1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SD_DRAW_VIEW_SHELL_HXX
29 #define SD_DRAW_VIEW_SHELL_HXX
31 #include "ViewShell.hxx"
32 #include "tools/AsynchronousCall.hxx"
33 #include <sfx2/viewfac.hxx>
34 #include <sfx2/viewsh.hxx>
35 #include "TabControl.hxx"
37 #include <com/sun/star/lang/XEventListener.hpp>
38 #include <com/sun/star/scanner/XScannerManager.hpp>
47 class TransferableDataHelper
;
48 class TransferableClipboardListener
;
49 class AbstractSvxNameDialog
;
51 class SvxClipboardFmtItem
;
59 class AnnotationManager
;
60 class ViewOverlayManager
;
62 #define CHECK_RANGE(nMin, nValue, nMax) ((nValue >= nMin) && (nValue <= nMax))
64 /** Base class of the stacked shells that provide graphical views to
65 Draw and Impress documents and editing functionality. In contrast
66 to this other stacked shells are responsible for showing an
67 overview over several slides (SlideViewShell) or a textual
68 overview over the text in an Impress document (OutlineViewShell).
75 static const int SLOTARRAY_COUNT
= 24;
79 SFX_DECL_INTERFACE(SD_IF_SDDRAWVIEWSHELL
)
81 /** Create a new stackable shell that may take some information
82 (e.g. the frame view) from the given previous shell.
84 This parameter gives the initial page kind that the new shell
87 The frame view that makes it possible to pass information from
88 one view shell to the next.
92 ViewShellBase
& rViewShellBase
,
93 ::Window
* pParentWindow
,
94 PageKind ePageKind
= PK_STANDARD
,
95 FrameView
* pFrameView
= NULL
);
97 virtual ~DrawViewShell (void);
99 virtual void Init (bool bIsMainViewShell
);
101 virtual void Shutdown (void);
104 virtual void Paint(const Rectangle
& rRect
, ::sd::Window
* pWin
);
106 /** Set the position and size of the area which contains the GUI
107 elements like rulers, sliders, and buttons as well as the document
108 view. Both size and position are expected to be in pixel
109 coordinates. The positions and sizes of the mentioned GUI elements
112 <p> This method is implemented by first setting copying the given
113 values to internal variables and then calling the
114 <type>ArrangeGUIElements</type> method which performs the actual
115 work of sizeing and arranging the UI elements accordingly.</p>
117 The position of the enclosing window relative to the document
118 window. This is only interesting if a Draw/Impress document
119 view is embedded as OLE object into another document view. For
120 normal documents this position is (0,0).
122 The new size in pixel.
124 // virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
126 /** Arrange and resize the GUI elements like rulers, sliders, and
127 buttons as well as the actual document view according to the size of
128 the enclosing window and current sizes of buttons, rulers, and
131 virtual void ArrangeGUIElements (void);
135 virtual sal_Bool
KeyInput(const KeyEvent
& rKEvt
, ::sd::Window
* pWin
);
136 virtual void MouseMove(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
137 virtual void MouseButtonUp(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
138 virtual void MouseButtonDown(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
139 virtual void Command(const CommandEvent
& rCEvt
, ::sd::Window
* pWin
);
141 virtual void Resize (void);
143 void ShowMousePosInfo(const Rectangle
& rRect
, ::sd::Window
* pWin
);
145 virtual void AddWindow(::sd::Window
* pWin
);
146 virtual void RemoveWindow(::sd::Window
* pWin
);
148 virtual void ChangeEditMode (EditMode eMode
, bool bIsLayerModeActive
);
150 virtual void SetZoom( long nZoom
);
151 virtual void SetZoomRect( const Rectangle
& rZoomRect
);
153 void InsertURLField(const String
& rURL
, const String
& rText
, const String
& rTarget
,
155 void InsertURLButton(const String
& rURL
, const String
& rText
, const String
& rTarget
,
158 virtual void SetUIUnit(FieldUnit eUnit
);
160 void SelectionHasChanged();
161 void ModelHasChanged();
162 virtual void Activate(sal_Bool bIsMDIActivate
);
163 virtual void Deactivate(sal_Bool IsMDIActivate
);
164 virtual void UIActivating( SfxInPlaceClient
* );
165 virtual void UIDeactivated( SfxInPlaceClient
* );
166 virtual String
GetSelectionText( sal_Bool bCompleteWords
= sal_False
);
167 virtual sal_Bool
HasSelection( sal_Bool bText
= sal_True
) const;
169 void ExecCtrl(SfxRequest
& rReq
);
170 void GetCtrlState(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 ExecEffectWin(SfxRequest
& rReq
);
205 void Update3DWindow();
206 void AssignFrom3DWindow();
208 void ExecGallery(SfxRequest
& rReq
);
209 void GetGalleryState(SfxItemSet
& rSet
);
211 void ExecBmpMask( SfxRequest
& rReq
);
212 void GetBmpMaskState( SfxItemSet
& rSet
);
214 void ExecIMap( SfxRequest
& rReq
);
215 void GetIMapState( SfxItemSet
& rSet
);
217 void FuTemporary(SfxRequest
& rReq
);
218 void FuPermanent(SfxRequest
& rReq
);
219 void FuSupport(SfxRequest
& rReq
);
220 void FuTable(SfxRequest
& rReq
);
222 void AttrExec (SfxRequest
& rReq
);
223 void AttrState (SfxItemSet
& rSet
);
225 void ExecuteAnnotation (SfxRequest
& rRequest
);
226 void GetAnnotationState (SfxItemSet
& rItemSet
);
228 void StartRulerDrag (
230 const MouseEvent
& rMEvt
);
232 virtual sal_uInt16
PrepareClose( sal_Bool bUI
= sal_True
, sal_Bool bForBrowsing
= sal_False
);
234 PageKind
GetPageKind() { return mePageKind
; }
236 Point
GetMousePos() { return maMousePos
; }
237 sal_Bool
IsMousePosFreezed() { return mbMousePosFreezed
; }
238 void SetMousePosFreezed( sal_Bool bIn
) { mbMousePosFreezed
= bIn
; }
240 EditMode
GetEditMode() const { return meEditMode
; }
241 virtual SdPage
* GetActualPage() { return mpActualPage
; }
243 /// inherited from sd::ViewShell
244 virtual SdPage
* getCurrentPage() const;
246 void ResetActualPage();
247 void ResetActualLayer();
248 sal_Bool
SwitchPage(sal_uInt16 nPage
);
249 sal_Bool
IsSwitchPageAllowed() const;
251 sal_Bool
GotoBookmark(const String
& rBookmark
);
252 void MakeVisible(const Rectangle
& rRect
, ::Window
& rWin
);
254 virtual void ReadFrameViewData(FrameView
* pView
);
255 virtual void WriteFrameViewData();
257 virtual ErrCode
DoVerb(long nVerb
);
258 virtual sal_Bool
ActivateObject(SdrOle2Obj
* pObj
, long nVerb
);
260 void SetZoomOnPage( sal_Bool bZoom
= sal_True
) { mbZoomOnPage
= bZoom
; }
261 sal_Bool
IsZoomOnPage() { return mbZoomOnPage
; }
262 void CheckLineTo (SfxRequest
& rReq
);
263 void FuTemp01(SfxRequest
& rReq
);
264 void FuTemp02(SfxRequest
& rReq
);
265 void FuTemp03(SfxRequest
& rReq
);
266 void FuTemp04(SfxRequest
& rReq
);
267 void SetChildWindowState( SfxItemSet
& rSet
);
269 void UpdateIMapDlg( SdrObject
* pObj
);
273 sal_Bool
IsInputLocked() const { return mnLockCount
> 0UL; }
275 sal_uInt16
GetCurPageId() { return( maTabControl
.GetCurPageId() ); }
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
281 virtual void ShowUIControls (bool bVisible
= true);
283 void ScannerEvent( const ::com::sun::star::lang::EventObject
& rEventObject
);
285 bool IsLayerModeActive (void) const;
287 sal_uInt16
* GetSlotArray() const { return mpSlotArray
; }
289 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
290 ::sd::Window
* pTargetWindow
, sal_uInt16 nPage
, sal_uInt16 nLayer
);
291 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
292 ::sd::Window
* pTargetWindow
, sal_uInt16 nPage
, sal_uInt16 nLayer
);
294 virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
295 virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
297 virtual void VisAreaChanged(const Rectangle
& rRect
);
299 /** Create an accessible object representing the specified window.
301 The returned object makes the document displayed in this window
304 Returns an <type>AccessibleDrawDocumentView</type> object.
306 virtual ::com::sun::star::uno::Reference
<
307 ::com::sun::star::accessibility::XAccessible
>
308 CreateAccessibleDocumentView (::sd::Window
* pWindow
);
310 /** Return the number of layers managed by the layer tab control. This
311 will usually differ from the number of layers managed by the layer
314 The number of layers managed by the layer tab control. The
315 returned value is independent of whether the layer modus is
316 currently active and the tab control is visible.
318 virtual int GetTabLayerCount (void) const;
320 /** Return the numerical id of the currently active layer as seen by the
323 The returned id is a number between zero (inclusive) and the
324 number of layers as returned by the
325 <member>GetTabLayerCount</member> method (exclusive).
327 virtual int GetActiveTabLayerIndex (void) const;
329 /** Set the active layer at the layer tab control and update the control
330 accordingly to reflect the change on screen.
332 The id is expected to be a number between zero (inclusive) and
333 the number of layers as returned by the
334 <member>GetTabLayerCount</member> method (exclusive). Note that
335 Invalid values are ignored. No excpetion is thrown in that case.
337 virtual void SetActiveTabLayerIndex (int nId
);
339 /** Return a pointer to the tab control for pages.
341 TabControl
* GetPageTabControl (void);
343 /** Return a pointer to the tab control for layers.
345 LayerTabBar
* GetLayerTabControl (void);
347 /** Renames the given slide using an SvxNameDialog
349 @param nPageId the index of the page in the SdTabControl.
350 @param rName the new name of the slide.
352 @return false, if the new name is invalid for some reason.
354 <p>Implemented in <code>drviews8.cxx</code>.</p>
356 bool RenameSlide( sal_uInt16 nPageId
, const String
& rName
);
358 /** modifies the given layer with the given values */
359 void ModifyLayer( SdrLayer
* pLayer
, const String
& rLayerName
, const String
& rLayerTitle
, const String
& rLayerDesc
, bool bIsVisible
, bool bIsLocked
, bool bIsPrintable
);
361 virtual css::uno::Reference
<css::drawing::XDrawSubController
> CreateSubController (void);
363 DrawView
* GetDrawView() const { return mpDrawView
; }
365 /** Relocation to a new parent window is not supported for DrawViewShell
366 objects so this method always returns <FALSE/>.
368 virtual bool RelocateToParentWindow (::Window
* pParentWindow
);
371 DrawView
* mpDrawView
;
372 SdPage
* mpActualPage
;
373 Rectangle maMarkRect
;
375 sal_Bool mbMousePosFreezed
;
376 TabControl maTabControl
;
379 sal_Bool mbZoomOnPage
;
380 sal_Bool mbIsRulerDrag
;
381 sal_uLong mnLockCount
;
384 sal_uInt16
* mpSlotArray
;
386 static sal_Bool mbPipette
;
388 DECL_LINK( ClipboardChanged
, TransferableDataHelper
* );
389 DECL_LINK( CloseHdl
, Timer
* pTimer
);
390 DECL_LINK( TabSplitHdl
, TabBar
* );
391 DECL_LINK( NameObjectHdl
, AbstractSvxNameDialog
* );
392 DECL_LINK( RenameSlideHdl
, AbstractSvxNameDialog
* );
394 void DeleteActualPage();
395 void DeleteActualLayer();
397 virtual SvxRuler
* CreateHRuler(::sd::Window
* pWin
, sal_Bool bIsFirst
);
398 virtual SvxRuler
* CreateVRuler(::sd::Window
* pWin
);
399 virtual void UpdateHRuler();
400 virtual void UpdateVRuler();
401 virtual long GetHCtrlWidth();
402 virtual void SetZoomFactor(const Fraction
& rZoomX
, const Fraction
& rZoomY
);
403 virtual Size
GetOptimalSizePixel() const;
405 void SetupPage( Size
&rSize
, long nLeft
, long nRight
, long nUpper
, long nLower
,
406 sal_Bool bSize
, sal_Bool bMargin
, sal_Bool bScaleAll
);
408 sal_uInt16
GetIdBySubId( sal_uInt16 nSId
);
409 void MapSlot( sal_uInt16 nSId
);
410 void UpdateToolboxImages( SfxItemSet
&rSet
, sal_Bool bPermanent
= sal_True
);
411 sal_uInt16
GetMappedSlot( sal_uInt16 nSId
);
412 sal_uInt16
GetArrayId( sal_uInt16 nSId
);
414 void GetMenuStateSel(SfxItemSet
& rSet
);
417 /** This flag controls whether the layer mode is active, i.e. the layer
420 bool mbIsLayerModeActive
;
422 /** This item contains the clipboard formats of the current clipboard
423 content that are supported both by that content and by the
426 ::std::auto_ptr
<SvxClipboardFmtItem
> mpCurrentClipboardFormats
;
428 /** On some occasions it is necessary to make SwitchPage calls
431 tools::AsynchronousCall maAsynchronousSwitchPageCall
;
433 /** This flag is used to prevent nested calls to SwitchPage().
435 bool mbIsInSwitchPage
;
437 void Construct (DrawDocShell
* pDocSh
, PageKind ePageKind
);
439 /** Depending on the given request create a new page or duplicate an
440 existing one. See ViewShell::CreateOrDuplicatePage() for more
443 virtual SdPage
* CreateOrDuplicatePage (
444 SfxRequest
& rRequest
,
447 const sal_Int32 nInsertPosition
= -1);
449 ::com::sun::star::uno::Reference
< ::com::sun::star::scanner::XScannerManager
> mxScannerManager
;
450 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> mxScannerListener
;
451 TransferableClipboardListener
* mpClipEvtLstnr
;
452 sal_Bool mbPastePossible
;
454 virtual void Notify (SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
456 /** Stop a running slide show. The frame the show is running in is
458 a) it is running in its own frame, i.e. is a full screen show and
459 b) the given flag bCloseFrame is true.
461 Be carefull with this flag when stopping a full screen show.
462 When called from the destructor the flag has to be <FALSE/> or
463 otherwise we run into a loop of calls to destructors of the view
465 When called from other places the flag should be <TRUE/> so that
466 not an empty frame remains. When called with <TRUE/> it is the
467 responsibility of the caller to avoid an illegal reentrant
470 void StopSlideShow (bool bCloseFrame
);
472 /** Show the context menu for snap lines and points. Because snap lines
473 can not be selected the index of the snap line/point for which the
474 popup menu is opened has to be passed to the processing slot
475 handlers. This can be done only by manually showing the popup menu.
477 The page view is used to access the help lines.
478 @param nSnapLineIndex
479 Index of the snap line or snap point for which to show the
481 @param rMouseLocation
482 The mouse location defines the location at which to display the
485 void ShowSnapLineContextMenu (
486 SdrPageView
& rPageView
,
487 const sal_uInt16 nSnapLineIndex
,
488 const Point
& rMouseLocation
);
490 using ViewShell::Notify
;
492 ::std::auto_ptr
< AnnotationManager
> mpAnnotationManager
;
493 ::std::auto_ptr
< ViewOverlayManager
> mpViewOverlayManager
;
497 } // end of namespace sd