bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / inc / DrawViewShell.hxx
blob713cac92c2fce64de3c3eb6314347bf343a01355
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 <memory>
24 #include "ViewShell.hxx"
25 #include "tools/AsynchronousCall.hxx"
26 #include "TabControl.hxx"
27 #include <glob.hxx>
28 #include <pres.hxx>
29 #include <unotools/caserotate.hxx>
30 #include <unotools/options.hxx>
31 #include <sddllapi.h>
33 namespace svx { namespace sidebar { class SelectionChangeHandler; } }
34 namespace com { namespace sun { namespace star { namespace lang { class XEventListener; } } } }
35 namespace com { namespace sun { namespace star { namespace scanner { class XScannerManager2; } } } }
37 class Outliner;
38 class SdPage;
39 class SdStyleSheet;
40 class SdrExternalToolEdit;
41 class TabBar;
42 class SdrObject;
43 class SdrPageView;
44 class TransferableDataHelper;
45 class TransferableClipboardListener;
46 class AbstractSvxNameDialog;
47 class SdrLayer;
48 class SvxClipboardFormatItem;
49 struct ESelection;
50 class AbstractSvxObjectNameDialog;
52 namespace sd {
54 class DrawView;
55 class LayerTabBar;
56 class Ruler;
57 class AnnotationManager;
58 class ViewOverlayManager;
60 #define CHECK_RANGE(nMin, nValue, nMax) ((nValue >= nMin) && (nValue <= nMax))
62 /** Base class of the stacked shells that provide graphical views to
63 Draw and Impress documents and editing functionality. In contrast
64 to this other stacked shells are responsible for showing an
65 overview over several slides or a textual
66 overview over the text in an Impress document (OutlineViewShell).
68 class SAL_DLLPUBLIC_RTTI DrawViewShell
69 : public ViewShell,
70 public SfxListener,
71 public utl::ConfigurationListener
73 public:
74 SFX_DECL_INTERFACE(SD_IF_SDDRAWVIEWSHELL)
76 private:
77 /// SfxInterface initializer.
78 static void InitInterface_Impl();
80 public:
81 /** Create a new stackable shell that may take some information
82 (e.g. the frame view) from the given previous shell.
83 @param ePageKind
84 This parameter gives the initial page kind that the new shell
85 will show.
86 @param pFrameView
87 The frame view that makes it possible to pass information from
88 one view shell to the next.
90 DrawViewShell (
91 ViewShellBase& rViewShellBase,
92 vcl::Window* pParentWindow,
93 PageKind ePageKind,
94 FrameView* pFrameView);
96 virtual ~DrawViewShell() override;
98 virtual void Init (bool bIsMainViewShell) override;
100 virtual void Shutdown() override;
102 void PrePaint() override;
103 virtual void Paint(const ::tools::Rectangle& rRect, ::sd::Window* pWin) override;
105 /** Arrange and resize the GUI elements like rulers, sliders, and
106 buttons as well as the actual document view according to the size of
107 the enclosing window and current sizes of buttons, rulers, and
108 sliders.
110 virtual void ArrangeGUIElements() override;
112 void HidePage();
114 virtual bool KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin) override;
115 virtual void MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin) override;
116 virtual void MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin) override;
117 virtual void MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin) override;
118 virtual void Command(const CommandEvent& rCEvt, ::sd::Window* pWin) override;
119 bool IsMouseButtonDown() { return mbMouseButtonDown; }
120 bool IsMouseSelecting() { return mbMouseSelecting; }
122 virtual void Resize() override;
124 void ShowMousePosInfo(const ::tools::Rectangle& rRect, ::sd::Window const * pWin);
126 virtual void ChangeEditMode (EditMode eMode, bool bIsLayerModeActive);
128 virtual void SetZoom( long nZoom ) override;
129 virtual void SetZoomRect( const ::tools::Rectangle& rZoomRect ) override;
131 void InsertURLField(const OUString& rURL, const OUString& rText, const OUString& rTarget);
132 void InsertURLButton(const OUString& rURL, const OUString& rText, const OUString& rTarget,
133 const Point* pPos);
135 void SelectionHasChanged();
136 void ModelHasChanged();
137 virtual void Activate(bool bIsMDIActivate) override;
138 virtual void Deactivate(bool IsMDIActivate) override;
139 virtual void UIActivating( SfxInPlaceClient* ) override;
140 virtual void UIDeactivated( SfxInPlaceClient* ) override;
141 OUString GetSelectionText( bool bCompleteWords );
142 bool HasSelection( bool bText ) const;
144 //If we are editing an PRESOBJ_OUTLINE return the Outliner and fill rSel
145 //with the current selection
146 ::Outliner* GetOutlinerForMasterPageOutlineTextObj(ESelection &rSel);
148 void ExecCtrl(SfxRequest& rReq);
149 void GetCtrlState(SfxItemSet& rSet);
150 void GetDrawAttrState(SfxItemSet& rSet);
151 void GetMenuState(SfxItemSet& rSet);
152 void GetTableMenuState(SfxItemSet& rSet);
153 /** Set the items of the given item set that are related to
154 switching the editing mode to the correct values.
155 <p>This function also sets the states of the mode buttons
156 (those at the upper right corner) accordingly.</p>
158 void GetModeSwitchingMenuState (SfxItemSet &rSet);
159 void GetAttrState(SfxItemSet& rSet);
160 void GetSnapItemState(SfxItemSet& rSet);
162 void SetPageProperties (SfxRequest& rReq);
163 void GetPageProperties(SfxItemSet& rSet);
164 void GetMarginProperties(SfxItemSet& rSet);
166 void GetState (SfxItemSet& rSet);
167 void Execute (SfxRequest& rReq);
169 void ExecStatusBar(SfxRequest& rReq);
170 void GetStatusBarState(SfxItemSet& rSet);
172 void ExecOptionsBar(SfxRequest& rReq);
173 void GetOptionsBarState(SfxItemSet& rSet);
175 void ExecRuler(SfxRequest& rReq);
176 void GetRulerState(SfxItemSet& rSet);
178 void ExecFormText(SfxRequest& rReq);
179 void GetFormTextState(SfxItemSet& rSet);
181 void ExecAnimationWin(SfxRequest& rReq);
182 void GetAnimationWinState(SfxItemSet& rSet);
184 void ExecNavigatorWin(SfxRequest& rReq);
185 void GetNavigatorWinState(SfxItemSet& rSet);
187 void ExecutePropPanelAttr (SfxRequest const & rReq);
188 void GetStatePropPanelAttr(SfxItemSet& rSet);
190 void ExecEffectWin(SfxRequest& rReq);
192 void Update3DWindow();
193 void AssignFrom3DWindow();
195 void ExecGallery(SfxRequest const & rReq);
197 void ExecBmpMask( SfxRequest const & rReq );
198 void GetBmpMaskState( SfxItemSet& rSet );
200 void ExecIMap( SfxRequest const & rReq );
201 void GetIMapState( SfxItemSet& rSet );
203 void FuTemporary(SfxRequest& rReq);
204 void FuPermanent(SfxRequest& rReq);
205 void FuSupport(SfxRequest& rReq);
206 void FuDeleteSelectedObjects();
207 void FuSupportRotate(SfxRequest const & rReq);
208 void FuTable(SfxRequest& rReq);
210 void AttrExec (SfxRequest& rReq);
211 void AttrState (SfxItemSet& rSet);
213 void ExecGoToNextPage (SfxRequest& rReq);
214 void GetStateGoToNextPage (SfxItemSet& rSet);
216 void ExecGoToPreviousPage (SfxRequest& rReq);
217 void GetStateGoToPreviousPage (SfxItemSet& rSet);
219 void ExecGoToFirstPage (SfxRequest& rReq);
220 void GetStateGoToFirstPage (SfxItemSet& rSet);
222 void ExecGoToLastPage (SfxRequest& rReq);
223 void GetStateGoToLastPage (SfxItemSet& rSet);
225 SD_DLLPUBLIC void ExecChar(SfxRequest& rReq);
227 void ExecuteAnnotation (SfxRequest const & rRequest);
228 void GetAnnotationState (SfxItemSet& rItemSet);
230 void StartRulerDrag (const Ruler& rRuler, const MouseEvent& rMEvt);
232 virtual bool PrepareClose( bool bUI = true ) override;
234 PageKind GetPageKind() { return mePageKind; }
235 void SetPageKind( PageKind ePageKind ) { mePageKind = ePageKind; }
236 const Point& GetMousePos() { return maMousePos; }
237 void SetMousePosFreezed( bool bIn ) { mbMousePosFreezed = bIn; }
239 EditMode GetEditMode() const { return meEditMode; }
240 virtual SdPage* GetActualPage() override { return mpActualPage; }
242 /// inherited from sd::ViewShell
243 virtual SdPage* getCurrentPage() const override;
245 void ResetActualPage();
246 void ResetActualLayer();
247 bool SwitchPage(sal_uInt16 nPage);
248 bool IsSwitchPageAllowed() const;
250 void GotoBookmark(const OUString& rBookmark);
251 //Realize multi-selection of objects, If object is marked, the
252 //corresponding entry is set true, else the corresponding entry is set
253 //false.
254 void FreshNavigatrEntry();
255 void FreshNavigatrTree();
256 void MakeVisible(const ::tools::Rectangle& rRect, vcl::Window& rWin);
258 virtual void ReadFrameViewData(FrameView* pView) override;
259 virtual void WriteFrameViewData() override;
261 virtual ErrCode DoVerb(long nVerb) override;
262 virtual bool ActivateObject(SdrOle2Obj* pObj, long nVerb) override;
264 void SetZoomOnPage( bool bZoom ) { mbZoomOnPage = bZoom; }
265 bool IsZoomOnPage() { return mbZoomOnPage; }
266 static void CheckLineTo (SfxRequest& rReq);
267 void SetChildWindowState( SfxItemSet& rSet );
269 void UpdateIMapDlg( SdrObject* pObj );
271 void LockInput();
272 void UnlockInput();
273 bool IsInputLocked() const { return mnLockCount > 0; }
275 sal_uInt16 GetCurPagePos() { return maTabControl->GetCurPagePos(); }
277 /** Show controls of the UI or hide them, depending on the given flag.
278 Do not call this method directly. Call the method at ViewShellBase
279 instead.
281 virtual void ShowUIControls (bool bVisible) override;
283 void ScannerEvent();
285 bool IsLayerModeActive() const { return mbIsLayerModeActive;}
287 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
288 ::sd::Window* pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer ) override;
289 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper,
290 ::sd::Window* pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer ) override;
292 virtual void WriteUserDataSequence ( css::uno::Sequence < css::beans::PropertyValue >& ) override;
293 virtual void ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >& ) override;
295 virtual void VisAreaChanged(const ::tools::Rectangle& rRect) override;
297 /** Create an accessible object representing the specified window.
298 @param pWindow
299 The returned object makes the document displayed in this window
300 accessible.
301 @return
302 Returns an <type>AccessibleDrawDocumentView</type> object.
304 virtual css::uno::Reference<css::accessibility::XAccessible>
305 CreateAccessibleDocumentView (::sd::Window* pWindow) override;
307 /** Return the number of layers managed by the layer tab control. This
308 will usually differ from the number of layers managed by the layer
309 administrator.
310 @return
311 The number of layers managed by the layer tab control. The
312 returned value is independent of whether the layer mode is
313 currently active and the tab control is visible.
315 int GetTabLayerCount() const;
317 /** Return the numerical id of the currently active layer as seen by the
318 layer tab control.
319 @return
320 The returned id is a number between zero (inclusive) and the
321 number of layers as returned by the
322 <member>GetTabLayerCount</member> method (exclusive).
324 int GetActiveTabLayerIndex() const;
326 /** Set the active layer at the layer tab control and update the control
327 accordingly to reflect the change on screen.
328 @param nId
329 The id is expected to be a number between zero (inclusive) and
330 the number of layers as returned by the
331 <member>GetTabLayerCount</member> method (exclusive). Note that
332 Invalid values are ignored. No exception is thrown in that case.
334 void SetActiveTabLayerIndex (int nId);
336 /** Return a pointer to the tab control for pages.
338 TabControl& GetPageTabControl() { return *maTabControl; }
340 /** Return a pointer to the tab control for layers.
342 SD_DLLPUBLIC LayerTabBar* GetLayerTabControl(); // export for unit test
344 /** Renames the given slide using an SvxNameDialog
346 @param nPageId the index of the page in the SdTabControl.
347 @param rName the new name of the slide.
349 @return false, if the new name is invalid for some reason.
351 <p>Implemented in <code>drviews8.cxx</code>.</p>
353 bool RenameSlide( sal_uInt16 nPageId, const OUString & rName );
355 /** modifies the given layer with the given values */
356 void ModifyLayer( SdrLayer* pLayer, const OUString& rLayerName, const OUString& rLayerTitle, const OUString& rLayerDesc, bool bIsVisible, bool bIsLocked, bool bIsPrintable );
358 virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController() override;
360 DrawView* GetDrawView() const { return mpDrawView.get(); }
362 /** Relocation to a new parent window is not supported for DrawViewShell
363 objects so this method always returns <FALSE/>.
365 virtual bool RelocateToParentWindow (vcl::Window* pParentWindow) override;
367 OUString const & GetSidebarContextName() const;
369 bool IsInSwitchPage() { return mbIsInSwitchPage; }
371 //move this method to ViewShell.
372 //void NotifyAccUpdate();
373 protected:
374 std::unique_ptr<DrawView> mpDrawView;
375 SdPage* mpActualPage;
376 ::tools::Rectangle maMarkRect;
377 Point maMousePos;
378 bool mbMousePosFreezed;
379 VclPtr<TabControl> maTabControl;
380 EditMode meEditMode;
381 PageKind mePageKind;
382 bool mbZoomOnPage;
383 bool mbIsRulerDrag;
384 sal_uLong mnLockCount;
385 bool mbReadOnly;
386 static bool mbPipette;
388 DECL_LINK( ClipboardChanged, TransferableDataHelper*, void );
389 DECL_LINK( TabSplitHdl, TabBar *, void );
390 DECL_LINK( NameObjectHdl, AbstractSvxObjectNameDialog&, bool );
391 DECL_LINK( RenameSlideHdl, AbstractSvxNameDialog&, bool );
393 void DeleteActualPage();
394 void DeleteActualLayer();
396 virtual VclPtr<SvxRuler> CreateHRuler(::sd::Window* pWin) override;
397 virtual VclPtr<SvxRuler> CreateVRuler(::sd::Window* pWin) override;
398 virtual void UpdateHRuler() override;
399 virtual void UpdateVRuler() override;
400 virtual void SetZoomFactor(const Fraction& rZoomX, const Fraction& rZoomY) override;
402 void SetupPage( Size const &rSize, long nLeft, long nRight, long nUpper, long nLower,
403 bool bSize, bool bMargin, bool bScaleAll );
405 void GetMenuStateSel(SfxItemSet& rSet);
407 private:
408 /** This flag controls whether the layer mode is active, i.e. the layer
409 dialog is visible.
411 bool mbIsLayerModeActive;
413 /** This item contains the clipboard formats of the current clipboard
414 content that are supported both by that content and by the
415 DrawViewShell.
417 ::std::unique_ptr<SvxClipboardFormatItem> mpCurrentClipboardFormats;
419 /** On some occasions it is necessary to make SwitchPage calls
420 asynchronously.
422 tools::AsynchronousCall maAsynchronousSwitchPageCall;
424 /** This flag is used to prevent nested calls to SwitchPage().
426 bool mbIsInSwitchPage;
428 RotateTransliteration m_aRotateCase;
430 /** Listen for selection changes and broadcast context changes for the sidebar.
432 ::rtl::Reference<svx::sidebar::SelectionChangeHandler> mpSelectionChangeHandler;
434 void Construct (DrawDocShell* pDocSh, PageKind ePageKind);
436 /** Depending on the given request create a new page or duplicate an
437 existing one. See ViewShell::CreateOrDuplicatePage() for more
438 information.
440 virtual SdPage* CreateOrDuplicatePage (
441 SfxRequest& rRequest,
442 PageKind ePageKind,
443 SdPage* pPage,
444 const sal_Int32 nInsertPosition = -1) override;
446 css::uno::Reference< css::scanner::XScannerManager2 > mxScannerManager;
447 css::uno::Reference< css::lang::XEventListener > mxScannerListener;
448 rtl::Reference<TransferableClipboardListener> mxClipEvtLstnr;
449 bool mbPastePossible;
450 bool mbMouseButtonDown;
451 bool mbMouseSelecting;
453 virtual void Notify (SfxBroadcaster& rBC, const SfxHint& rHint) override;
455 /** Stop a running slide show.
457 void StopSlideShow();
459 /** Show the context menu for snap lines and points. Because snap lines
460 can not be selected the index of the snap line/point for which the
461 popup menu is opened has to be passed to the processing slot
462 handlers. This can be done only by manually showing the popup menu.
463 @param rPageView
464 The page view is used to access the help lines.
465 @param nSnapLineIndex
466 Index of the snap line or snap point for which to show the
467 context menu.
468 @param rMouseLocation
469 The mouse location defines the location at which to display the
470 context menu.
472 void ShowSnapLineContextMenu (
473 SdrPageView& rPageView,
474 const sal_uInt16 nSnapLineIndex,
475 const Point& rMouseLocation);
477 using ViewShell::Notify;
479 ::std::unique_ptr< AnnotationManager > mpAnnotationManager;
480 ::std::unique_ptr< ViewOverlayManager > mpViewOverlayManager;
482 std::vector<std::unique_ptr<SdrExternalToolEdit>> m_ExternalEdits;
484 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster* pCb, ConfigurationHints ) override;
486 void ConfigureAppBackgroundColor( svtools::ColorConfig* pColorConfig = nullptr );
488 // The colour of the area behind the slide (used to be called "Wiese")
489 Color mnAppBackgroundColor;
492 /// Merge the background properties together and deposit the result in rMergeAttr
493 void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool bMasterPage, SfxItemSet& rMergedAttr);
495 } // end of namespace sd
497 #endif
499 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */