1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 SD_DRAW_VIEW_SHELL_HXX
21 #define SD_DRAW_VIEW_SHELL_HXX
23 #include "ViewShell.hxx"
24 #include "tools/AsynchronousCall.hxx"
25 #include <sfx2/viewfac.hxx>
26 #include <sfx2/viewsh.hxx>
27 #include "TabControl.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>
39 class TransferableDataHelper
;
40 class TransferableClipboardListener
;
41 class AbstractSvxNameDialog
;
43 class SvxClipboardFmtItem
;
50 class AnnotationManager
;
51 class ViewOverlayManager
;
53 #define CHECK_RANGE(nMin, nValue, nMax) ((nValue >= nMin) && (nValue <= nMax))
55 /** Base class of the stacked shells that provide graphical views to
56 Draw and Impress documents and editing functionality. In contrast
57 to this other stacked shells are responsible for showing an
58 overview over several slides or a textual
59 overview over the text in an Impress document (OutlineViewShell).
66 static const int SLOTARRAY_COUNT
= 24;
70 SFX_DECL_INTERFACE(SD_IF_SDDRAWVIEWSHELL
)
72 /** Create a new stackable shell that may take some information
73 (e.g. the frame view) from the given previous shell.
75 This parameter gives the initial page kind that the new shell
78 The frame view that makes it possible to pass information from
79 one view shell to the next.
83 ViewShellBase
& rViewShellBase
,
84 ::Window
* pParentWindow
,
85 PageKind ePageKind
= PK_STANDARD
,
86 FrameView
* pFrameView
= NULL
);
88 virtual ~DrawViewShell (void);
90 virtual void Init (bool bIsMainViewShell
);
92 virtual void Shutdown (void);
95 virtual void Paint(const Rectangle
& rRect
, ::sd::Window
* pWin
);
97 /** Set the position and size of the area which contains the GUI
98 elements like rulers, sliders, and buttons as well as the document
99 view. Both size and position are expected to be in pixel
100 coordinates. The positions and sizes of the mentioned GUI elements
103 <p> This method is implemented by first setting copying the given
104 values to internal variables and then calling the
105 <type>ArrangeGUIElements</type> method which performs the actual
106 work of sizeing and arranging the UI elements accordingly.</p>
108 The position of the enclosing window relative to the document
109 window. This is only interesting if a Draw/Impress document
110 view is embedded as OLE object into another document view. For
111 normal documents this position is (0,0).
113 The new size in pixel.
115 // virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
117 /** Arrange and resize the GUI elements like rulers, sliders, and
118 buttons as well as the actual document view according to the size of
119 the enclosing window and current sizes of buttons, rulers, and
122 virtual void ArrangeGUIElements (void);
126 virtual sal_Bool
KeyInput(const KeyEvent
& rKEvt
, ::sd::Window
* pWin
);
127 virtual void MouseMove(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
128 virtual void MouseButtonUp(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
129 virtual void MouseButtonDown(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
130 virtual void Command(const CommandEvent
& rCEvt
, ::sd::Window
* pWin
);
132 virtual void Resize (void);
134 void ShowMousePosInfo(const Rectangle
& rRect
, ::sd::Window
* pWin
);
136 virtual void AddWindow(::sd::Window
* pWin
);
137 virtual void RemoveWindow(::sd::Window
* pWin
);
139 virtual void ChangeEditMode (EditMode eMode
, bool bIsLayerModeActive
);
141 virtual void SetZoom( long nZoom
);
142 virtual void SetZoomRect( const Rectangle
& rZoomRect
);
144 void InsertURLField(const String
& rURL
, const String
& rText
, const String
& rTarget
,
146 void InsertURLButton(const String
& rURL
, const String
& rText
, const String
& rTarget
,
149 virtual void SetUIUnit(FieldUnit eUnit
);
151 void SelectionHasChanged();
152 void ModelHasChanged();
153 virtual void Activate(sal_Bool bIsMDIActivate
);
154 virtual void Deactivate(sal_Bool IsMDIActivate
);
155 virtual void UIActivating( SfxInPlaceClient
* );
156 virtual void UIDeactivated( SfxInPlaceClient
* );
157 virtual String
GetSelectionText( sal_Bool bCompleteWords
= sal_False
);
158 virtual sal_Bool
HasSelection( sal_Bool bText
= sal_True
) const;
160 void ExecCtrl(SfxRequest
& rReq
);
161 void GetCtrlState(SfxItemSet
& rSet
);
162 void GetDrawAttrState(SfxItemSet
& rSet
);
163 void GetMenuState(SfxItemSet
& rSet
);
164 void GetTableMenuState(SfxItemSet
& rSet
);
165 /** Set the items of the given item set that are related to
166 switching the editing mode to the correct values.
167 <p>This function also sets the states of the mode buttons
168 (those at the upper right corner) accordingly.</p>
170 void GetModeSwitchingMenuState (SfxItemSet
&rSet
);
171 void GetAttrState(SfxItemSet
& rSet
);
172 void GetSnapItemState(SfxItemSet
& rSet
);
174 void GetState (SfxItemSet
& rSet
);
175 void Execute (SfxRequest
& rReq
);
177 void ExecStatusBar(SfxRequest
& rReq
);
178 void GetStatusBarState(SfxItemSet
& rSet
);
180 void ExecOptionsBar(SfxRequest
& rReq
);
181 void GetOptionsBarState(SfxItemSet
& rSet
);
183 void ExecRuler(SfxRequest
& rReq
);
184 void GetRulerState(SfxItemSet
& rSet
);
186 void ExecFormText(SfxRequest
& rReq
);
187 void GetFormTextState(SfxItemSet
& rSet
);
189 void ExecAnimationWin(SfxRequest
& rReq
);
190 void GetAnimationWinState(SfxItemSet
& rSet
);
192 void ExecNavigatorWin(SfxRequest
& rReq
);
193 void GetNavigatorWinState(SfxItemSet
& rSet
);
195 void ExecutePropPanelAttr (SfxRequest
& rReq
);
196 void GetStatePropPanelAttr(SfxItemSet
& rSet
);
198 void ExecEffectWin(SfxRequest
& rReq
);
200 void Update3DWindow();
201 void AssignFrom3DWindow();
203 void ExecGallery(SfxRequest
& rReq
);
204 void GetGalleryState(SfxItemSet
& rSet
);
206 void ExecBmpMask( SfxRequest
& rReq
);
207 void GetBmpMaskState( SfxItemSet
& rSet
);
209 void ExecIMap( SfxRequest
& rReq
);
210 void GetIMapState( SfxItemSet
& rSet
);
212 void FuTemporary(SfxRequest
& rReq
);
213 void FuPermanent(SfxRequest
& rReq
);
214 void FuSupport(SfxRequest
& rReq
);
215 void FuSupportRotate(SfxRequest
& rReq
);
216 void FuTable(SfxRequest
& rReq
);
218 void AttrExec (SfxRequest
& rReq
);
219 void AttrState (SfxItemSet
& rSet
);
221 void ExecChar(SfxRequest
& rReq
);
223 void ExecuteAnnotation (SfxRequest
& rRequest
);
224 void GetAnnotationState (SfxItemSet
& rItemSet
);
226 void StartRulerDrag (
228 const MouseEvent
& rMEvt
);
230 virtual sal_uInt16
PrepareClose( sal_Bool bUI
= sal_True
, sal_Bool bForBrowsing
= sal_False
);
232 PageKind
GetPageKind() { return mePageKind
; }
234 Point
GetMousePos() { return maMousePos
; }
235 sal_Bool
IsMousePosFreezed() { return mbMousePosFreezed
; }
236 void SetMousePosFreezed( sal_Bool bIn
) { mbMousePosFreezed
= bIn
; }
238 EditMode
GetEditMode() const { return meEditMode
; }
239 virtual SdPage
* GetActualPage() { return mpActualPage
; }
241 /// inherited from sd::ViewShell
242 virtual SdPage
* getCurrentPage() const;
244 void ResetActualPage();
245 void ResetActualLayer();
246 sal_Bool
SwitchPage(sal_uInt16 nPage
);
247 sal_Bool
IsSwitchPageAllowed() const;
249 sal_Bool
GotoBookmark(const String
& rBookmark
);
250 void MakeVisible(const Rectangle
& rRect
, ::Window
& rWin
);
252 virtual void ReadFrameViewData(FrameView
* pView
);
253 virtual void WriteFrameViewData();
255 virtual ErrCode
DoVerb(long nVerb
);
256 virtual sal_Bool
ActivateObject(SdrOle2Obj
* pObj
, long nVerb
);
258 void SetZoomOnPage( sal_Bool bZoom
= sal_True
) { mbZoomOnPage
= bZoom
; }
259 sal_Bool
IsZoomOnPage() { return mbZoomOnPage
; }
260 void CheckLineTo (SfxRequest
& rReq
);
261 void SetChildWindowState( SfxItemSet
& rSet
);
263 void UpdateIMapDlg( SdrObject
* pObj
);
267 sal_Bool
IsInputLocked() const { return mnLockCount
> 0UL; }
269 sal_uInt16
GetCurPageId() { return( maTabControl
.GetCurPageId() ); }
271 /** Show controls of the UI or hide them, depending on the given flag.
272 Do not call this method directly. Call the method at ViewShellBase
275 virtual void ShowUIControls (bool bVisible
= true);
277 void ScannerEvent( const ::com::sun::star::lang::EventObject
& rEventObject
);
279 bool IsLayerModeActive (void) const;
281 sal_uInt16
* GetSlotArray() const { return mpSlotArray
; }
283 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
284 ::sd::Window
* pTargetWindow
, sal_uInt16 nPage
, sal_uInt16 nLayer
);
285 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
286 ::sd::Window
* pTargetWindow
, sal_uInt16 nPage
, sal_uInt16 nLayer
);
288 virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
289 virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
291 virtual void VisAreaChanged(const Rectangle
& rRect
);
293 /** Create an accessible object representing the specified window.
295 The returned object makes the document displayed in this window
298 Returns an <type>AccessibleDrawDocumentView</type> object.
300 virtual ::com::sun::star::uno::Reference
<
301 ::com::sun::star::accessibility::XAccessible
>
302 CreateAccessibleDocumentView (::sd::Window
* pWindow
);
304 /** Return the number of layers managed by the layer tab control. This
305 will usually differ from the number of layers managed by the layer
308 The number of layers managed by the layer tab control. The
309 returned value is independent of whether the layer modus is
310 currently active and the tab control is visible.
312 virtual int GetTabLayerCount (void) const;
314 /** Return the numerical id of the currently active layer as seen by the
317 The returned id is a number between zero (inclusive) and the
318 number of layers as returned by the
319 <member>GetTabLayerCount</member> method (exclusive).
321 virtual int GetActiveTabLayerIndex (void) const;
323 /** Set the active layer at the layer tab control and update the control
324 accordingly to reflect the change on screen.
326 The id is expected to be a number between zero (inclusive) and
327 the number of layers as returned by the
328 <member>GetTabLayerCount</member> method (exclusive). Note that
329 Invalid values are ignored. No excpetion is thrown in that case.
331 virtual void SetActiveTabLayerIndex (int nId
);
333 /** Return a pointer to the tab control for pages.
335 TabControl
* GetPageTabControl (void);
337 /** Return a pointer to the tab control for layers.
339 LayerTabBar
* GetLayerTabControl (void);
341 /** Renames the given slide using an SvxNameDialog
343 @param nPageId the index of the page in the SdTabControl.
344 @param rName the new name of the slide.
346 @return false, if the new name is invalid for some reason.
348 <p>Implemented in <code>drviews8.cxx</code>.</p>
350 bool RenameSlide( sal_uInt16 nPageId
, const String
& rName
);
352 /** modifies the given layer with the given values */
353 void ModifyLayer( SdrLayer
* pLayer
, const String
& rLayerName
, const String
& rLayerTitle
, const String
& rLayerDesc
, bool bIsVisible
, bool bIsLocked
, bool bIsPrintable
);
355 virtual css::uno::Reference
<css::drawing::XDrawSubController
> CreateSubController (void);
357 DrawView
* GetDrawView() const { return mpDrawView
; }
359 /** Relocation to a new parent window is not supported for DrawViewShell
360 objects so this method always returns <FALSE/>.
362 virtual bool RelocateToParentWindow (::Window
* pParentWindow
);
364 ::rtl::OUString
GetSidebarContextName (void) const;
367 DrawView
* mpDrawView
;
368 SdPage
* mpActualPage
;
369 Rectangle maMarkRect
;
371 sal_Bool mbMousePosFreezed
;
372 TabControl maTabControl
;
375 sal_Bool mbZoomOnPage
;
376 sal_Bool mbIsRulerDrag
;
377 sal_uLong mnLockCount
;
380 sal_uInt16
* mpSlotArray
;
382 static sal_Bool mbPipette
;
384 DECL_LINK( ClipboardChanged
, TransferableDataHelper
* );
385 DECL_LINK( CloseHdl
, Timer
* pTimer
);
386 DECL_LINK( TabSplitHdl
, TabBar
* );
387 DECL_LINK( NameObjectHdl
, AbstractSvxNameDialog
* );
388 DECL_LINK( RenameSlideHdl
, AbstractSvxNameDialog
* );
390 void DeleteActualPage();
391 void DeleteActualLayer();
393 virtual SvxRuler
* CreateHRuler(::sd::Window
* pWin
, sal_Bool bIsFirst
);
394 virtual SvxRuler
* CreateVRuler(::sd::Window
* pWin
);
395 virtual void UpdateHRuler();
396 virtual void UpdateVRuler();
397 virtual void SetZoomFactor(const Fraction
& rZoomX
, const Fraction
& rZoomY
);
399 void SetupPage( Size
&rSize
, long nLeft
, long nRight
, long nUpper
, long nLower
,
400 sal_Bool bSize
, sal_Bool bMargin
, sal_Bool bScaleAll
);
402 sal_uInt16
GetIdBySubId( sal_uInt16 nSId
);
403 void MapSlot( sal_uInt16 nSId
);
404 void UpdateToolboxImages( SfxItemSet
&rSet
, sal_Bool bPermanent
= sal_True
);
405 sal_uInt16
GetMappedSlot( sal_uInt16 nSId
);
406 sal_uInt16
GetArrayId( sal_uInt16 nSId
);
408 void GetMenuStateSel(SfxItemSet
& rSet
);
411 void ShowSlideShow(SfxRequest
& rReq
);
412 /** This flag controls whether the layer mode is active, i.e. the layer
415 bool mbIsLayerModeActive
;
417 /** This item contains the clipboard formats of the current clipboard
418 content that are supported both by that content and by the
421 ::std::auto_ptr
<SvxClipboardFmtItem
> mpCurrentClipboardFormats
;
423 /** On some occasions it is necessary to make SwitchPage calls
426 tools::AsynchronousCall maAsynchronousSwitchPageCall
;
428 /** This flag is used to prevent nested calls to SwitchPage().
430 bool mbIsInSwitchPage
;
432 RotateTransliteration m_aRotateCase
;
434 /** Listen for selection changes and broadcast context changes for the sidebar.
436 ::rtl::Reference
<svx::sidebar::SelectionChangeHandler
> mpSelectionChangeHandler
;
438 void Construct (DrawDocShell
* pDocSh
, PageKind ePageKind
);
440 /** Depending on the given request create a new page or duplicate an
441 existing one. See ViewShell::CreateOrDuplicatePage() for more
444 virtual SdPage
* CreateOrDuplicatePage (
445 SfxRequest
& rRequest
,
448 const sal_Int32 nInsertPosition
= -1);
450 ::com::sun::star::uno::Reference
< ::com::sun::star::scanner::XScannerManager2
> mxScannerManager
;
451 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> mxScannerListener
;
452 TransferableClipboardListener
* mpClipEvtLstnr
;
453 sal_Bool mbPastePossible
;
455 virtual void Notify (SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
457 /** Stop a running slide show. The frame the show is running in is
459 a) it is running in its own frame, i.e. is a full screen show and
460 b) the given flag bCloseFrame is true.
462 Be carefull with this flag when stopping a full screen show.
463 When called from the destructor the flag has to be <FALSE/> or
464 otherwise we run into a loop of calls to destructors of the view
466 When called from other places the flag should be <TRUE/> so that
467 not an empty frame remains. When called with <TRUE/> it is the
468 responsibility of the caller to avoid an illegal reentrant
471 void StopSlideShow (bool bCloseFrame
);
473 /** Show the context menu for snap lines and points. Because snap lines
474 can not be selected the index of the snap line/point for which the
475 popup menu is opened has to be passed to the processing slot
476 handlers. This can be done only by manually showing the popup menu.
478 The page view is used to access the help lines.
479 @param nSnapLineIndex
480 Index of the snap line or snap point for which to show the
482 @param rMouseLocation
483 The mouse location defines the location at which to display the
486 void ShowSnapLineContextMenu (
487 SdrPageView
& rPageView
,
488 const sal_uInt16 nSnapLineIndex
,
489 const Point
& rMouseLocation
);
491 using ViewShell::Notify
;
493 ::std::auto_ptr
< AnnotationManager
> mpAnnotationManager
;
494 ::std::auto_ptr
< ViewOverlayManager
> mpViewOverlayManager
;
498 } // end of namespace sd
502 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */