Line data Source code
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 : #ifndef INCLUDED_SD_SOURCE_UI_INC_DRAWVIEWSHELL_HXX
21 : #define INCLUDED_SD_SOURCE_UI_INC_DRAWVIEWSHELL_HXX
22 :
23 : #include "ViewShell.hxx"
24 : #include "tools/AsynchronousCall.hxx"
25 : #include <sfx2/viewfac.hxx>
26 : #include <sfx2/viewsh.hxx>
27 : #include "TabControl.hxx"
28 : #include "pres.hxx"
29 : #include <svx/sidebar/SelectionChangeHandler.hxx>
30 : #include <com/sun/star/lang/XEventListener.hpp>
31 : #include <com/sun/star/scanner/XScannerManager2.hpp>
32 : #include <unotools/caserotate.hxx>
33 :
34 : class Outliner;
35 : class SdPage;
36 : class DrawDocShell;
37 : class TabBar;
38 : class SdrObject;
39 : class SdrPageView;
40 : class TransferableDataHelper;
41 : class TransferableClipboardListener;
42 : class AbstractSvxNameDialog;
43 : class SdrLayer;
44 : class SvxClipboardFmtItem;
45 : struct ESelection;
46 :
47 : namespace sd {
48 :
49 : class DrawView;
50 : class LayerTabBar;
51 : class Ruler;
52 : class AnnotationManager;
53 : class ViewOverlayManager;
54 :
55 : #define CHECK_RANGE(nMin, nValue, nMax) ((nValue >= nMin) && (nValue <= nMax))
56 :
57 : /** Base class of the stacked shells that provide graphical views to
58 : Draw and Impress documents and editing functionality. In contrast
59 : to this other stacked shells are responsible for showing an
60 : overview over several slides or a textual
61 : overview over the text in an Impress document (OutlineViewShell).
62 : */
63 : class DrawViewShell
64 : : public ViewShell,
65 : public SfxListener
66 : {
67 : public:
68 : static const int SLOTARRAY_COUNT = 24;
69 :
70 : TYPEINFO_OVERRIDE();
71 72 : SFX_DECL_INTERFACE(SD_IF_SDDRAWVIEWSHELL)
72 :
73 : private:
74 : /// SfxInterface initializer.
75 : static void InitInterface_Impl();
76 :
77 : public:
78 : /** Create a new stackable shell that may take some information
79 : (e.g. the frame view) from the given previous shell.
80 : @param ePageKind
81 : This parameter gives the initial page kind that the new shell
82 : will show.
83 : @param pFrameView
84 : The frame view that makes it possible to pass information from
85 : one view shell to the next.
86 : */
87 : DrawViewShell (
88 : SfxViewFrame* pFrame,
89 : ViewShellBase& rViewShellBase,
90 : ::vcl::Window* pParentWindow,
91 : PageKind ePageKind = PK_STANDARD,
92 : FrameView* pFrameView = NULL);
93 :
94 : virtual ~DrawViewShell (void);
95 :
96 : virtual void Init (bool bIsMainViewShell) SAL_OVERRIDE;
97 :
98 : virtual void Shutdown (void) SAL_OVERRIDE;
99 :
100 : void PrePaint() SAL_OVERRIDE;
101 : virtual void Paint(const Rectangle& rRect, ::sd::Window* pWin) SAL_OVERRIDE;
102 :
103 : /** Set the position and size of the area which contains the GUI
104 : elements like rulers, sliders, and buttons as well as the document
105 : view. Both size and position are expected to be in pixel
106 : coordinates. The positions and sizes of the mentioned GUI elements
107 : are updated as well.
108 :
109 : <p> This method is implemented by first setting copying the given
110 : values to internal variables and then calling the
111 : <type>ArrangeGUIElements</type> method which performs the actual
112 : work of sizeing and arranging the UI elements accordingly.</p>
113 : @param rPos
114 : The position of the enclosing window relative to the document
115 : window. This is only interesting if a Draw/Impress document
116 : view is embedded as OLE object into another document view. For
117 : normal documents this position is (0,0).
118 : @param rSize
119 : The new size in pixel.
120 : */
121 : // virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
122 :
123 : /** Arrange and resize the GUI elements like rulers, sliders, and
124 : buttons as well as the actual document view according to the size of
125 : the enclosing window and current sizes of buttons, rulers, and
126 : sliders.
127 : */
128 : virtual void ArrangeGUIElements (void) SAL_OVERRIDE;
129 :
130 : void HidePage();
131 :
132 : virtual bool KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin) SAL_OVERRIDE;
133 : virtual void MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin) SAL_OVERRIDE;
134 : virtual void MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin) SAL_OVERRIDE;
135 : virtual void MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin) SAL_OVERRIDE;
136 : virtual void Command(const CommandEvent& rCEvt, ::sd::Window* pWin) SAL_OVERRIDE;
137 :
138 : virtual void Resize (void) SAL_OVERRIDE;
139 :
140 : void ShowMousePosInfo(const Rectangle& rRect, ::sd::Window* pWin);
141 :
142 : virtual void AddWindow(::sd::Window* pWin);
143 : virtual void RemoveWindow(::sd::Window* pWin);
144 :
145 : virtual void ChangeEditMode (EditMode eMode, bool bIsLayerModeActive);
146 :
147 : virtual void SetZoom( long nZoom ) SAL_OVERRIDE;
148 : virtual void SetZoomRect( const Rectangle& rZoomRect ) SAL_OVERRIDE;
149 :
150 : void InsertURLField(const OUString& rURL, const OUString& rText, const OUString& rTarget,
151 : const Point* pPos);
152 : void InsertURLButton(const OUString& rURL, const OUString& rText, const OUString& rTarget,
153 : const Point* pPos);
154 :
155 : virtual void SetUIUnit(FieldUnit eUnit) SAL_OVERRIDE;
156 :
157 : void SelectionHasChanged();
158 : void ModelHasChanged();
159 : virtual void Activate(bool bIsMDIActivate) SAL_OVERRIDE;
160 : virtual void Deactivate(bool IsMDIActivate) SAL_OVERRIDE;
161 : virtual void UIActivating( SfxInPlaceClient* ) SAL_OVERRIDE;
162 : virtual void UIDeactivated( SfxInPlaceClient* ) SAL_OVERRIDE;
163 : virtual OUString GetSelectionText( bool bCompleteWords = false );
164 : virtual bool HasSelection( bool bText = true ) const;
165 :
166 : //If we are editing an PRESOBJ_OUTLINE return the Outliner and fill rSel
167 : //with the current selection
168 : ::Outliner* GetOutlinerForMasterPageOutlineTextObj(ESelection &rSel);
169 :
170 : void ExecCtrl(SfxRequest& rReq);
171 : void GetCtrlState(SfxItemSet& rSet);
172 : void GetDrawAttrState(SfxItemSet& rSet);
173 : void GetMenuState(SfxItemSet& rSet);
174 : void GetTableMenuState(SfxItemSet& rSet);
175 : /** Set the items of the given item set that are related to
176 : switching the editing mode to the correct values.
177 : <p>This function also sets the states of the mode buttons
178 : (those at the upper right corner) accordingly.</p>
179 : */
180 : void GetModeSwitchingMenuState (SfxItemSet &rSet);
181 : void GetAttrState(SfxItemSet& rSet);
182 : void GetSnapItemState(SfxItemSet& rSet);
183 :
184 : void GetState (SfxItemSet& rSet);
185 : void Execute (SfxRequest& rReq);
186 :
187 : void ExecStatusBar(SfxRequest& rReq);
188 : void GetStatusBarState(SfxItemSet& rSet);
189 :
190 : void ExecOptionsBar(SfxRequest& rReq);
191 : void GetOptionsBarState(SfxItemSet& rSet);
192 :
193 : void ExecRuler(SfxRequest& rReq);
194 : void GetRulerState(SfxItemSet& rSet);
195 :
196 : void ExecFormText(SfxRequest& rReq);
197 : void GetFormTextState(SfxItemSet& rSet);
198 :
199 : void ExecAnimationWin(SfxRequest& rReq);
200 : void GetAnimationWinState(SfxItemSet& rSet);
201 :
202 : void ExecNavigatorWin(SfxRequest& rReq);
203 : void GetNavigatorWinState(SfxItemSet& rSet);
204 :
205 : void ExecutePropPanelAttr (SfxRequest& rReq);
206 : void GetStatePropPanelAttr(SfxItemSet& rSet);
207 :
208 : void ExecEffectWin(SfxRequest& rReq);
209 :
210 : void Update3DWindow();
211 : void AssignFrom3DWindow();
212 :
213 : void ExecGallery(SfxRequest& rReq);
214 :
215 : void ExecBmpMask( SfxRequest& rReq );
216 : void GetBmpMaskState( SfxItemSet& rSet );
217 :
218 : void ExecIMap( SfxRequest& rReq );
219 : void GetIMapState( SfxItemSet& rSet );
220 :
221 : void FuTemporary(SfxRequest& rReq);
222 : void FuPermanent(SfxRequest& rReq);
223 : void FuSupport(SfxRequest& rReq);
224 : void FuSupportRotate(SfxRequest& rReq);
225 : void FuTable(SfxRequest& rReq);
226 :
227 : void AttrExec (SfxRequest& rReq);
228 : void AttrState (SfxItemSet& rSet);
229 :
230 : void ExecChar(SfxRequest& rReq);
231 :
232 : void ExecuteAnnotation (SfxRequest& rRequest);
233 : void GetAnnotationState (SfxItemSet& rItemSet);
234 :
235 : void StartRulerDrag (
236 : const Ruler& rRuler,
237 : const MouseEvent& rMEvt);
238 :
239 : virtual bool PrepareClose( bool bUI = true ) SAL_OVERRIDE;
240 :
241 52 : PageKind GetPageKind() { return mePageKind; }
242 0 : void SetPageKind( PageKind ePageKind ) { mePageKind = ePageKind; }
243 0 : Point GetMousePos() { return maMousePos; }
244 : bool IsMousePosFreezed() { return mbMousePosFreezed; }
245 0 : void SetMousePosFreezed( bool bIn ) { mbMousePosFreezed = bIn; }
246 :
247 336 : EditMode GetEditMode() const { return meEditMode; }
248 918 : virtual SdPage* GetActualPage() SAL_OVERRIDE { return mpActualPage; }
249 :
250 : /// inherited from sd::ViewShell
251 : virtual SdPage* getCurrentPage() const SAL_OVERRIDE;
252 :
253 : void ResetActualPage();
254 : void ResetActualLayer();
255 : bool SwitchPage(sal_uInt16 nPage);
256 : bool IsSwitchPageAllowed() const;
257 :
258 : bool GotoBookmark(const OUString& rBookmark);
259 : //Realize multi-selection of objects, If object is marked, the
260 : //corresponding entry is set true, else the corresponding entry is set
261 : //false.
262 : void FreshNavigatrEntry();
263 : void FreshNavigatrTree();
264 : void MakeVisible(const Rectangle& rRect, ::vcl::Window& rWin);
265 :
266 : virtual void ReadFrameViewData(FrameView* pView) SAL_OVERRIDE;
267 : virtual void WriteFrameViewData() SAL_OVERRIDE;
268 :
269 : virtual ErrCode DoVerb(long nVerb) SAL_OVERRIDE;
270 : virtual bool ActivateObject(SdrOle2Obj* pObj, long nVerb) SAL_OVERRIDE;
271 :
272 0 : void SetZoomOnPage( bool bZoom = true ) { mbZoomOnPage = bZoom; }
273 0 : bool IsZoomOnPage() { return mbZoomOnPage; }
274 : void CheckLineTo (SfxRequest& rReq);
275 : void SetChildWindowState( SfxItemSet& rSet );
276 :
277 : void UpdateIMapDlg( SdrObject* pObj );
278 :
279 : void LockInput();
280 : void UnlockInput();
281 0 : bool IsInputLocked() const { return mnLockCount > 0UL; }
282 :
283 0 : sal_uInt16 GetCurPageId() { return( maTabControl.GetCurPageId() ); }
284 :
285 : /** Show controls of the UI or hide them, depending on the given flag.
286 : Do not call this method directly. Call the method at ViewShellBase
287 : instead.
288 : */
289 : virtual void ShowUIControls (bool bVisible = true) SAL_OVERRIDE;
290 :
291 : void ScannerEvent( const ::com::sun::star::lang::EventObject& rEventObject );
292 :
293 11057 : bool IsLayerModeActive (void) const { return mbIsLayerModeActive;}
294 :
295 0 : sal_uInt16* GetSlotArray() const { return mpSlotArray; }
296 :
297 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
298 : ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer ) SAL_OVERRIDE;
299 : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper,
300 : ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer ) SAL_OVERRIDE;
301 :
302 : virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, bool bBrowse = false ) SAL_OVERRIDE;
303 : virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, bool bBrowse = false ) SAL_OVERRIDE;
304 :
305 : virtual void VisAreaChanged(const Rectangle& rRect) SAL_OVERRIDE;
306 :
307 : /** Create an accessible object representing the specified window.
308 : @param pWindow
309 : The returned object makes the document displayed in this window
310 : accessible.
311 : @return
312 : Returns an <type>AccessibleDrawDocumentView</type> object.
313 : */
314 : virtual ::com::sun::star::uno::Reference<
315 : ::com::sun::star::accessibility::XAccessible>
316 : CreateAccessibleDocumentView (::sd::Window* pWindow) SAL_OVERRIDE;
317 :
318 : /** Return the number of layers managed by the layer tab control. This
319 : will usually differ from the number of layers managed by the layer
320 : administrator.
321 : @return
322 : The number of layers managed by the layer tab control. The
323 : returned value is independent of whether the layer modus is
324 : currently active and the tab control is visible.
325 : */
326 : virtual int GetTabLayerCount (void) const;
327 :
328 : /** Return the numerical id of the currently active layer as seen by the
329 : layer tab control.
330 : @return
331 : The returned id is a number between zero (inclusive) and the
332 : number of layers as returned by the
333 : <member>GetTabLayerCount</member> method (exclusive).
334 : */
335 : virtual int GetActiveTabLayerIndex (void) const;
336 :
337 : /** Set the active layer at the layer tab control and update the control
338 : accordingly to reflect the change on screen.
339 : @param nId
340 : The id is expected to be a number between zero (inclusive) and
341 : the number of layers as returned by the
342 : <member>GetTabLayerCount</member> method (exclusive). Note that
343 : Invalid values are ignored. No excpetion is thrown in that case.
344 : */
345 : virtual void SetActiveTabLayerIndex (int nId);
346 :
347 : /** Return a pointer to the tab control for pages.
348 : */
349 0 : TabControl& GetPageTabControl (void) { return maTabControl;}
350 :
351 : /** Return a pointer to the tab control for layers.
352 : */
353 : LayerTabBar* GetLayerTabControl (void);
354 :
355 : /** Renames the given slide using an SvxNameDialog
356 :
357 : @param nPageId the index of the page in the SdTabControl.
358 : @param rName the new name of the slide.
359 :
360 : @return false, if the new name is invalid for some reason.
361 :
362 : <p>Implemented in <code>drviews8.cxx</code>.</p>
363 : */
364 : bool RenameSlide( sal_uInt16 nPageId, const OUString & rName );
365 :
366 : /** modifies the given layer with the given values */
367 : void ModifyLayer( SdrLayer* pLayer, const OUString& rLayerName, const OUString& rLayerTitle, const OUString& rLayerDesc, bool bIsVisible, bool bIsLocked, bool bIsPrintable );
368 :
369 : virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController (void) SAL_OVERRIDE;
370 :
371 4223 : DrawView* GetDrawView() const { return mpDrawView; }
372 :
373 : /** Relocation to a new parent window is not supported for DrawViewShell
374 : objects so this method always returns <FALSE/>.
375 : */
376 : virtual bool RelocateToParentWindow (::vcl::Window* pParentWindow) SAL_OVERRIDE;
377 :
378 : OUString GetSidebarContextName (void) const;
379 :
380 : //move this method to ViewShell.
381 : //void NotifyAccUpdate();
382 : protected:
383 : DrawView* mpDrawView;
384 : SdPage* mpActualPage;
385 : Rectangle maMarkRect;
386 : Point maMousePos;
387 : bool mbMousePosFreezed;
388 : TabControl maTabControl;
389 : EditMode meEditMode;
390 : PageKind mePageKind;
391 : bool mbZoomOnPage;
392 : bool mbIsRulerDrag;
393 : sal_uLong mnLockCount;
394 : bool mbReadOnly;
395 : sal_uInt16* mpSlotArray;
396 :
397 : static bool mbPipette;
398 :
399 : DECL_LINK( ClipboardChanged, TransferableDataHelper* );
400 : DECL_LINK( TabSplitHdl, TabBar * );
401 : DECL_LINK( NameObjectHdl, AbstractSvxNameDialog* );
402 : DECL_LINK( RenameSlideHdl, AbstractSvxNameDialog* );
403 :
404 : void DeleteActualPage();
405 : void DeleteActualLayer();
406 :
407 : virtual SvxRuler* CreateHRuler(::sd::Window* pWin, bool bIsFirst) SAL_OVERRIDE;
408 : virtual SvxRuler* CreateVRuler(::sd::Window* pWin) SAL_OVERRIDE;
409 : virtual void UpdateHRuler() SAL_OVERRIDE;
410 : virtual void UpdateVRuler() SAL_OVERRIDE;
411 : virtual void SetZoomFactor(const Fraction& rZoomX, const Fraction& rZoomY) SAL_OVERRIDE;
412 :
413 : void SetupPage( Size &rSize, long nLeft, long nRight, long nUpper, long nLower,
414 : bool bSize, bool bMargin, bool bScaleAll );
415 :
416 : sal_uInt16 GetIdBySubId( sal_uInt16 nSId );
417 : void MapSlot( sal_uInt16 nSId );
418 : void UpdateToolboxImages( SfxItemSet &rSet, bool bPermanent = true );
419 : sal_uInt16 GetMappedSlot( sal_uInt16 nSId );
420 : sal_uInt16 GetArrayId( sal_uInt16 nSId );
421 :
422 : void GetMenuStateSel(SfxItemSet& rSet);
423 :
424 : private:
425 : void ShowSlideShow(SfxRequest& rReq);
426 : /** This flag controls whether the layer mode is active, i.e. the layer
427 : dialog is visible.
428 : */
429 : bool mbIsLayerModeActive;
430 :
431 : /** This item contains the clipboard formats of the current clipboard
432 : content that are supported both by that content and by the
433 : DrawViewShell.
434 : */
435 : ::std::unique_ptr<SvxClipboardFmtItem> mpCurrentClipboardFormats;
436 :
437 : /** On some occasions it is necessary to make SwitchPage calls
438 : asynchronously.
439 : */
440 : tools::AsynchronousCall maAsynchronousSwitchPageCall;
441 :
442 : /** This flag is used to prevent nested calls to SwitchPage().
443 : */
444 : bool mbIsInSwitchPage;
445 :
446 : RotateTransliteration m_aRotateCase;
447 :
448 : /** Listen for selection changes and broadcast context changes for the sidebar.
449 : */
450 : ::rtl::Reference<svx::sidebar::SelectionChangeHandler> mpSelectionChangeHandler;
451 :
452 : void Construct (DrawDocShell* pDocSh, PageKind ePageKind);
453 :
454 : /** Depending on the given request create a new page or duplicate an
455 : existing one. See ViewShell::CreateOrDuplicatePage() for more
456 : information.
457 : */
458 : virtual SdPage* CreateOrDuplicatePage (
459 : SfxRequest& rRequest,
460 : PageKind ePageKind,
461 : SdPage* pPage,
462 : const sal_Int32 nInsertPosition = -1) SAL_OVERRIDE;
463 :
464 : ::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager2 > mxScannerManager;
465 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > mxScannerListener;
466 : TransferableClipboardListener* mpClipEvtLstnr;
467 : bool mbPastePossible;
468 :
469 : virtual void Notify (SfxBroadcaster& rBC, const SfxHint& rHint) SAL_OVERRIDE;
470 :
471 : /** Stop a running slide show. The frame the show is running in is
472 : destroyed if
473 : a) it is running in its own frame, i.e. is a full screen show and
474 : b) the given flag bCloseFrame is true.
475 : @param bCloseFrame
476 : Be careful with this flag when stopping a full screen show.
477 : When called from the destructor the flag has to be <FALSE/> or
478 : otherwise we run into a loop of calls to destructors of the view
479 : and the frame.
480 : When called from other places the flag should be <TRUE/> so that
481 : not an empty frame remains. When called with <TRUE/> it is the
482 : responsibility of the caller to avoid an illegal reentrant
483 : call.
484 : */
485 : void StopSlideShow (bool bCloseFrame);
486 :
487 : /** Show the context menu for snap lines and points. Because snap lines
488 : can not be selected the index of the snap line/point for which the
489 : popup menu is opened has to be passed to the processing slot
490 : handlers. This can be done only by manually showing the popup menu.
491 : @param rPageView
492 : The page view is used to access the help lines.
493 : @param nSnapLineIndex
494 : Index of the snap line or snap point for which to show the
495 : context menu.
496 : @param rMouseLocation
497 : The mouse location defines the location at which to display the
498 : context menu.
499 : */
500 : void ShowSnapLineContextMenu (
501 : SdrPageView& rPageView,
502 : const sal_uInt16 nSnapLineIndex,
503 : const Point& rMouseLocation);
504 :
505 : using ViewShell::Notify;
506 :
507 : ::std::unique_ptr< AnnotationManager > mpAnnotationManager;
508 : ::std::unique_ptr< ViewOverlayManager > mpViewOverlayManager;
509 : };
510 :
511 : } // end of namespace sd
512 :
513 : #endif
514 :
515 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|