Update ooo320-m1
[ooovba.git] / sd / source / ui / inc / DrawViewShell.hxx
blob542d697386d4d45011de22976614b91f771bf30b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DrawViewShell.hxx,v $
10 * $Revision: 1.28 $
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"
39 #include "pres.hxx"
40 #include <com/sun/star/lang/XEventListener.hpp>
41 #include <com/sun/star/scanner/XScannerManager.hpp>
43 class SdPage;
44 class DrawDocShell;
45 class SdAnimationWin;
46 class SdRuler;
47 class TabBar;
48 class SdrObject;
49 class SdrPageView;
50 class TransferableDataHelper;
51 class TransferableClipboardListener;
52 class AbstractSvxNameDialog;
53 class SdrLayer;
54 class SvxClipboardFmtItem;
56 namespace sd {
58 class DrawView;
59 class LayerTabBar;
60 class Ruler;
61 class SdUnoDrawView;
62 class AnnotationManager;
64 #define CHECK_RANGE(nMin, nValue, nMax) ((nValue >= nMin) && (nValue <= nMax))
66 /** Base class of the stacked shells that provide graphical views to
67 Draw and Impress documents and editing functionality. In contrast
68 to this other stacked shells are responsible for showing an
69 overview over several slides (SlideViewShell) or a textual
70 overview over the text in an Impress document (OutlineViewShell).
72 class DrawViewShell
73 : public ViewShell,
74 public SfxListener
76 public:
77 static const int SLOTARRAY_COUNT = 24;
79 TYPEINFO();
81 SFX_DECL_INTERFACE(SD_IF_SDDRAWVIEWSHELL)
83 /** Create a new stackable shell that may take some information
84 (e.g. the frame view) from the given previous shell.
85 @param ePageKind
86 This parameter gives the initial page kind that the new shell
87 will show.
88 @param pFrameView
89 The frame view that makes it possible to pass information from
90 one view shell to the next.
92 DrawViewShell (
93 SfxViewFrame* pFrame,
94 ViewShellBase& rViewShellBase,
95 ::Window* pParentWindow,
96 PageKind ePageKind = PK_STANDARD,
97 FrameView* pFrameView = NULL);
99 DrawViewShell(
100 SfxViewFrame* pFrame,
101 ::Window* pParentWindow,
102 const DrawViewShell& rShell);
104 virtual ~DrawViewShell (void);
106 virtual void Init (bool bIsMainViewShell);
108 virtual void Shutdown (void);
110 void PrePaint();
111 virtual void Paint(const Rectangle& rRect, ::sd::Window* pWin);
113 /** Set the position and size of the area which contains the GUI
114 elements like rulers, sliders, and buttons as well as the document
115 view. Both size and position are expected to be in pixel
116 coordinates. The positions and sizes of the mentioned GUI elements
117 are updated as well.
119 <p> This method is implemented by first setting copying the given
120 values to internal variables and then calling the
121 <type>ArrangeGUIElements</type> method which performs the actual
122 work of sizeing and arranging the UI elements accordingly.</p>
123 @param rPos
124 The position of the enclosing window relative to the document
125 window. This is only interesting if a Draw/Impress document
126 view is embedded as OLE object into another document view. For
127 normal documents this position is (0,0).
128 @param rSize
129 The new size in pixel.
131 // virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
133 /** Arrange and resize the GUI elements like rulers, sliders, and
134 buttons as well as the actual document view according to the size of
135 the enclosing window and current sizes of buttons, rulers, and
136 sliders.
138 virtual void ArrangeGUIElements (void);
140 void HidePage();
142 virtual BOOL KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin);
143 virtual void MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin);
144 virtual void MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin);
145 virtual void MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin);
146 virtual void Command(const CommandEvent& rCEvt, ::sd::Window* pWin);
148 virtual void Resize (void);
150 void ShowMousePosInfo(const Rectangle& rRect, ::sd::Window* pWin);
152 virtual void AddWindow(::sd::Window* pWin);
153 virtual void RemoveWindow(::sd::Window* pWin);
155 virtual void ChangeEditMode (EditMode eMode, bool bIsLayerModeActive);
157 virtual void SetZoom( long nZoom );
158 virtual void SetZoomRect( const Rectangle& rZoomRect );
160 void InsertURLField(const String& rURL, const String& rText, const String& rTarget,
161 const Point* pPos);
162 void InsertURLButton(const String& rURL, const String& rText, const String& rTarget,
163 const Point* pPos);
165 virtual void SetUIUnit(FieldUnit eUnit);
167 void SelectionHasChanged();
168 void ModelHasChanged();
169 virtual void Activate(BOOL bIsMDIActivate);
170 virtual void Deactivate(BOOL IsMDIActivate);
171 virtual void UIActivating( SfxInPlaceClient* );
172 virtual void UIDeactivated( SfxInPlaceClient* );
173 virtual String GetSelectionText( BOOL bCompleteWords = FALSE );
174 virtual BOOL HasSelection( BOOL bText = TRUE ) const;
176 void ExecCtrl(SfxRequest& rReq);
177 void GetCtrlState(SfxItemSet& rSet);
178 void GetMenuState(SfxItemSet& rSet);
179 void GetTableMenuState(SfxItemSet& rSet);
180 /** Set the items of the given item set that are related to
181 switching the editing mode to the correct values.
182 <p>This function also sets the states of the mode buttons
183 (those at the upper right corner) accordingly.</p>
185 void GetModeSwitchingMenuState (SfxItemSet &rSet);
186 void GetAttrState(SfxItemSet& rSet);
187 void GetSnapItemState(SfxItemSet& rSet);
189 void GetState (SfxItemSet& rSet);
190 void Execute (SfxRequest& rReq);
192 void ExecStatusBar(SfxRequest& rReq);
193 void GetStatusBarState(SfxItemSet& rSet);
195 void ExecOptionsBar(SfxRequest& rReq);
196 void GetOptionsBarState(SfxItemSet& rSet);
198 void ExecRuler(SfxRequest& rReq);
199 void GetRulerState(SfxItemSet& rSet);
201 void ExecFormText(SfxRequest& rReq);
202 void GetFormTextState(SfxItemSet& rSet);
204 void ExecObjPalette(SfxRequest& rReq);
205 void GetObjPaletteState(SfxItemSet& rSet);
207 void ExecAnimationWin(SfxRequest& rReq);
208 void GetAnimationWinState(SfxItemSet& rSet);
210 void ExecNavigatorWin(SfxRequest& rReq);
211 void GetNavigatorWinState(SfxItemSet& rSet);
213 void ExecEffectWin(SfxRequest& rReq);
215 void Update3DWindow();
216 void AssignFrom3DWindow();
218 void ExecGallery(SfxRequest& rReq);
219 void GetGalleryState(SfxItemSet& rSet);
221 void ExecBmpMask( SfxRequest& rReq );
222 void GetBmpMaskState( SfxItemSet& rSet );
224 void ExecIMap( SfxRequest& rReq );
225 void GetIMapState( SfxItemSet& rSet );
227 void FuTemporary(SfxRequest& rReq);
228 void FuPermanent(SfxRequest& rReq);
229 void FuSupport(SfxRequest& rReq);
230 void FuTable(SfxRequest& rReq);
232 void AttrExec (SfxRequest& rReq);
233 void AttrState (SfxItemSet& rSet);
235 void ExecuteAnnotation (SfxRequest& rRequest);
236 void GetAnnotationState (SfxItemSet& rItemSet);
238 void StartRulerDrag (
239 const Ruler& rRuler,
240 const MouseEvent& rMEvt);
242 virtual USHORT PrepareClose( BOOL bUI = TRUE, BOOL bForBrowsing = FALSE );
244 PageKind GetPageKind() { return mePageKind; }
246 Point GetMousePos() { return maMousePos; }
247 BOOL IsMousePosFreezed() { return mbMousePosFreezed; }
248 void SetMousePosFreezed( BOOL bIn ) { mbMousePosFreezed = bIn; }
250 EditMode GetEditMode() const { return meEditMode; }
251 virtual SdPage* GetActualPage() { return mpActualPage; }
253 /// inherited from sd::ViewShell
254 virtual SdPage* getCurrentPage() const;
256 void ResetActualPage();
257 void ResetActualLayer();
258 BOOL SwitchPage(USHORT nPage);
259 BOOL IsSwitchPageAllowed() const;
261 BOOL GotoBookmark(const String& rBookmark);
262 void MakeVisible(const Rectangle& rRect, ::Window& rWin);
264 virtual void ReadFrameViewData(FrameView* pView);
265 virtual void WriteFrameViewData();
267 virtual ErrCode DoVerb(long nVerb);
268 virtual BOOL ActivateObject(SdrOle2Obj* pObj, long nVerb);
270 void SetZoomOnPage( BOOL bZoom = TRUE ) { mbZoomOnPage = bZoom; }
271 BOOL IsZoomOnPage() { return mbZoomOnPage; }
272 void CheckLineTo (SfxRequest& rReq);
273 void FuTemp01(SfxRequest& rReq);
274 void FuTemp02(SfxRequest& rReq);
275 void FuTemp03(SfxRequest& rReq);
276 void FuTemp04(SfxRequest& rReq);
277 void SetChildWindowState( SfxItemSet& rSet );
279 void UpdateIMapDlg( SdrObject* pObj );
281 void LockInput();
282 void UnlockInput();
283 BOOL IsInputLocked() const { return mnLockCount > 0UL; }
285 USHORT GetCurPageId() { return( maTabControl.GetCurPageId() ); }
287 /** Show controls of the UI or hide them, depending on the given flag.
288 Do not call this method directly. Call the method at ViewShellBase
289 instead.
291 virtual void ShowUIControls (bool bVisible = true);
293 void ScannerEvent( const ::com::sun::star::lang::EventObject& rEventObject );
295 bool IsLayerModeActive (void) const;
297 USHORT* GetSlotArray() const { return mpSlotArray; }
299 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
300 ::sd::Window* pTargetWindow, USHORT nPage, USHORT nLayer );
301 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper,
302 ::sd::Window* pTargetWindow, USHORT nPage, USHORT nLayer );
304 virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
305 virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
307 virtual void VisAreaChanged(const Rectangle& rRect);
309 /** Create an accessible object representing the specified window.
310 @param pWindow
311 The returned object makes the document displayed in this window
312 accessible.
313 @return
314 Returns an <type>AccessibleDrawDocumentView</type> object.
316 virtual ::com::sun::star::uno::Reference<
317 ::com::sun::star::accessibility::XAccessible>
318 CreateAccessibleDocumentView (::sd::Window* pWindow);
320 /** Return the number of layers managed by the layer tab control. This
321 will usually differ from the number of layers managed by the layer
322 administrator.
323 @return
324 The number of layers managed by the layer tab control. The
325 returned value is independent of whether the layer modus is
326 currently active and the tab control is visible.
328 virtual int GetTabLayerCount (void) const;
330 /** Return the numerical id of the currently active layer as seen by the
331 layer tab control.
332 @return
333 The returned id is a number between zero (inclusive) and the
334 number of layers as returned by the
335 <member>GetTabLayerCount</member> method (exclusive).
337 virtual int GetActiveTabLayerIndex (void) const;
339 /** Set the active layer at the layer tab control and update the control
340 accordingly to reflect the change on screen.
341 @param nId
342 The id is expected to be a number between zero (inclusive) and
343 the number of layers as returned by the
344 <member>GetTabLayerCount</member> method (exclusive). Note that
345 Invalid values are ignored. No excpetion is thrown in that case.
347 virtual void SetActiveTabLayerIndex (int nId);
349 /** Return a pointer to the tab control for pages.
351 TabControl* GetPageTabControl (void);
353 /** Return a pointer to the tab control for layers.
355 LayerTabBar* GetLayerTabControl (void);
357 /** Renames the given slide using an SvxNameDialog
359 @param nPageId the index of the page in the SdTabControl.
360 @param rName the new name of the slide.
362 @return false, if the new name is invalid for some reason.
364 <p>Implemented in <code>drviews8.cxx</code>.</p>
366 bool RenameSlide( USHORT nPageId, const String & rName );
368 /** modifies the given layer with the given values */
369 void ModifyLayer( SdrLayer* pLayer, const String& rLayerName, const String& rLayerTitle, const String& rLayerDesc, bool bIsVisible, bool bIsLocked, bool bIsPrintable );
371 virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController (void);
373 DrawView* GetDrawView() const { return mpDrawView; }
375 /** Relocation to a new parent window is not supported for DrawViewShell
376 objects so this method always returns <FALSE/>.
378 virtual bool RelocateToParentWindow (::Window* pParentWindow);
380 protected:
381 DrawView* mpDrawView;
382 SdPage* mpActualPage;
383 Rectangle maMarkRect;
384 Point maMousePos;
385 BOOL mbMousePosFreezed;
386 TabControl maTabControl;
387 EditMode meEditMode;
388 PageKind mePageKind;
389 BOOL mbZoomOnPage;
390 BOOL mbIsRulerDrag;
391 ULONG mnLockCount;
392 Timer maCloseTimer;
393 BOOL mbReadOnly;
394 USHORT* mpSlotArray;
396 static BOOL mbPipette;
398 DECL_LINK( ClipboardChanged, TransferableDataHelper* );
399 DECL_LINK( CloseHdl, Timer* pTimer );
400 DECL_LINK( TabSplitHdl, TabBar * );
401 DECL_LINK( NameObjectHdl, AbstractSvxNameDialog* );
402 DECL_LINK( RenameSlideHdl, AbstractSvxNameDialog* );
404 void DeleteActualPage();
405 void DeleteActualLayer();
407 virtual SvxRuler* CreateHRuler(::sd::Window* pWin, BOOL bIsFirst);
408 virtual SvxRuler* CreateVRuler(::sd::Window* pWin);
409 virtual void UpdateHRuler();
410 virtual void UpdateVRuler();
411 virtual long GetHCtrlWidth();
412 virtual void SetZoomFactor(const Fraction& rZoomX, const Fraction& rZoomY);
413 virtual Size GetOptimalSizePixel() const;
415 void SetupPage( Size &rSize, long nLeft, long nRight, long nUpper, long nLower,
416 BOOL bSize, BOOL bMargin, BOOL bScaleAll );
418 USHORT GetIdBySubId( USHORT nSId );
419 void MapSlot( USHORT nSId );
420 void UpdateToolboxImages( SfxItemSet &rSet, BOOL bPermanent = TRUE );
421 USHORT GetMappedSlot( USHORT nSId );
422 USHORT GetArrayId( USHORT nSId );
424 void GetMenuStateSel(SfxItemSet& rSet);
426 private:
427 /** This flag controls whether the layer mode is active, i.e. the layer
428 dialog is visible.
430 bool mbIsLayerModeActive;
432 /** This item contains the clipboard formats of the current clipboard
433 content that are supported both by that content and by the
434 DrawViewShell.
436 ::std::auto_ptr<SvxClipboardFmtItem> mpCurrentClipboardFormats;
438 /** On some occasions it is necessary to make SwitchPage calls
439 asynchronously.
441 tools::AsynchronousCall maAsynchronousSwitchPageCall;
443 /** This flag is used to prevent nested calls to SwitchPage().
445 bool mbIsInSwitchPage;
447 void Construct (DrawDocShell* pDocSh, PageKind ePageKind);
449 /** Depending on the given request create a new page or duplicate an
450 existing one. See ViewShell::CreateOrDuplicatePage() for more
451 information.
453 virtual SdPage* CreateOrDuplicatePage (
454 SfxRequest& rRequest,
455 PageKind ePageKind,
456 SdPage* pPage);
458 ::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager > mxScannerManager;
459 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > mxScannerListener;
460 TransferableClipboardListener* mpClipEvtLstnr;
461 BOOL mbPastePossible;
463 virtual void Notify (SfxBroadcaster& rBC, const SfxHint& rHint);
465 /** Stop a running slide show. The frame the show is running in is
466 destroyed if
467 a) it is running in its own frame, i.e. is a full screen show and
468 b) the given flag bCloseFrame is true.
469 @param bCloseFrame
470 Be carefull with this flag when stopping a full screen show.
471 When called from the destructor the flag has to be <FALSE/> or
472 otherwise we run into a loop of calls to destructors of the view
473 and the frame.
474 When called from other places the flag should be <TRUE/> so that
475 not an empty frame remains. When called with <TRUE/> it is the
476 responsibility of the caller to avoid an illegal reentrant
477 call.
479 void StopSlideShow (bool bCloseFrame);
481 /** Show the context menu for snap lines and points. Because snap lines
482 can not be selected the index of the snap line/point for which the
483 popup menu is opened has to be passed to the processing slot
484 handlers. This can be done only by manually showing the popup menu.
485 @param rPageView
486 The page view is used to access the help lines.
487 @param nSnapLineIndex
488 Index of the snap line or snap point for which to show the
489 context menu.
490 @param rMouseLocation
491 The mouse location defines the location at which to display the
492 context menu.
494 void ShowSnapLineContextMenu (
495 SdrPageView& rPageView,
496 const USHORT nSnapLineIndex,
497 const Point& rMouseLocation);
499 using ViewShell::Notify;
501 ::std::auto_ptr< AnnotationManager > mpAnnotationManager;
505 } // end of namespace sd
507 #endif