LibreOffice Module sd (master) 1
fuoltext.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <fuoltext.hxx>
21
22#include <sfx2/viewfrm.hxx>
23#include <editeng/outliner.hxx>
24#include <editeng/flditem.hxx>
25#include <sfx2/bindings.hxx>
26#include <sfx2/docfile.hxx>
27#include <sfx2/dispatch.hxx>
28#include <tools/debug.hxx>
29#include <svl/stritem.hxx>
30
31#include <svx/svxids.hrc>
32#include <app.hrc>
33#include <OutlineView.hxx>
34#include <Window.hxx>
35#include <DrawDocShell.hxx>
36#include <ViewShell.hxx>
37#include <OutlineViewShell.hxx>
38
39#include <memory>
40
41namespace sd {
42
43const sal_uInt16 SidArray[] = {
44 SID_STYLE_FAMILY2,
45 SID_STYLE_FAMILY3,
46 SID_STYLE_FAMILY5,
47 SID_STYLE_UPDATE_BY_EXAMPLE,
48 SID_CUT,
49 SID_COPY,
50 SID_PASTE,
51 SID_SELECTALL,
52 SID_ATTR_CHAR_FONT,
53 SID_ATTR_CHAR_POSTURE,
54 SID_ATTR_CHAR_WEIGHT,
55 SID_ATTR_CHAR_SHADOWED,
56 SID_ATTR_CHAR_STRIKEOUT,
57 SID_ATTR_CHAR_UNDERLINE,
58 SID_ATTR_CHAR_FONTHEIGHT,
59 SID_ATTR_CHAR_COLOR,
60 SID_ATTR_CHAR_KERNING,
61 SID_OUTLINE_UP,
62 SID_OUTLINE_DOWN,
63 SID_OUTLINE_LEFT,
64 SID_OUTLINE_RIGHT,
65 //SID_OUTLINE_FORMAT,
66 SID_OUTLINE_COLLAPSE_ALL,
67 //SID_OUTLINE_BULLET,
68 SID_OUTLINE_COLLAPSE,
69 SID_OUTLINE_EXPAND_ALL,
70 SID_OUTLINE_EXPAND,
71 SID_SET_SUPER_SCRIPT,
72 SID_SET_SUB_SCRIPT,
73 SID_HYPERLINK_GETLINK,
74 SID_DEC_INDENT,
75 SID_INC_INDENT,
76 SID_PARASPACE_INCREASE,
77 SID_PARASPACE_DECREASE,
78 SID_SCALE,
79 SID_STATUS_PAGE,
80 SID_STATUS_LAYOUT,
81 SID_EXPAND_PAGE,
82 SID_SUMMARY_PAGE,
83 0 };
84
85
87 ::sd::View* pView, SdDrawDocument* pDoc,
88 SfxRequest& rReq)
89 : FuPoor(pViewShell, pWindow, pView, pDoc, rReq),
90 pOutlineViewShell (static_cast<OutlineViewShell*>(pViewShell)),
91 pOutlineView (static_cast<OutlineView*>(pView))
92{
93}
94
99{
100 bool bResult = false;
101
102 OutlinerView* pOlView =
103 static_cast<OutlineView*>(mpView)->GetViewByWindow(mpWindow);
104 DBG_ASSERT (pOlView, "no OutlineView found");
105
106 if (pOlView)
107 {
108 pOlView->Command(rCEvt); // unfortunately, we do not get a return value
109 bResult = true;
110 }
111 return bResult;
112}
113
114
116{
117 rtl::Reference<FuPoor> xFunc( new FuOutlineText( pViewSh, pWin, pView, pDoc, rReq ) );
118 xFunc->DoExecute( rReq );
119 return xFunc;
120}
121
123{
124 mpWindow->GrabFocus();
125
126 bool bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonDown(rMEvt);
127
128 if (bReturn)
129 {
130 // Now the attributes of the current text position can be different
132 }
133 else
134 {
135 bReturn = FuPoor::MouseButtonDown(rMEvt);
136 }
137
138 return bReturn;
139}
140
142{
143 bool bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseMove(rMEvt);
144
145 if (!bReturn)
146 {
147 bReturn = FuPoor::MouseMove(rMEvt);
148 }
149
150 return bReturn;
151}
152
154{
155 bool bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonUp(rMEvt);
156
157 if (bReturn)
158 {
159 // Now the attributes of the current text position can be different
161 }
162 else
163 {
165 if( pFieldItem )
166 {
167 const SvxFieldData* pField = pFieldItem->GetField();
168
169 if( auto pURLField = dynamic_cast< const SvxURLField *>( pField ) )
170 {
171 bReturn = true;
172 mpWindow->ReleaseMouse();
173 SfxStringItem aStrItem( SID_FILE_NAME, pURLField->GetURL() );
174 SfxStringItem aReferer( SID_REFERER, mpDocSh->GetMedium()->GetName() );
175 SfxBoolItem aBrowseItem( SID_BROWSE, true );
177
178 if ( rMEvt.IsMod1() )
179 {
180 // open in new frame
181 pFrame->GetDispatcher()->ExecuteList(SID_OPENDOC,
182 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
183 { &aStrItem, &aBrowseItem, &aReferer });
184 }
185 else
186 {
187 // open in current frame
188 SfxFrameItem aFrameItem( SID_DOCFRAME, pFrame );
189 pFrame->GetDispatcher()->ExecuteList(SID_OPENDOC,
190 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
191 { &aStrItem, &aFrameItem, &aBrowseItem, &aReferer });
192 }
193 }
194 }
195 }
196
197 if( !bReturn )
198 bReturn = FuPoor::MouseButtonUp(rMEvt);
199
200 return bReturn;
201}
202
208{
209 bool bReturn = false;
210
211 sal_uInt16 nKeyGroup = rKEvt.GetKeyCode().GetGroup();
212 if( !mpDocSh->IsReadOnly() || nKeyGroup == KEYGROUP_CURSOR )
213 {
214 mpWindow->GrabFocus();
215
216 std::unique_ptr<OutlineViewModelChangeGuard, o3tl::default_delete<OutlineViewModelChangeGuard>> aGuard;
217 if( (nKeyGroup != KEYGROUP_CURSOR) && (nKeyGroup != KEYGROUP_FKEYS) )
218 aGuard.reset( new OutlineViewModelChangeGuard( *pOutlineView ) );
219
221
222 if (bReturn)
223 {
224 UpdateForKeyPress (rKEvt);
225 }
226 else
227 {
228 bReturn = FuPoor::KeyInput(rKEvt);
229 }
230 }
231
232 return bReturn;
233}
234
236{
237 // Attributes at the current text position may have changed.
239
240 bool bUpdatePreview = true;
241 switch (rEvent.GetKeyCode().GetCode())
242 {
243 // When just the cursor has been moved the preview only changes when
244 // it moved to entries of another page. To prevent unnecessary
245 // updates we check this here. This is an early rejection test, so
246 // missing a key is not a problem.
247 case KEY_UP:
248 case KEY_DOWN:
249 case KEY_LEFT:
250 case KEY_RIGHT:
251 case KEY_HOME:
252 case KEY_END:
253 case KEY_PAGEUP:
254 case KEY_PAGEDOWN:
255 {
256 SdPage* pCurrentPage = pOutlineViewShell->GetActualPage();
257 bUpdatePreview = (pCurrentPage != pOutlineViewShell->GetActualPage());
258 }
259 break;
260 }
261 if (bUpdatePreview)
263}
264
269{
271}
272
277{
279}
280
285{
287}
288
293{
295 if (aDataHelper.GetTransferable().is())
296 {
297 OUString aText;
298 if (aDataHelper.GetString(SotClipboardFormatId::STRING, aText))
300 }
301}
302
303} // end of namespace sd
304
305/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const vcl::KeyCode & GetKeyCode() const
bool IsMod1() const
bool MouseMove(const MouseEvent &)
bool Command(const CommandEvent &rCEvt)
void PasteSpecial()
bool MouseButtonUp(const MouseEvent &)
void InsertText(const OUString &rNew, bool bSelect=false)
bool PostKeyEvent(const KeyEvent &rKEvt, vcl::Window const *pFrameWin=nullptr)
const SvxFieldItem * GetFieldUnderMousePointer() const
bool MouseButtonDown(const MouseEvent &)
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
const OUString & GetName() const
bool IsReadOnly() const
SfxMedium * GetMedium() const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
const SvxFieldData * GetField() const
bool GetString(SotClipboardFormatId nFormat, OUString &rStr) const
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
virtual void DoPasteUnformatted() override
Paste object as unformatted text from clipboard.
Definition: fuoltext.cxx:292
virtual bool Command(const CommandEvent &rCEvt) override
forward to OutlinerView
Definition: fuoltext.cxx:98
virtual void DoCopy() override
Copy object to clipboard.
Definition: fuoltext.cxx:276
void UpdateForKeyPress(const KeyEvent &rEvent)
Call this method when the text in the outliner (may) has changed.
Definition: fuoltext.cxx:235
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fuoltext.cxx:115
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuoltext.cxx:153
virtual bool KeyInput(const KeyEvent &rKEvt) override
Process keyboard input.
Definition: fuoltext.cxx:207
virtual void DoPaste() override
Paste object from clipboard.
Definition: fuoltext.cxx:284
virtual void DoCut() override
Cut object to clipboard.
Definition: fuoltext.cxx:268
FuOutlineText(ViewShell *pViewShell, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fuoltext.cxx:86
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuoltext.cxx:122
OutlineView * pOutlineView
Definition: fuoltext.hxx:71
virtual bool MouseMove(const MouseEvent &rMEvt) override
Definition: fuoltext.cxx:141
OutlineViewShell * pOutlineViewShell
Definition: fuoltext.hxx:70
Base class for all functions.
Definition: fupoor.hxx:48
virtual bool MouseButtonDown(const MouseEvent &rMEvt)
Definition: fupoor.cxx:975
virtual bool MouseMove(const MouseEvent &)
Definition: fupoor.cxx:863
virtual bool MouseButtonUp(const MouseEvent &rMEvt)
Definition: fupoor.cxx:965
virtual bool KeyInput(const KeyEvent &rKEvt)
handle keyboard events
Definition: fupoor.cxx:175
VclPtr< ::sd::Window > mpWindow
Definition: fupoor.hxx:146
ViewShell * mpViewShell
Definition: fupoor.hxx:145
DrawDocShell * mpDocSh
Definition: fupoor.hxx:147
::sd::View * mpView
Definition: fupoor.hxx:144
Show a textual overview of the text contents of all slides.
virtual void UpdatePreview(SdPage *pPage) override
Update the preview to show the specified page.
Definition: outlnvsh.cxx:1549
virtual SdPage * GetActualPage() override
Returns the first selected page.
Definition: outlnvsh.cxx:1544
Derivative of sd::View for the outline mode |* .
Definition: OutlineView.hxx:55
OutlinerView * GetViewByWindow(vcl::Window const *pWin) const
Return a pointer to the OutlinerView corresponding to the window.
Definition: outlview.cxx:262
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
Definition: ViewShell.hxx:155
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
sal_uInt16 GetGroup() const
sal_uInt16 GetCode() const
#define DBG_ASSERT(sCon, aError)
constexpr sal_uInt16 KEY_HOME
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_PAGEDOWN
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEYGROUP_FKEYS
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DOWN
constexpr sal_uInt16 KEY_PAGEUP
constexpr sal_uInt16 KEY_END
constexpr sal_uInt16 KEYGROUP_CURSOR
const sal_uInt16 SidArray[]
Definition: fuoltext.cxx:43