Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SD_DRAW_VIEW_SHELL_HXX
30 : : #define SD_DRAW_VIEW_SHELL_HXX
31 : :
32 : : #include "ViewShell.hxx"
33 : : #include "tools/AsynchronousCall.hxx"
34 : : #include <sfx2/viewfac.hxx>
35 : : #include <sfx2/viewsh.hxx>
36 : : #include "TabControl.hxx"
37 : : #include "pres.hxx"
38 : : #include <com/sun/star/lang/XEventListener.hpp>
39 : : #include <com/sun/star/scanner/XScannerManager2.hpp>
40 : : #include <unotools/caserotate.hxx>
41 : :
42 : : class SdPage;
43 : : class DrawDocShell;
44 : : class TabBar;
45 : : class SdrObject;
46 : : class SdrPageView;
47 : : class TransferableDataHelper;
48 : : class TransferableClipboardListener;
49 : : class AbstractSvxNameDialog;
50 : : class SdrLayer;
51 : : class SvxClipboardFmtItem;
52 : :
53 : : namespace sd {
54 : :
55 : : class DrawView;
56 : : class LayerTabBar;
57 : : class Ruler;
58 : : class AnnotationManager;
59 : : class ViewOverlayManager;
60 : :
61 : : #define CHECK_RANGE(nMin, nValue, nMax) ((nValue >= nMin) && (nValue <= nMax))
62 : :
63 : : /** Base class of the stacked shells that provide graphical views to
64 : : Draw and Impress documents and editing functionality. In contrast
65 : : to this other stacked shells are responsible for showing an
66 : : overview over several slides or a textual
67 : : overview over the text in an Impress document (OutlineViewShell).
68 : : */
69 : : class DrawViewShell
70 : : : public ViewShell,
71 : : public SfxListener
72 : : {
73 : : public:
74 : : static const int SLOTARRAY_COUNT = 24;
75 : :
76 : : TYPEINFO();
77 : :
78 : 50 : SFX_DECL_INTERFACE(SD_IF_SDDRAWVIEWSHELL)
79 : :
80 : : /** Create a new stackable shell that may take some information
81 : : (e.g. the frame view) from the given previous shell.
82 : : @param ePageKind
83 : : This parameter gives the initial page kind that the new shell
84 : : will show.
85 : : @param pFrameView
86 : : The frame view that makes it possible to pass information from
87 : : one view shell to the next.
88 : : */
89 : : DrawViewShell (
90 : : SfxViewFrame* pFrame,
91 : : ViewShellBase& rViewShellBase,
92 : : ::Window* pParentWindow,
93 : : PageKind ePageKind = PK_STANDARD,
94 : : FrameView* pFrameView = NULL);
95 : :
96 : : virtual ~DrawViewShell (void);
97 : :
98 : : virtual void Init (bool bIsMainViewShell);
99 : :
100 : : virtual void Shutdown (void);
101 : :
102 : : void PrePaint();
103 : : virtual void Paint(const Rectangle& rRect, ::sd::Window* pWin);
104 : :
105 : : /** Set the position and size of the area which contains the GUI
106 : : elements like rulers, sliders, and buttons as well as the document
107 : : view. Both size and position are expected to be in pixel
108 : : coordinates. The positions and sizes of the mentioned GUI elements
109 : : are updated as well.
110 : :
111 : : <p> This method is implemented by first setting copying the given
112 : : values to internal variables and then calling the
113 : : <type>ArrangeGUIElements</type> method which performs the actual
114 : : work of sizeing and arranging the UI elements accordingly.</p>
115 : : @param rPos
116 : : The position of the enclosing window relative to the document
117 : : window. This is only interesting if a Draw/Impress document
118 : : view is embedded as OLE object into another document view. For
119 : : normal documents this position is (0,0).
120 : : @param rSize
121 : : The new size in pixel.
122 : : */
123 : : // virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
124 : :
125 : : /** Arrange and resize the GUI elements like rulers, sliders, and
126 : : buttons as well as the actual document view according to the size of
127 : : the enclosing window and current sizes of buttons, rulers, and
128 : : sliders.
129 : : */
130 : : virtual void ArrangeGUIElements (void);
131 : :
132 : : void HidePage();
133 : :
134 : : virtual sal_Bool KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin);
135 : : virtual void MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin);
136 : : virtual void MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin);
137 : : virtual void MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin);
138 : : virtual void Command(const CommandEvent& rCEvt, ::sd::Window* pWin);
139 : :
140 : : virtual void Resize (void);
141 : :
142 : : void ShowMousePosInfo(const Rectangle& rRect, ::sd::Window* pWin);
143 : :
144 : : virtual void AddWindow(::sd::Window* pWin);
145 : : virtual void RemoveWindow(::sd::Window* pWin);
146 : :
147 : : virtual void ChangeEditMode (EditMode eMode, bool bIsLayerModeActive);
148 : :
149 : : virtual void SetZoom( long nZoom );
150 : : virtual void SetZoomRect( const Rectangle& rZoomRect );
151 : :
152 : : void InsertURLField(const String& rURL, const String& rText, const String& rTarget,
153 : : const Point* pPos);
154 : : void InsertURLButton(const String& rURL, const String& rText, const String& rTarget,
155 : : const Point* pPos);
156 : :
157 : : virtual void SetUIUnit(FieldUnit eUnit);
158 : :
159 : : void SelectionHasChanged();
160 : : void ModelHasChanged();
161 : : virtual void Activate(sal_Bool bIsMDIActivate);
162 : : virtual void Deactivate(sal_Bool IsMDIActivate);
163 : : virtual void UIActivating( SfxInPlaceClient* );
164 : : virtual void UIDeactivated( SfxInPlaceClient* );
165 : : virtual String GetSelectionText( sal_Bool bCompleteWords = sal_False );
166 : : virtual sal_Bool HasSelection( sal_Bool bText = sal_True ) const;
167 : :
168 : : void ExecCtrl(SfxRequest& rReq);
169 : : void GetCtrlState(SfxItemSet& rSet);
170 : : void GetMenuState(SfxItemSet& rSet);
171 : : void GetTableMenuState(SfxItemSet& rSet);
172 : : /** Set the items of the given item set that are related to
173 : : switching the editing mode to the correct values.
174 : : <p>This function also sets the states of the mode buttons
175 : : (those at the upper right corner) accordingly.</p>
176 : : */
177 : : void GetModeSwitchingMenuState (SfxItemSet &rSet);
178 : : void GetAttrState(SfxItemSet& rSet);
179 : : void GetSnapItemState(SfxItemSet& rSet);
180 : :
181 : : void GetState (SfxItemSet& rSet);
182 : : void Execute (SfxRequest& rReq);
183 : :
184 : : void ExecStatusBar(SfxRequest& rReq);
185 : : void GetStatusBarState(SfxItemSet& rSet);
186 : :
187 : : void ExecOptionsBar(SfxRequest& rReq);
188 : : void GetOptionsBarState(SfxItemSet& rSet);
189 : :
190 : : void ExecRuler(SfxRequest& rReq);
191 : : void GetRulerState(SfxItemSet& rSet);
192 : :
193 : : void ExecFormText(SfxRequest& rReq);
194 : : void GetFormTextState(SfxItemSet& rSet);
195 : :
196 : : void ExecAnimationWin(SfxRequest& rReq);
197 : : void GetAnimationWinState(SfxItemSet& rSet);
198 : :
199 : : void ExecNavigatorWin(SfxRequest& rReq);
200 : : void GetNavigatorWinState(SfxItemSet& rSet);
201 : :
202 : : void ExecEffectWin(SfxRequest& rReq);
203 : :
204 : : void Update3DWindow();
205 : : void AssignFrom3DWindow();
206 : :
207 : : void ExecGallery(SfxRequest& rReq);
208 : : void GetGalleryState(SfxItemSet& rSet);
209 : :
210 : : void ExecBmpMask( SfxRequest& rReq );
211 : : void GetBmpMaskState( SfxItemSet& rSet );
212 : :
213 : : void ExecIMap( SfxRequest& rReq );
214 : : void GetIMapState( SfxItemSet& rSet );
215 : :
216 : : void FuTemporary(SfxRequest& rReq);
217 : : void FuPermanent(SfxRequest& rReq);
218 : : void FuSupport(SfxRequest& rReq);
219 : : void FuSupportRotate(SfxRequest& rReq);
220 : : void FuTable(SfxRequest& rReq);
221 : :
222 : : void AttrExec (SfxRequest& rReq);
223 : : void AttrState (SfxItemSet& rSet);
224 : :
225 : : void ExecuteAnnotation (SfxRequest& rRequest);
226 : : void GetAnnotationState (SfxItemSet& rItemSet);
227 : :
228 : : void StartRulerDrag (
229 : : const Ruler& rRuler,
230 : : const MouseEvent& rMEvt);
231 : :
232 : : virtual sal_uInt16 PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False );
233 : :
234 : 26 : PageKind GetPageKind() { return mePageKind; }
235 : :
236 : 0 : Point GetMousePos() { return maMousePos; }
237 : : sal_Bool IsMousePosFreezed() { return mbMousePosFreezed; }
238 : 0 : void SetMousePosFreezed( sal_Bool bIn ) { mbMousePosFreezed = bIn; }
239 : :
240 : 172 : EditMode GetEditMode() const { return meEditMode; }
241 : 825 : virtual SdPage* GetActualPage() { return mpActualPage; }
242 : :
243 : : /// inherited from sd::ViewShell
244 : : virtual SdPage* getCurrentPage() const;
245 : :
246 : : void ResetActualPage();
247 : : void ResetActualLayer();
248 : : sal_Bool SwitchPage(sal_uInt16 nPage);
249 : : sal_Bool IsSwitchPageAllowed() const;
250 : :
251 : : sal_Bool GotoBookmark(const String& rBookmark);
252 : : void MakeVisible(const Rectangle& rRect, ::Window& rWin);
253 : :
254 : : virtual void ReadFrameViewData(FrameView* pView);
255 : : virtual void WriteFrameViewData();
256 : :
257 : : virtual ErrCode DoVerb(long nVerb);
258 : : virtual sal_Bool ActivateObject(SdrOle2Obj* pObj, long nVerb);
259 : :
260 : 0 : void SetZoomOnPage( sal_Bool bZoom = sal_True ) { mbZoomOnPage = bZoom; }
261 : 0 : 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 );
268 : :
269 : : void UpdateIMapDlg( SdrObject* pObj );
270 : :
271 : : void LockInput();
272 : : void UnlockInput();
273 : 0 : sal_Bool IsInputLocked() const { return mnLockCount > 0UL; }
274 : :
275 : 0 : sal_uInt16 GetCurPageId() { return( maTabControl.GetCurPageId() ); }
276 : :
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.
280 : : */
281 : : virtual void ShowUIControls (bool bVisible = true);
282 : :
283 : : void ScannerEvent( const ::com::sun::star::lang::EventObject& rEventObject );
284 : :
285 : : bool IsLayerModeActive (void) const;
286 : :
287 : 0 : sal_uInt16* GetSlotArray() const { return mpSlotArray; }
288 : :
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 );
293 : :
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 );
296 : :
297 : : virtual void VisAreaChanged(const Rectangle& rRect);
298 : :
299 : : /** Create an accessible object representing the specified window.
300 : : @param pWindow
301 : : The returned object makes the document displayed in this window
302 : : accessible.
303 : : @return
304 : : Returns an <type>AccessibleDrawDocumentView</type> object.
305 : : */
306 : : virtual ::com::sun::star::uno::Reference<
307 : : ::com::sun::star::accessibility::XAccessible>
308 : : CreateAccessibleDocumentView (::sd::Window* pWindow);
309 : :
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
312 : : administrator.
313 : : @return
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.
317 : : */
318 : : virtual int GetTabLayerCount (void) const;
319 : :
320 : : /** Return the numerical id of the currently active layer as seen by the
321 : : layer tab control.
322 : : @return
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).
326 : : */
327 : : virtual int GetActiveTabLayerIndex (void) const;
328 : :
329 : : /** Set the active layer at the layer tab control and update the control
330 : : accordingly to reflect the change on screen.
331 : : @param nId
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.
336 : : */
337 : : virtual void SetActiveTabLayerIndex (int nId);
338 : :
339 : : /** Return a pointer to the tab control for pages.
340 : : */
341 : : TabControl* GetPageTabControl (void);
342 : :
343 : : /** Return a pointer to the tab control for layers.
344 : : */
345 : : LayerTabBar* GetLayerTabControl (void);
346 : :
347 : : /** Renames the given slide using an SvxNameDialog
348 : :
349 : : @param nPageId the index of the page in the SdTabControl.
350 : : @param rName the new name of the slide.
351 : :
352 : : @return false, if the new name is invalid for some reason.
353 : :
354 : : <p>Implemented in <code>drviews8.cxx</code>.</p>
355 : : */
356 : : bool RenameSlide( sal_uInt16 nPageId, const String & rName );
357 : :
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 );
360 : :
361 : : virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController (void);
362 : :
363 : 6388 : DrawView* GetDrawView() const { return mpDrawView; }
364 : :
365 : : /** Relocation to a new parent window is not supported for DrawViewShell
366 : : objects so this method always returns <FALSE/>.
367 : : */
368 : : virtual bool RelocateToParentWindow (::Window* pParentWindow);
369 : :
370 : : protected:
371 : : DrawView* mpDrawView;
372 : : SdPage* mpActualPage;
373 : : Rectangle maMarkRect;
374 : : Point maMousePos;
375 : : sal_Bool mbMousePosFreezed;
376 : : TabControl maTabControl;
377 : : EditMode meEditMode;
378 : : PageKind mePageKind;
379 : : sal_Bool mbZoomOnPage;
380 : : sal_Bool mbIsRulerDrag;
381 : : sal_uLong mnLockCount;
382 : : Timer maCloseTimer;
383 : : sal_Bool mbReadOnly;
384 : : sal_uInt16* mpSlotArray;
385 : :
386 : : static sal_Bool mbPipette;
387 : :
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* );
393 : :
394 : : void DeleteActualPage();
395 : : void DeleteActualLayer();
396 : :
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;
404 : :
405 : : void SetupPage( Size &rSize, long nLeft, long nRight, long nUpper, long nLower,
406 : : sal_Bool bSize, sal_Bool bMargin, sal_Bool bScaleAll );
407 : :
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 );
413 : :
414 : : void GetMenuStateSel(SfxItemSet& rSet);
415 : :
416 : : private:
417 : : /** This flag controls whether the layer mode is active, i.e. the layer
418 : : dialog is visible.
419 : : */
420 : : bool mbIsLayerModeActive;
421 : :
422 : : /** This item contains the clipboard formats of the current clipboard
423 : : content that are supported both by that content and by the
424 : : DrawViewShell.
425 : : */
426 : : ::std::auto_ptr<SvxClipboardFmtItem> mpCurrentClipboardFormats;
427 : :
428 : : /** On some occasions it is necessary to make SwitchPage calls
429 : : asynchronously.
430 : : */
431 : : tools::AsynchronousCall maAsynchronousSwitchPageCall;
432 : :
433 : : /** This flag is used to prevent nested calls to SwitchPage().
434 : : */
435 : : bool mbIsInSwitchPage;
436 : :
437 : : RotateTransliteration m_aRotateCase;
438 : :
439 : : void Construct (DrawDocShell* pDocSh, PageKind ePageKind);
440 : :
441 : : /** Depending on the given request create a new page or duplicate an
442 : : existing one. See ViewShell::CreateOrDuplicatePage() for more
443 : : information.
444 : : */
445 : : virtual SdPage* CreateOrDuplicatePage (
446 : : SfxRequest& rRequest,
447 : : PageKind ePageKind,
448 : : SdPage* pPage,
449 : : const sal_Int32 nInsertPosition = -1);
450 : :
451 : : ::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager2 > mxScannerManager;
452 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > mxScannerListener;
453 : : TransferableClipboardListener* mpClipEvtLstnr;
454 : : sal_Bool mbPastePossible;
455 : :
456 : : virtual void Notify (SfxBroadcaster& rBC, const SfxHint& rHint);
457 : :
458 : : /** Stop a running slide show. The frame the show is running in is
459 : : destroyed if
460 : : a) it is running in its own frame, i.e. is a full screen show and
461 : : b) the given flag bCloseFrame is true.
462 : : @param bCloseFrame
463 : : Be carefull with this flag when stopping a full screen show.
464 : : When called from the destructor the flag has to be <FALSE/> or
465 : : otherwise we run into a loop of calls to destructors of the view
466 : : and the frame.
467 : : When called from other places the flag should be <TRUE/> so that
468 : : not an empty frame remains. When called with <TRUE/> it is the
469 : : responsibility of the caller to avoid an illegal reentrant
470 : : call.
471 : : */
472 : : void StopSlideShow (bool bCloseFrame);
473 : :
474 : : /** Show the context menu for snap lines and points. Because snap lines
475 : : can not be selected the index of the snap line/point for which the
476 : : popup menu is opened has to be passed to the processing slot
477 : : handlers. This can be done only by manually showing the popup menu.
478 : : @param rPageView
479 : : The page view is used to access the help lines.
480 : : @param nSnapLineIndex
481 : : Index of the snap line or snap point for which to show the
482 : : context menu.
483 : : @param rMouseLocation
484 : : The mouse location defines the location at which to display the
485 : : context menu.
486 : : */
487 : : void ShowSnapLineContextMenu (
488 : : SdrPageView& rPageView,
489 : : const sal_uInt16 nSnapLineIndex,
490 : : const Point& rMouseLocation);
491 : :
492 : : using ViewShell::Notify;
493 : :
494 : : ::std::auto_ptr< AnnotationManager > mpAnnotationManager;
495 : : ::std::auto_ptr< ViewOverlayManager > mpViewOverlayManager;
496 : : };
497 : :
498 : :
499 : : } // end of namespace sd
500 : :
501 : : #endif
502 : :
503 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|