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