Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef SD_DRAW_VIEW_SHELL_HXX
21 : #define SD_DRAW_VIEW_SHELL_HXX
22 :
23 : #include "ViewShell.hxx"
24 : #include "tools/AsynchronousCall.hxx"
25 : #include <sfx2/viewfac.hxx>
26 : #include <sfx2/viewsh.hxx>
27 : #include "TabControl.hxx"
28 : #include "pres.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>
33 :
34 : class SdPage;
35 : class DrawDocShell;
36 : class TabBar;
37 : class SdrObject;
38 : class SdrPageView;
39 : class TransferableDataHelper;
40 : class TransferableClipboardListener;
41 : class AbstractSvxNameDialog;
42 : class SdrLayer;
43 : class SvxClipboardFmtItem;
44 :
45 : namespace sd {
46 :
47 : class DrawView;
48 : class LayerTabBar;
49 : class Ruler;
50 : class AnnotationManager;
51 : class ViewOverlayManager;
52 :
53 : #define CHECK_RANGE(nMin, nValue, nMax) ((nValue >= nMin) && (nValue <= nMax))
54 :
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).
60 : */
61 : class DrawViewShell
62 : : public ViewShell,
63 : public SfxListener
64 : {
65 : public:
66 : static const int SLOTARRAY_COUNT = 24;
67 :
68 : TYPEINFO();
69 :
70 22 : SFX_DECL_INTERFACE(SD_IF_SDDRAWVIEWSHELL)
71 :
72 : /** Create a new stackable shell that may take some information
73 : (e.g. the frame view) from the given previous shell.
74 : @param ePageKind
75 : This parameter gives the initial page kind that the new shell
76 : will show.
77 : @param pFrameView
78 : The frame view that makes it possible to pass information from
79 : one view shell to the next.
80 : */
81 : DrawViewShell (
82 : SfxViewFrame* pFrame,
83 : ViewShellBase& rViewShellBase,
84 : ::Window* pParentWindow,
85 : PageKind ePageKind = PK_STANDARD,
86 : FrameView* pFrameView = NULL);
87 :
88 : virtual ~DrawViewShell (void);
89 :
90 : virtual void Init (bool bIsMainViewShell);
91 :
92 : virtual void Shutdown (void);
93 :
94 : void PrePaint();
95 : virtual void Paint(const Rectangle& rRect, ::sd::Window* pWin);
96 :
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
101 : are updated as well.
102 :
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>
107 : @param rPos
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).
112 : @param rSize
113 : The new size in pixel.
114 : */
115 : // virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
116 :
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
120 : sliders.
121 : */
122 : virtual void ArrangeGUIElements (void);
123 :
124 : void HidePage();
125 :
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);
131 :
132 : virtual void Resize (void);
133 :
134 : void ShowMousePosInfo(const Rectangle& rRect, ::sd::Window* pWin);
135 :
136 : virtual void AddWindow(::sd::Window* pWin);
137 : virtual void RemoveWindow(::sd::Window* pWin);
138 :
139 : virtual void ChangeEditMode (EditMode eMode, bool bIsLayerModeActive);
140 :
141 : virtual void SetZoom( long nZoom );
142 : virtual void SetZoomRect( const Rectangle& rZoomRect );
143 :
144 : void InsertURLField(const String& rURL, const String& rText, const String& rTarget,
145 : const Point* pPos);
146 : void InsertURLButton(const String& rURL, const String& rText, const String& rTarget,
147 : const Point* pPos);
148 :
149 : virtual void SetUIUnit(FieldUnit eUnit);
150 :
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;
159 :
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>
169 : */
170 : void GetModeSwitchingMenuState (SfxItemSet &rSet);
171 : void GetAttrState(SfxItemSet& rSet);
172 : void GetSnapItemState(SfxItemSet& rSet);
173 :
174 : void GetState (SfxItemSet& rSet);
175 : void Execute (SfxRequest& rReq);
176 :
177 : void ExecStatusBar(SfxRequest& rReq);
178 : void GetStatusBarState(SfxItemSet& rSet);
179 :
180 : void ExecOptionsBar(SfxRequest& rReq);
181 : void GetOptionsBarState(SfxItemSet& rSet);
182 :
183 : void ExecRuler(SfxRequest& rReq);
184 : void GetRulerState(SfxItemSet& rSet);
185 :
186 : void ExecFormText(SfxRequest& rReq);
187 : void GetFormTextState(SfxItemSet& rSet);
188 :
189 : void ExecAnimationWin(SfxRequest& rReq);
190 : void GetAnimationWinState(SfxItemSet& rSet);
191 :
192 : void ExecNavigatorWin(SfxRequest& rReq);
193 : void GetNavigatorWinState(SfxItemSet& rSet);
194 :
195 : void ExecutePropPanelAttr (SfxRequest& rReq);
196 : void GetStatePropPanelAttr(SfxItemSet& rSet);
197 :
198 : void ExecEffectWin(SfxRequest& rReq);
199 :
200 : void Update3DWindow();
201 : void AssignFrom3DWindow();
202 :
203 : void ExecGallery(SfxRequest& rReq);
204 : void GetGalleryState(SfxItemSet& rSet);
205 :
206 : void ExecBmpMask( SfxRequest& rReq );
207 : void GetBmpMaskState( SfxItemSet& rSet );
208 :
209 : void ExecIMap( SfxRequest& rReq );
210 : void GetIMapState( SfxItemSet& rSet );
211 :
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);
217 :
218 : void AttrExec (SfxRequest& rReq);
219 : void AttrState (SfxItemSet& rSet);
220 :
221 : void ExecChar(SfxRequest& rReq);
222 :
223 : void ExecuteAnnotation (SfxRequest& rRequest);
224 : void GetAnnotationState (SfxItemSet& rItemSet);
225 :
226 : void StartRulerDrag (
227 : const Ruler& rRuler,
228 : const MouseEvent& rMEvt);
229 :
230 : virtual sal_uInt16 PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False );
231 :
232 13 : PageKind GetPageKind() { return mePageKind; }
233 :
234 0 : Point GetMousePos() { return maMousePos; }
235 : sal_Bool IsMousePosFreezed() { return mbMousePosFreezed; }
236 0 : void SetMousePosFreezed( sal_Bool bIn ) { mbMousePosFreezed = bIn; }
237 :
238 86 : EditMode GetEditMode() const { return meEditMode; }
239 276 : virtual SdPage* GetActualPage() { return mpActualPage; }
240 :
241 : /// inherited from sd::ViewShell
242 : virtual SdPage* getCurrentPage() const;
243 :
244 : void ResetActualPage();
245 : void ResetActualLayer();
246 : sal_Bool SwitchPage(sal_uInt16 nPage);
247 : sal_Bool IsSwitchPageAllowed() const;
248 :
249 : sal_Bool GotoBookmark(const String& rBookmark);
250 : void MakeVisible(const Rectangle& rRect, ::Window& rWin);
251 :
252 : virtual void ReadFrameViewData(FrameView* pView);
253 : virtual void WriteFrameViewData();
254 :
255 : virtual ErrCode DoVerb(long nVerb);
256 : virtual sal_Bool ActivateObject(SdrOle2Obj* pObj, long nVerb);
257 :
258 0 : void SetZoomOnPage( sal_Bool bZoom = sal_True ) { mbZoomOnPage = bZoom; }
259 0 : sal_Bool IsZoomOnPage() { return mbZoomOnPage; }
260 : void CheckLineTo (SfxRequest& rReq);
261 : void SetChildWindowState( SfxItemSet& rSet );
262 :
263 : void UpdateIMapDlg( SdrObject* pObj );
264 :
265 : void LockInput();
266 : void UnlockInput();
267 0 : sal_Bool IsInputLocked() const { return mnLockCount > 0UL; }
268 :
269 0 : sal_uInt16 GetCurPageId() { return( maTabControl.GetCurPageId() ); }
270 :
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
273 : instead.
274 : */
275 : virtual void ShowUIControls (bool bVisible = true);
276 :
277 : void ScannerEvent( const ::com::sun::star::lang::EventObject& rEventObject );
278 :
279 : bool IsLayerModeActive (void) const;
280 :
281 0 : sal_uInt16* GetSlotArray() const { return mpSlotArray; }
282 :
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 );
287 :
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 );
290 :
291 : virtual void VisAreaChanged(const Rectangle& rRect);
292 :
293 : /** Create an accessible object representing the specified window.
294 : @param pWindow
295 : The returned object makes the document displayed in this window
296 : accessible.
297 : @return
298 : Returns an <type>AccessibleDrawDocumentView</type> object.
299 : */
300 : virtual ::com::sun::star::uno::Reference<
301 : ::com::sun::star::accessibility::XAccessible>
302 : CreateAccessibleDocumentView (::sd::Window* pWindow);
303 :
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
306 : administrator.
307 : @return
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.
311 : */
312 : virtual int GetTabLayerCount (void) const;
313 :
314 : /** Return the numerical id of the currently active layer as seen by the
315 : layer tab control.
316 : @return
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).
320 : */
321 : virtual int GetActiveTabLayerIndex (void) const;
322 :
323 : /** Set the active layer at the layer tab control and update the control
324 : accordingly to reflect the change on screen.
325 : @param nId
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.
330 : */
331 : virtual void SetActiveTabLayerIndex (int nId);
332 :
333 : /** Return a pointer to the tab control for pages.
334 : */
335 : TabControl* GetPageTabControl (void);
336 :
337 : /** Return a pointer to the tab control for layers.
338 : */
339 : LayerTabBar* GetLayerTabControl (void);
340 :
341 : /** Renames the given slide using an SvxNameDialog
342 :
343 : @param nPageId the index of the page in the SdTabControl.
344 : @param rName the new name of the slide.
345 :
346 : @return false, if the new name is invalid for some reason.
347 :
348 : <p>Implemented in <code>drviews8.cxx</code>.</p>
349 : */
350 : bool RenameSlide( sal_uInt16 nPageId, const String & rName );
351 :
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 );
354 :
355 : virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController (void);
356 :
357 3281 : DrawView* GetDrawView() const { return mpDrawView; }
358 :
359 : /** Relocation to a new parent window is not supported for DrawViewShell
360 : objects so this method always returns <FALSE/>.
361 : */
362 : virtual bool RelocateToParentWindow (::Window* pParentWindow);
363 :
364 : ::rtl::OUString GetSidebarContextName (void) const;
365 :
366 : protected:
367 : DrawView* mpDrawView;
368 : SdPage* mpActualPage;
369 : Rectangle maMarkRect;
370 : Point maMousePos;
371 : sal_Bool mbMousePosFreezed;
372 : TabControl maTabControl;
373 : EditMode meEditMode;
374 : PageKind mePageKind;
375 : sal_Bool mbZoomOnPage;
376 : sal_Bool mbIsRulerDrag;
377 : sal_uLong mnLockCount;
378 : Timer maCloseTimer;
379 : sal_Bool mbReadOnly;
380 : sal_uInt16* mpSlotArray;
381 :
382 : static sal_Bool mbPipette;
383 :
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* );
389 :
390 : void DeleteActualPage();
391 : void DeleteActualLayer();
392 :
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);
398 :
399 : void SetupPage( Size &rSize, long nLeft, long nRight, long nUpper, long nLower,
400 : sal_Bool bSize, sal_Bool bMargin, sal_Bool bScaleAll );
401 :
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 );
407 :
408 : void GetMenuStateSel(SfxItemSet& rSet);
409 :
410 : private:
411 : void ShowSlideShow(SfxRequest& rReq);
412 : /** This flag controls whether the layer mode is active, i.e. the layer
413 : dialog is visible.
414 : */
415 : bool mbIsLayerModeActive;
416 :
417 : /** This item contains the clipboard formats of the current clipboard
418 : content that are supported both by that content and by the
419 : DrawViewShell.
420 : */
421 : ::std::auto_ptr<SvxClipboardFmtItem> mpCurrentClipboardFormats;
422 :
423 : /** On some occasions it is necessary to make SwitchPage calls
424 : asynchronously.
425 : */
426 : tools::AsynchronousCall maAsynchronousSwitchPageCall;
427 :
428 : /** This flag is used to prevent nested calls to SwitchPage().
429 : */
430 : bool mbIsInSwitchPage;
431 :
432 : RotateTransliteration m_aRotateCase;
433 :
434 : /** Listen for selection changes and broadcast context changes for the sidebar.
435 : */
436 : ::rtl::Reference<svx::sidebar::SelectionChangeHandler> mpSelectionChangeHandler;
437 :
438 : void Construct (DrawDocShell* pDocSh, PageKind ePageKind);
439 :
440 : /** Depending on the given request create a new page or duplicate an
441 : existing one. See ViewShell::CreateOrDuplicatePage() for more
442 : information.
443 : */
444 : virtual SdPage* CreateOrDuplicatePage (
445 : SfxRequest& rRequest,
446 : PageKind ePageKind,
447 : SdPage* pPage,
448 : const sal_Int32 nInsertPosition = -1);
449 :
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;
454 :
455 : virtual void Notify (SfxBroadcaster& rBC, const SfxHint& rHint);
456 :
457 : /** Stop a running slide show. The frame the show is running in is
458 : destroyed if
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.
461 : @param bCloseFrame
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
465 : and the frame.
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
469 : call.
470 : */
471 : void StopSlideShow (bool bCloseFrame);
472 :
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.
477 : @param rPageView
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
481 : context menu.
482 : @param rMouseLocation
483 : The mouse location defines the location at which to display the
484 : context menu.
485 : */
486 : void ShowSnapLineContextMenu (
487 : SdrPageView& rPageView,
488 : const sal_uInt16 nSnapLineIndex,
489 : const Point& rMouseLocation);
490 :
491 : using ViewShell::Notify;
492 :
493 : ::std::auto_ptr< AnnotationManager > mpAnnotationManager;
494 : ::std::auto_ptr< ViewOverlayManager > mpViewOverlayManager;
495 : };
496 :
497 :
498 : } // end of namespace sd
499 :
500 : #endif
501 :
502 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|