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 INCLUDED_SD_SOURCE_UI_INC_DRAWVIEWSHELL_HXX
21 : #define INCLUDED_SD_SOURCE_UI_INC_DRAWVIEWSHELL_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_OVERRIDE();
69 :
70 0 : 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) SAL_OVERRIDE;
91 :
92 : virtual void Shutdown (void) SAL_OVERRIDE;
93 :
94 : void PrePaint() SAL_OVERRIDE;
95 : virtual void Paint(const Rectangle& rRect, ::sd::Window* pWin) SAL_OVERRIDE;
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) SAL_OVERRIDE;
123 :
124 : void HidePage();
125 :
126 : virtual sal_Bool KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin) SAL_OVERRIDE;
127 : virtual void MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin) SAL_OVERRIDE;
128 : virtual void MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin) SAL_OVERRIDE;
129 : virtual void MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin) SAL_OVERRIDE;
130 : virtual void Command(const CommandEvent& rCEvt, ::sd::Window* pWin) SAL_OVERRIDE;
131 :
132 : virtual void Resize (void) SAL_OVERRIDE;
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 ) SAL_OVERRIDE;
142 : virtual void SetZoomRect( const Rectangle& rZoomRect ) SAL_OVERRIDE;
143 :
144 : void InsertURLField(const OUString& rURL, const OUString& rText, const OUString& rTarget,
145 : const Point* pPos);
146 : void InsertURLButton(const OUString& rURL, const OUString& rText, const OUString& rTarget,
147 : const Point* pPos);
148 :
149 : virtual void SetUIUnit(FieldUnit eUnit) SAL_OVERRIDE;
150 :
151 : void SelectionHasChanged();
152 : void ModelHasChanged();
153 : virtual void Activate(bool bIsMDIActivate) SAL_OVERRIDE;
154 : virtual void Deactivate(bool IsMDIActivate) SAL_OVERRIDE;
155 : virtual void UIActivating( SfxInPlaceClient* ) SAL_OVERRIDE;
156 : virtual void UIDeactivated( SfxInPlaceClient* ) SAL_OVERRIDE;
157 : virtual OUString GetSelectionText( bool bCompleteWords = 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 bool PrepareClose( sal_Bool bUI = sal_True ) SAL_OVERRIDE;
231 :
232 0 : 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 0 : EditMode GetEditMode() const { return meEditMode; }
239 0 : virtual SdPage* GetActualPage() SAL_OVERRIDE { return mpActualPage; }
240 :
241 : /// inherited from sd::ViewShell
242 : virtual SdPage* getCurrentPage() const SAL_OVERRIDE;
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 OUString& rBookmark);
250 : //Realize multi-selection of objects, If object is marked, the
251 : //corresponding entry is set true, else the corresponding entry is set
252 : //false.
253 : void FreshNavigatrEntry();
254 : void FreshNavigatrTree();
255 : void MakeVisible(const Rectangle& rRect, ::Window& rWin);
256 :
257 : virtual void ReadFrameViewData(FrameView* pView) SAL_OVERRIDE;
258 : virtual void WriteFrameViewData() SAL_OVERRIDE;
259 :
260 : virtual ErrCode DoVerb(long nVerb) SAL_OVERRIDE;
261 : virtual sal_Bool ActivateObject(SdrOle2Obj* pObj, long nVerb) SAL_OVERRIDE;
262 :
263 0 : void SetZoomOnPage( sal_Bool bZoom = sal_True ) { mbZoomOnPage = bZoom; }
264 0 : sal_Bool IsZoomOnPage() { return mbZoomOnPage; }
265 : void CheckLineTo (SfxRequest& rReq);
266 : void SetChildWindowState( SfxItemSet& rSet );
267 :
268 : void UpdateIMapDlg( SdrObject* pObj );
269 :
270 : void LockInput();
271 : void UnlockInput();
272 0 : sal_Bool IsInputLocked() const { return mnLockCount > 0UL; }
273 :
274 0 : sal_uInt16 GetCurPageId() { return( maTabControl.GetCurPageId() ); }
275 :
276 : /** Show controls of the UI or hide them, depending on the given flag.
277 : Do not call this method directly. Call the method at ViewShellBase
278 : instead.
279 : */
280 : virtual void ShowUIControls (bool bVisible = true) SAL_OVERRIDE;
281 :
282 : void ScannerEvent( const ::com::sun::star::lang::EventObject& rEventObject );
283 :
284 : bool IsLayerModeActive (void) const;
285 :
286 0 : sal_uInt16* GetSlotArray() const { return mpSlotArray; }
287 :
288 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
289 : ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer ) SAL_OVERRIDE;
290 : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper,
291 : ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer ) SAL_OVERRIDE;
292 :
293 : virtual void WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False ) SAL_OVERRIDE;
294 : virtual void ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False ) SAL_OVERRIDE;
295 :
296 : virtual void VisAreaChanged(const Rectangle& rRect) SAL_OVERRIDE;
297 :
298 : /** Create an accessible object representing the specified window.
299 : @param pWindow
300 : The returned object makes the document displayed in this window
301 : accessible.
302 : @return
303 : Returns an <type>AccessibleDrawDocumentView</type> object.
304 : */
305 : virtual ::com::sun::star::uno::Reference<
306 : ::com::sun::star::accessibility::XAccessible>
307 : CreateAccessibleDocumentView (::sd::Window* pWindow) SAL_OVERRIDE;
308 :
309 : /** Return the number of layers managed by the layer tab control. This
310 : will usually differ from the number of layers managed by the layer
311 : administrator.
312 : @return
313 : The number of layers managed by the layer tab control. The
314 : returned value is independent of whether the layer modus is
315 : currently active and the tab control is visible.
316 : */
317 : virtual int GetTabLayerCount (void) const;
318 :
319 : /** Return the numerical id of the currently active layer as seen by the
320 : layer tab control.
321 : @return
322 : The returned id is a number between zero (inclusive) and the
323 : number of layers as returned by the
324 : <member>GetTabLayerCount</member> method (exclusive).
325 : */
326 : virtual int GetActiveTabLayerIndex (void) const;
327 :
328 : /** Set the active layer at the layer tab control and update the control
329 : accordingly to reflect the change on screen.
330 : @param nId
331 : The id is expected to be a number between zero (inclusive) and
332 : the number of layers as returned by the
333 : <member>GetTabLayerCount</member> method (exclusive). Note that
334 : Invalid values are ignored. No excpetion is thrown in that case.
335 : */
336 : virtual void SetActiveTabLayerIndex (int nId);
337 :
338 : /** Return a pointer to the tab control for pages.
339 : */
340 : TabControl* GetPageTabControl (void);
341 :
342 : /** Return a pointer to the tab control for layers.
343 : */
344 : LayerTabBar* GetLayerTabControl (void);
345 :
346 : /** Renames the given slide using an SvxNameDialog
347 :
348 : @param nPageId the index of the page in the SdTabControl.
349 : @param rName the new name of the slide.
350 :
351 : @return false, if the new name is invalid for some reason.
352 :
353 : <p>Implemented in <code>drviews8.cxx</code>.</p>
354 : */
355 : bool RenameSlide( sal_uInt16 nPageId, const OUString & rName );
356 :
357 : /** modifies the given layer with the given values */
358 : void ModifyLayer( SdrLayer* pLayer, const OUString& rLayerName, const OUString& rLayerTitle, const OUString& rLayerDesc, bool bIsVisible, bool bIsLocked, bool bIsPrintable );
359 :
360 : virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController (void) SAL_OVERRIDE;
361 :
362 0 : DrawView* GetDrawView() const { return mpDrawView; }
363 :
364 : /** Relocation to a new parent window is not supported for DrawViewShell
365 : objects so this method always returns <FALSE/>.
366 : */
367 : virtual bool RelocateToParentWindow (::Window* pParentWindow) SAL_OVERRIDE;
368 :
369 : OUString GetSidebarContextName (void) const;
370 :
371 : //move this method to ViewShell.
372 : //void NotifyAccUpdate();
373 : protected:
374 : DrawView* mpDrawView;
375 : SdPage* mpActualPage;
376 : Rectangle maMarkRect;
377 : Point maMousePos;
378 : sal_Bool mbMousePosFreezed;
379 : TabControl maTabControl;
380 : EditMode meEditMode;
381 : PageKind mePageKind;
382 : sal_Bool mbZoomOnPage;
383 : sal_Bool mbIsRulerDrag;
384 : sal_uLong mnLockCount;
385 : sal_Bool mbReadOnly;
386 : sal_uInt16* mpSlotArray;
387 :
388 : static sal_Bool mbPipette;
389 :
390 : DECL_LINK( ClipboardChanged, TransferableDataHelper* );
391 : DECL_LINK( TabSplitHdl, TabBar * );
392 : DECL_LINK( NameObjectHdl, AbstractSvxNameDialog* );
393 : DECL_LINK( RenameSlideHdl, AbstractSvxNameDialog* );
394 :
395 : void DeleteActualPage();
396 : void DeleteActualLayer();
397 :
398 : virtual SvxRuler* CreateHRuler(::sd::Window* pWin, sal_Bool bIsFirst) SAL_OVERRIDE;
399 : virtual SvxRuler* CreateVRuler(::sd::Window* pWin) SAL_OVERRIDE;
400 : virtual void UpdateHRuler() SAL_OVERRIDE;
401 : virtual void UpdateVRuler() SAL_OVERRIDE;
402 : virtual void SetZoomFactor(const Fraction& rZoomX, const Fraction& rZoomY) SAL_OVERRIDE;
403 :
404 : void SetupPage( Size &rSize, long nLeft, long nRight, long nUpper, long nLower,
405 : sal_Bool bSize, sal_Bool bMargin, sal_Bool bScaleAll );
406 :
407 : sal_uInt16 GetIdBySubId( sal_uInt16 nSId );
408 : void MapSlot( sal_uInt16 nSId );
409 : void UpdateToolboxImages( SfxItemSet &rSet, sal_Bool bPermanent = sal_True );
410 : sal_uInt16 GetMappedSlot( sal_uInt16 nSId );
411 : sal_uInt16 GetArrayId( sal_uInt16 nSId );
412 :
413 : void GetMenuStateSel(SfxItemSet& rSet);
414 :
415 : private:
416 : void ShowSlideShow(SfxRequest& rReq);
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 : /** Listen for selection changes and broadcast context changes for the sidebar.
440 : */
441 : ::rtl::Reference<svx::sidebar::SelectionChangeHandler> mpSelectionChangeHandler;
442 :
443 : void Construct (DrawDocShell* pDocSh, PageKind ePageKind);
444 :
445 : /** Depending on the given request create a new page or duplicate an
446 : existing one. See ViewShell::CreateOrDuplicatePage() for more
447 : information.
448 : */
449 : virtual SdPage* CreateOrDuplicatePage (
450 : SfxRequest& rRequest,
451 : PageKind ePageKind,
452 : SdPage* pPage,
453 : const sal_Int32 nInsertPosition = -1) SAL_OVERRIDE;
454 :
455 : ::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager2 > mxScannerManager;
456 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > mxScannerListener;
457 : TransferableClipboardListener* mpClipEvtLstnr;
458 : sal_Bool mbPastePossible;
459 :
460 : virtual void Notify (SfxBroadcaster& rBC, const SfxHint& rHint) SAL_OVERRIDE;
461 :
462 : /** Stop a running slide show. The frame the show is running in is
463 : destroyed if
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.
466 : @param bCloseFrame
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
470 : and the frame.
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
474 : call.
475 : */
476 : void StopSlideShow (bool bCloseFrame);
477 :
478 : /** Show the context menu for snap lines and points. Because snap lines
479 : can not be selected the index of the snap line/point for which the
480 : popup menu is opened has to be passed to the processing slot
481 : handlers. This can be done only by manually showing the popup menu.
482 : @param rPageView
483 : The page view is used to access the help lines.
484 : @param nSnapLineIndex
485 : Index of the snap line or snap point for which to show the
486 : context menu.
487 : @param rMouseLocation
488 : The mouse location defines the location at which to display the
489 : context menu.
490 : */
491 : void ShowSnapLineContextMenu (
492 : SdrPageView& rPageView,
493 : const sal_uInt16 nSnapLineIndex,
494 : const Point& rMouseLocation);
495 :
496 : using ViewShell::Notify;
497 :
498 : ::std::auto_ptr< AnnotationManager > mpAnnotationManager;
499 : ::std::auto_ptr< ViewOverlayManager > mpViewOverlayManager;
500 : };
501 :
502 :
503 : } // end of namespace sd
504 :
505 : #endif
506 :
507 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|