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