1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DrawViewShell.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_DRAW_VIEW_SHELL_HXX
32 #define SD_DRAW_VIEW_SHELL_HXX
34 #include "ViewShell.hxx"
35 #include "tools/AsynchronousCall.hxx"
36 #include <sfx2/viewfac.hxx>
37 #include <sfx2/viewsh.hxx>
38 #include "TabControl.hxx"
40 #include <com/sun/star/lang/XEventListener.hpp>
41 #include <com/sun/star/scanner/XScannerManager.hpp>
50 class TransferableDataHelper
;
51 class TransferableClipboardListener
;
52 class AbstractSvxNameDialog
;
54 class SvxClipboardFmtItem
;
63 #define CHECK_RANGE(nMin, nValue, nMax) ((nValue >= nMin) && (nValue <= nMax))
65 /** Base class of the stacked shells that provide graphical views to
66 Draw and Impress documents and editing functionality. In contrast
67 to this other stacked shells are responsible for showing an
68 overview over several slides (SlideViewShell) or a textual
69 overview over the text in an Impress document (OutlineViewShell).
76 static const int SLOTARRAY_COUNT
= 24;
80 SFX_DECL_INTERFACE(SD_IF_SDDRAWVIEWSHELL
)
82 /** Create a new stackable shell that may take some information
83 (e.g. the frame view) from the given previous shell.
85 This parameter gives the initial page kind that the new shell
88 The frame view that makes it possible to pass information from
89 one view shell to the next.
93 ViewShellBase
& rViewShellBase
,
94 ::Window
* pParentWindow
,
95 PageKind ePageKind
= PK_STANDARD
,
96 FrameView
* pFrameView
= NULL
);
100 ::Window
* pParentWindow
,
101 const DrawViewShell
& rShell
);
103 virtual ~DrawViewShell (void);
105 virtual void Init (bool bIsMainViewShell
);
107 virtual void Shutdown (void);
110 virtual void Paint(const Rectangle
& rRect
, ::sd::Window
* pWin
);
112 /** Set the position and size of the area which contains the GUI
113 elements like rulers, sliders, and buttons as well as the document
114 view. Both size and position are expected to be in pixel
115 coordinates. The positions and sizes of the mentioned GUI elements
118 <p> This method is implemented by first setting copying the given
119 values to internal variables and then calling the
120 <type>ArrangeGUIElements</type> method which performs the actual
121 work of sizeing and arranging the UI elements accordingly.</p>
123 The position of the enclosing window relative to the document
124 window. This is only interesting if a Draw/Impress document
125 view is embedded as OLE object into another document view. For
126 normal documents this position is (0,0).
128 The new size in pixel.
130 // virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
132 /** Arrange and resize the GUI elements like rulers, sliders, and
133 buttons as well as the actual document view according to the size of
134 the enclosing window and current sizes of buttons, rulers, and
137 virtual void ArrangeGUIElements (void);
141 virtual BOOL
KeyInput(const KeyEvent
& rKEvt
, ::sd::Window
* pWin
);
142 virtual void MouseMove(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
143 virtual void MouseButtonUp(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
144 virtual void MouseButtonDown(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
);
145 virtual void Command(const CommandEvent
& rCEvt
, ::sd::Window
* pWin
);
147 virtual void Resize (void);
149 void ShowMousePosInfo(const Rectangle
& rRect
, ::sd::Window
* pWin
);
151 virtual void AddWindow(::sd::Window
* pWin
);
152 virtual void RemoveWindow(::sd::Window
* pWin
);
154 virtual void ChangeEditMode (EditMode eMode
, bool bIsLayerModeActive
);
156 virtual void SetZoom( long nZoom
);
157 virtual void SetZoomRect( const Rectangle
& rZoomRect
);
159 void InsertURLField(const String
& rURL
, const String
& rText
, const String
& rTarget
,
161 void InsertURLButton(const String
& rURL
, const String
& rText
, const String
& rTarget
,
164 virtual void SetUIUnit(FieldUnit eUnit
);
166 void SelectionHasChanged();
167 void ModelHasChanged();
168 virtual void Activate(BOOL bIsMDIActivate
);
169 virtual void Deactivate(BOOL IsMDIActivate
);
170 virtual void UIActivating( SfxInPlaceClient
* );
171 virtual void UIDeactivated( SfxInPlaceClient
* );
172 virtual String
GetSelectionText( BOOL bCompleteWords
= FALSE
);
173 virtual BOOL
HasSelection( BOOL bText
= TRUE
) const;
175 void ExecCtrl(SfxRequest
& rReq
);
176 void GetCtrlState(SfxItemSet
& rSet
);
177 void GetMenuState(SfxItemSet
& rSet
);
178 void GetTableMenuState(SfxItemSet
& rSet
);
179 /** Set the items of the given item set that are related to
180 switching the editing mode to the correct values.
181 <p>This function also sets the states of the mode buttons
182 (those at the upper right corner) accordingly.</p>
184 void GetModeSwitchingMenuState (SfxItemSet
&rSet
);
185 void GetAttrState(SfxItemSet
& rSet
);
186 void GetSnapItemState(SfxItemSet
& rSet
);
188 void GetState (SfxItemSet
& rSet
);
189 void Execute (SfxRequest
& rReq
);
191 void ExecStatusBar(SfxRequest
& rReq
);
192 void GetStatusBarState(SfxItemSet
& rSet
);
194 void ExecOptionsBar(SfxRequest
& rReq
);
195 void GetOptionsBarState(SfxItemSet
& rSet
);
197 void ExecRuler(SfxRequest
& rReq
);
198 void GetRulerState(SfxItemSet
& rSet
);
200 void ExecFormText(SfxRequest
& rReq
);
201 void GetFormTextState(SfxItemSet
& rSet
);
203 void ExecObjPalette(SfxRequest
& rReq
);
204 void GetObjPaletteState(SfxItemSet
& rSet
);
206 void ExecAnimationWin(SfxRequest
& rReq
);
207 void GetAnimationWinState(SfxItemSet
& rSet
);
209 void ExecNavigatorWin(SfxRequest
& rReq
);
210 void GetNavigatorWinState(SfxItemSet
& rSet
);
212 void ExecEffectWin(SfxRequest
& rReq
);
214 void Update3DWindow();
215 void AssignFrom3DWindow();
217 void ExecGallery(SfxRequest
& rReq
);
218 void GetGalleryState(SfxItemSet
& rSet
);
220 void ExecBmpMask( SfxRequest
& rReq
);
221 void GetBmpMaskState( SfxItemSet
& rSet
);
223 void ExecIMap( SfxRequest
& rReq
);
224 void GetIMapState( SfxItemSet
& rSet
);
226 void FuTemporary(SfxRequest
& rReq
);
227 void FuPermanent(SfxRequest
& rReq
);
228 void FuSupport(SfxRequest
& rReq
);
229 void FuTable(SfxRequest
& rReq
);
231 void AttrExec (SfxRequest
& rReq
);
232 void AttrState (SfxItemSet
& rSet
);
234 void StartRulerDrag (
236 const MouseEvent
& rMEvt
);
238 virtual USHORT
PrepareClose( BOOL bUI
= TRUE
, BOOL bForBrowsing
= FALSE
);
240 PageKind
GetPageKind() { return mePageKind
; }
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() { return mpActualPage
; }
249 /// inherited from sd::ViewShell
250 virtual SdPage
* getCurrentPage() const;
252 void ResetActualPage();
253 void ResetActualLayer();
254 BOOL
SwitchPage(USHORT nPage
);
255 BOOL
IsSwitchPageAllowed() const;
257 BOOL
GotoBookmark(const String
& rBookmark
);
258 void MakeVisible(const Rectangle
& rRect
, ::Window
& rWin
);
260 virtual void ReadFrameViewData(FrameView
* pView
);
261 virtual void WriteFrameViewData();
263 virtual ErrCode
DoVerb(long nVerb
);
264 virtual BOOL
ActivateObject(SdrOle2Obj
* pObj
, long nVerb
);
266 void SetZoomOnPage( BOOL bZoom
= TRUE
) { mbZoomOnPage
= bZoom
; }
267 BOOL
IsZoomOnPage() { return mbZoomOnPage
; }
268 void CheckLineTo (SfxRequest
& rReq
);
269 void FuTemp01(SfxRequest
& rReq
);
270 void FuTemp02(SfxRequest
& rReq
);
271 void FuTemp03(SfxRequest
& rReq
);
272 void FuTemp04(SfxRequest
& rReq
);
273 void SetChildWindowState( SfxItemSet
& rSet
);
275 void UpdateIMapDlg( SdrObject
* pObj
);
279 BOOL
IsInputLocked() const { return mnLockCount
> 0UL; }
281 USHORT
GetCurPageId() { return( maTabControl
.GetCurPageId() ); }
283 /** Show controls of the UI or hide them, depending on the given flag.
284 Do not call this method directly. Call the method at ViewShellBase
287 virtual void ShowUIControls (bool bVisible
= true);
289 void ScannerEvent( const ::com::sun::star::lang::EventObject
& rEventObject
);
291 bool IsLayerModeActive (void) const;
293 USHORT
* GetSlotArray() const { return mpSlotArray
; }
295 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
296 ::sd::Window
* pTargetWindow
, USHORT nPage
, USHORT nLayer
);
297 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
, DropTargetHelper
& rTargetHelper
,
298 ::sd::Window
* pTargetWindow
, USHORT nPage
, USHORT nLayer
);
300 virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
301 virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>&, sal_Bool bBrowse
= sal_False
);
303 virtual void VisAreaChanged(const Rectangle
& rRect
);
305 /** Create an accessible object representing the specified window.
307 The returned object makes the document displayed in this window
310 Returns an <type>AccessibleDrawDocumentView</type> object.
312 virtual ::com::sun::star::uno::Reference
<
313 ::com::sun::star::accessibility::XAccessible
>
314 CreateAccessibleDocumentView (::sd::Window
* pWindow
);
316 /** Return the number of layers managed by the layer tab control. This
317 will usually differ from the number of layers managed by the layer
320 The number of layers managed by the layer tab control. The
321 returned value is independent of whether the layer modus is
322 currently active and the tab control is visible.
324 virtual int GetTabLayerCount (void) const;
326 /** Return the numerical id of the currently active layer as seen by the
329 The returned id is a number between zero (inclusive) and the
330 number of layers as returned by the
331 <member>GetTabLayerCount</member> method (exclusive).
333 virtual int GetActiveTabLayerIndex (void) const;
335 /** Set the active layer at the layer tab control and update the control
336 accordingly to reflect the change on screen.
338 The id is expected to be a number between zero (inclusive) and
339 the number of layers as returned by the
340 <member>GetTabLayerCount</member> method (exclusive). Note that
341 Invalid values are ignored. No excpetion is thrown in that case.
343 virtual void SetActiveTabLayerIndex (int nId
);
345 /** Return a pointer to the tab control for pages.
347 TabControl
* GetPageTabControl (void);
349 /** Return a pointer to the tab control for layers.
351 LayerTabBar
* GetLayerTabControl (void);
353 /** Renames the given slide using an SvxNameDialog
355 @param nPageId the index of the page in the SdTabControl.
356 @param rName the new name of the slide.
358 @return false, if the new name is invalid for some reason.
360 <p>Implemented in <code>drviews8.cxx</code>.</p>
362 bool RenameSlide( USHORT nPageId
, const String
& rName
);
364 /** modifies the given layer with the given values */
365 void ModifyLayer( SdrLayer
* pLayer
, const String
& rLayerName
, const String
& rLayerTitle
, const String
& rLayerDesc
, bool bIsVisible
, bool bIsLocked
, bool bIsPrintable
);
367 virtual css::uno::Reference
<css::drawing::XDrawSubController
> CreateSubController (void);
369 DrawView
* GetDrawView() const { return mpDrawView
; }
371 /** Relocation to a new parent window is not supported for DrawViewShell
372 objects so this method always returns <FALSE/>.
374 virtual bool RelocateToParentWindow (::Window
* pParentWindow
);
377 DrawView
* mpDrawView
;
378 SdPage
* mpActualPage
;
379 Rectangle maMarkRect
;
381 BOOL mbMousePosFreezed
;
382 TabControl maTabControl
;
392 static BOOL mbPipette
;
395 DECL_LINK( ClipboardChanged
, TransferableDataHelper
* );
396 DECL_LINK( CloseHdl
, Timer
* pTimer
);
397 DECL_LINK( TabSplitHdl
, TabBar
* );
398 DECL_LINK( NameObjectHdl
, AbstractSvxNameDialog
* );
399 DECL_LINK( RenameSlideHdl
, AbstractSvxNameDialog
* );
401 void DeleteActualPage();
402 void DeleteActualLayer();
404 virtual SvxRuler
* CreateHRuler(::sd::Window
* pWin
, BOOL bIsFirst
);
405 virtual SvxRuler
* CreateVRuler(::sd::Window
* pWin
);
406 virtual void UpdateHRuler();
407 virtual void UpdateVRuler();
408 virtual long GetHCtrlWidth();
409 virtual void SetZoomFactor(const Fraction
& rZoomX
, const Fraction
& rZoomY
);
410 virtual Size
GetOptimalSizePixel() const;
412 void SetupPage( Size
&rSize
, long nLeft
, long nRight
, long nUpper
, long nLower
,
413 BOOL bSize
, BOOL bMargin
, BOOL bScaleAll
);
415 USHORT
GetIdBySubId( USHORT nSId
);
416 void MapSlot( USHORT nSId
);
417 void UpdateToolboxImages( SfxItemSet
&rSet
, BOOL bPermanent
= TRUE
);
418 USHORT
GetMappedSlot( USHORT nSId
);
419 USHORT
GetArrayId( USHORT nSId
);
421 void GetMenuStateSel(SfxItemSet
& rSet
);
424 /** This flag controls whether the layer mode is active, i.e. the layer
427 bool mbIsLayerModeActive
;
429 /** This item contains the clipboard formats of the current clipboard
430 content that are supported both by that content and by the
433 ::std::auto_ptr
<SvxClipboardFmtItem
> mpCurrentClipboardFormats
;
435 /** On some occasions it is necessary to make SwitchPage calls
438 tools::AsynchronousCall maAsynchronousSwitchPageCall
;
440 /** This flag is used to prevent nested calls to SwitchPage().
442 bool mbIsInSwitchPage
;
444 void Construct (DrawDocShell
* pDocSh
, PageKind ePageKind
);
446 /** Depending on the given request create a new page or duplicate an
447 existing one. See ViewShell::CreateOrDuplicatePage() for more
450 virtual SdPage
* CreateOrDuplicatePage (
451 SfxRequest
& rRequest
,
455 ::com::sun::star::uno::Reference
< ::com::sun::star::scanner::XScannerManager
> mxScannerManager
;
456 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> mxScannerListener
;
457 TransferableClipboardListener
* mpClipEvtLstnr
;
458 BOOL mbPastePossible
;
460 virtual void Notify (SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
462 /** Stop a running slide show. The frame the show is running in is
464 a) it is running in its own frame, i.e. is a full screen show and
465 b) the given flag bCloseFrame is true.
467 Be carefull with this flag when stopping a full screen show.
468 When called from the destructor the flag has to be <FALSE/> or
469 otherwise we run into a loop of calls to destructors of the view
471 When called from other places the flag should be <TRUE/> so that
472 not an empty frame remains. When called with <TRUE/> it is the
473 responsibility of the caller to avoid an illegal reentrant
476 void StopSlideShow (bool bCloseFrame
);
478 using ViewShell::Notify
;
482 } // end of namespace sd