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