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