xref: /aoo42x/main/sd/source/ui/inc/DrawViewShell.hxx (revision 0deba7fb)
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 
237 	PageKind	    GetPageKind() { return mePageKind; }
238 
239 	Point		    GetMousePos() { return maMousePos; }
240 	sal_Bool 		    IsMousePosFreezed() { return mbMousePosFreezed; }
241 	void 		    SetMousePosFreezed( sal_Bool bIn ) { mbMousePosFreezed = bIn; }
242 
243 	EditMode	    GetEditMode() const { return meEditMode; }
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 //IAccessibility2 Implementation 2009-----
256 	//Solution: realize multi-selection of objects ,If object is marked ,
257 	//the corresponding entry is set true ,else the corresponding entry is set false .
258 	void                    FreshNavigatrEntry();
259 	void                    FreshNavigatrTree();
260 //-----IAccessibility2 Implementation 2009
261 	void            MakeVisible(const Rectangle& rRect, ::Window& rWin);
262 
263 	virtual void    ReadFrameViewData(FrameView* pView);
264 	virtual void    WriteFrameViewData();
265 
266 	virtual ErrCode DoVerb(long nVerb);
267 	virtual sal_Bool    ActivateObject(SdrOle2Obj* pObj, long nVerb);
268 
269 	void		    SetZoomOnPage( sal_Bool bZoom = sal_True ) { mbZoomOnPage = bZoom; }
270 	sal_Bool		    IsZoomOnPage() { return mbZoomOnPage; }
271 	void		    CheckLineTo (SfxRequest& rReq);
272 	void		    FuTemp01(SfxRequest& rReq);
273 	void		    FuTemp02(SfxRequest& rReq);
274 	void		    FuTemp03(SfxRequest& rReq);
275 	void		    FuTemp04(SfxRequest& rReq);
276 	void		    SetChildWindowState( SfxItemSet& rSet );
277 
278 	void		    UpdateIMapDlg( SdrObject* pObj );
279 
280 	void		    LockInput();
281 	void		    UnlockInput();
282 	sal_Bool		    IsInputLocked() const { return mnLockCount > 0UL; }
283 
284 	sal_uInt16		    GetCurPageId() { return( maTabControl.GetCurPageId() ); }
285 
286     /** Show controls of the UI or hide them, depending on the given flag.
287         Do not call this method directly.  Call the method at ViewShellBase
288         instead.
289     */
290 	virtual void ShowUIControls (bool bVisible = true);
291 
292 	void		    ScannerEvent( const ::com::sun::star::lang::EventObject& rEventObject );
293 
294 	bool IsLayerModeActive (void) const;
295 
296 	sal_uInt16*	    	GetSlotArray() const { return mpSlotArray; }
297 
298 	virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
299                                     ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer );
300 	virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper,
301                                     ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer );
302 
303     virtual void    WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
304     virtual void    ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
305 
306 	virtual void    VisAreaChanged(const Rectangle& rRect);
307 
308     /** Create an accessible object representing the specified window.
309 	    @param pWindow
310 	        The returned object makes the document displayed in this window
311 	        accessible.
312         @return
313 	        Returns an <type>AccessibleDrawDocumentView</type> object.
314    */
315     virtual ::com::sun::star::uno::Reference<
316         ::com::sun::star::accessibility::XAccessible>
317         CreateAccessibleDocumentView (::sd::Window* pWindow);
318 
319     /** Return the number of layers managed by the layer tab control.  This
320         will usually differ from the number of layers managed by the layer
321         administrator.
322         @return
323             The number of layers managed by the layer tab control.  The
324             returned value is independent of whether the layer modus is
325             currently active and the tab control is visible.
326     */
327     virtual int GetTabLayerCount (void) const;
328 
329     /** Return the numerical id of the currently active layer as seen by the
330         layer tab control.
331         @return
332             The returned id is a number between zero (inclusive) and the
333             number of layers as returned by the
334             <member>GetTabLayerCount</member> method (exclusive).
335     */
336     virtual int GetActiveTabLayerIndex (void) const;
337 
338     /** Set the active layer at the layer tab control and update the control
339         accordingly to reflect the change on screen.
340         @param nId
341             The id is expected to be a number between zero (inclusive) and
342             the number of layers as returned by the
343             <member>GetTabLayerCount</member> method (exclusive).  Note that
344             Invalid values are ignored.  No excpetion is thrown in that case.
345     */
346     virtual void SetActiveTabLayerIndex (int nId);
347 
348     /** Return a pointer to the tab control for pages.
349     */
350 	TabControl* GetPageTabControl (void);
351 
352     /** Return a pointer to the tab control for layers.
353     */
354 	LayerTabBar* GetLayerTabControl (void);
355 
356     /** Renames the given slide using an SvxNameDialog
357 
358         @param nPageId the index of the page in the SdTabControl.
359         @param rName the new name of the slide.
360 
361         @return false, if the new name is invalid for some reason.
362 
363         <p>Implemented in <code>drviews8.cxx</code>.</p>
364      */
365     bool RenameSlide( sal_uInt16 nPageId, const String & rName );
366 
367 	/** modifies the given layer with the given values */
368 	void ModifyLayer( SdrLayer* pLayer, const String& rLayerName, const String& rLayerTitle, const String& rLayerDesc, bool bIsVisible, bool bIsLocked, bool bIsPrintable );
369 
370     virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController (void);
371 
372 	DrawView*	GetDrawView() const { return mpDrawView; }
373 
374     /** Relocation to a new parent window is not supported for DrawViewShell
375         objects so this method always returns <FALSE/>.
376     */
377     virtual bool RelocateToParentWindow (::Window* pParentWindow);
378 
379     ::rtl::OUString GetSidebarContextName (void) const;
380 
381 //IAccessibility2 Implementation 2009-----
382 	//move this method to ViewShell.
383 	//void	NotifyAccUpdate();
384 //-----IAccessibility2 Implementation 2009
385 protected:
386 	DrawView*		mpDrawView;
387 	SdPage* 		mpActualPage;
388 	Rectangle		maMarkRect;
389 	Point			maMousePos;
390 	sal_Bool			mbMousePosFreezed;
391 	TabControl		maTabControl;
392 	EditMode		meEditMode;
393 	PageKind		mePageKind;
394 	sal_Bool			mbZoomOnPage;
395 	sal_Bool			mbIsRulerDrag;
396 	sal_uLong			mnLockCount;
397 	Timer			maCloseTimer;
398 	sal_Bool 			mbReadOnly;
399 	sal_uInt16*			mpSlotArray;
400 
401     static sal_Bool 	mbPipette;
402 
403                 	DECL_LINK( ClipboardChanged, TransferableDataHelper* );
404                 	DECL_LINK( CloseHdl, Timer* pTimer );
405 	                DECL_LINK( TabSplitHdl, TabBar * );
406 	                DECL_LINK( NameObjectHdl, AbstractSvxNameDialog* );
407 	                DECL_LINK( RenameSlideHdl, AbstractSvxNameDialog* );
408 
409 	void	        DeleteActualPage();
410 	void	        DeleteActualLayer();
411 
412 	virtual SvxRuler* CreateHRuler(::sd::Window* pWin, sal_Bool bIsFirst);
413 	virtual SvxRuler* CreateVRuler(::sd::Window* pWin);
414 	virtual void    UpdateHRuler();
415 	virtual void    UpdateVRuler();
416 	virtual long    GetHCtrlWidth();
417 	virtual void    SetZoomFactor(const Fraction& rZoomX, const Fraction& rZoomY);
418 	virtual Size    GetOptimalSizePixel() const;
419 
420 	void            SetupPage( Size &rSize, long nLeft, long nRight, long nUpper, long nLower,
421 					           sal_Bool bSize, sal_Bool bMargin, sal_Bool bScaleAll );
422 
423 	sal_uInt16	        GetIdBySubId( sal_uInt16 nSId );
424 	void	        MapSlot( sal_uInt16 nSId );
425 	void	        UpdateToolboxImages( SfxItemSet &rSet, sal_Bool bPermanent = sal_True );
426 	sal_uInt16	        GetMappedSlot( sal_uInt16 nSId );
427 	sal_uInt16	        GetArrayId( sal_uInt16 nSId );
428 
429 	void	        GetMenuStateSel(SfxItemSet& rSet);
430 
431 private:
432     /** This flag controls whether the layer mode is active, i.e. the layer
433         dialog is visible.
434     */
435 	bool mbIsLayerModeActive;
436 
437     /** This item contains the clipboard formats of the current clipboard
438         content that are supported both by that content and by the
439         DrawViewShell.
440     */
441     ::std::auto_ptr<SvxClipboardFmtItem> mpCurrentClipboardFormats;
442 
443     /** On some occasions it is necessary to make SwitchPage calls
444         asynchronously.
445     */
446     tools::AsynchronousCall maAsynchronousSwitchPageCall;
447 
448     /** This flag is used to prevent nested calls to SwitchPage().
449     */
450     bool mbIsInSwitchPage;
451 
452     /** Listen for selection changes and broadcast context changes for the sidebar.
453     */
454     ::rtl::Reference<svx::sidebar::SelectionChangeHandler> mpSelectionChangeHandler;
455 
456 	void Construct (DrawDocShell* pDocSh, PageKind ePageKind);
457 
458     /** Depending on the given request create a new page or duplicate an
459         existing one.  See ViewShell::CreateOrDuplicatePage() for more
460         information.
461     */
462     virtual SdPage* CreateOrDuplicatePage (
463         SfxRequest& rRequest,
464         PageKind ePageKind,
465         SdPage* pPage,
466         const sal_Int32 nInsertPosition = -1);
467 
468 	::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager >	mxScannerManager;
469 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >		mxScannerListener;
470 	TransferableClipboardListener*                                                  mpClipEvtLstnr;
471 	sal_Bool			                                                                mbPastePossible;
472 
473 	virtual void Notify (SfxBroadcaster& rBC, const SfxHint& rHint);
474 
475     /** Stop a running slide show.  The frame the show is running in is
476         destroyed if
477         a) it is running in its own frame, i.e. is a full screen show and
478         b) the given flag bCloseFrame is true.
479         @param bCloseFrame
480             Be carefull with this flag when stopping a full screen show.
481             When called from the destructor the flag has to be <FALSE/> or
482             otherwise we run into a loop of calls to destructors of the view
483             and the frame.
484             When called from other places the flag should be <TRUE/> so that
485             not an empty frame remains. When called with <TRUE/> it is the
486             responsibility of the caller to avoid an illegal reentrant
487             call.
488     */
489     void StopSlideShow (bool bCloseFrame);
490 
491     /** Show the context menu for snap lines and points.  Because snap lines
492         can not be selected the index of the snap line/point for which the
493         popup menu is opened has to be passed to the processing slot
494         handlers.  This can be done only by manually showing the popup menu.
495         @param rPageView
496             The page view is used to access the help lines.
497         @param nSnapLineIndex
498             Index of the snap line or snap point for which to show the
499             context menu.
500         @param rMouseLocation
501             The mouse location defines the location at which to display the
502             context menu.
503     */
504     void ShowSnapLineContextMenu (
505         SdrPageView& rPageView,
506         const sal_uInt16 nSnapLineIndex,
507         const Point& rMouseLocation);
508 
509 	using ViewShell::Notify;
510 
511 //IAccessibility2 Implementation 2009-----
512 	//const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & GetForms() const;
513 //-----IAccessibility2 Implementation 2009
514 
515 	::std::auto_ptr< AnnotationManager > mpAnnotationManager;
516 	::std::auto_ptr< ViewOverlayManager > mpViewOverlayManager;
517 };
518 
519 
520 } // end of namespace sd
521 
522 #endif
523