xref: /AOO41X/main/sfx2/source/inc/workwin.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SFXWORKWIN_HXX
28 #define _SFXWORKWIN_HXX
29 
30 #include <vector>
31 #include <deque>
32 #include <com/sun/star/frame/XDispatch.hpp>
33 #include <com/sun/star/frame/XFrame.hpp>
34 #ifndef _COM_SUN_STAR_UI_XUILEMENT_HPP_
35 #include <com/sun/star/ui/XUIElement.hpp>
36 #endif
37 #include <com/sun/star/task/XStatusIndicator.hpp>
38 #include <com/sun/star/frame/XLayoutManagerListener.hpp>
39 #include <cppuhelper/weak.hxx>
40 #include <cppuhelper/propshlp.hxx>
41 
42 #define _SVSTDARR_USHORTS
43 #include <svl/svstdarr.hxx>		// SvUShorts
44 #include <rtl/ustring.hxx>
45 #include <vos/mutex.hxx>
46 
47 #include <sfx2/sfx.hrc>
48 #include <sfx2/childwin.hxx>
49 #include <sfx2/shell.hxx>
50 #include <sfx2/minarray.hxx>
51 #include <sfx2/ctrlitem.hxx>
52 #include <sfx2/viewfrm.hxx>
53 
54 class SfxInPlaceEnv_Impl;
55 class SfxPlugInEnv_Impl;
56 class SfxSplitWindow;
57 class SfxWorkWindow;
58 
59 //====================================================================
60 // Dieser struct h"alt alle relevanten Informationen "uber Toolboxen bereit.
61 
62 struct SfxObjectBar_Impl
63 {
64     sal_uInt16        nId;   // Resource - und ConfigId der Toolbox
65     sal_uInt16        nMode; // spezielle Sichtbarkeitsflags
66     sal_uInt16        nPos;
67     sal_uInt16        nIndex;
68     sal_Bool      bDestroy;
69     String        aName;
70     SfxInterface* pIFace;
71 
72     SfxObjectBar_Impl() :
73         nId(0),
74         nMode(0),
75         bDestroy(sal_False),
76         pIFace(0)
77     {}
78 };
79 
80 //------------------------------------------------------------------------------
81 // Dieser struct h"alt alle relevanten Informationen "uber die Statuszeile bereit.
82 struct SfxStatBar_Impl
83 {
84 	sal_uInt16					nId;
85 	sal_Bool					bOn;
86 	sal_Bool					bTemp;
87 
88 	SfxStatBar_Impl() :
89 		nId(0),
90 		bOn(sal_True),
91 		bTemp(sal_False)
92 	{}
93 };
94 
95 //------------------------------------------------------------------------------
96 
97 #define CHILD_NOT_VISIBLE	0
98 #define CHILD_ACTIVE		1	// nicht durch HidePopups ausgeschaltet
99 #define CHILD_NOT_HIDDEN	2	// nicht durch HideChildWindow ausgeschaltet
100 #define CHILD_FITS_IN		4	// nicht zu gro\s f"ur OutputSize des parent
101 #define CHILD_VISIBLE		(CHILD_NOT_HIDDEN | CHILD_ACTIVE | CHILD_FITS_IN)
102 #define CHILD_ISVISIBLE		(CHILD_NOT_HIDDEN | CHILD_ACTIVE)
103 
104 struct SfxChild_Impl
105 {
106 	Window*             			pWin;
107 	Size                			aSize;
108 	SfxChildAlignment				eAlign;
109 	sal_uInt16							nVisible;
110 	sal_Bool							bResize;
111 	sal_Bool							bCanGetFocus;
112 	sal_Bool							bSetFocus;
113 
114 	SfxChild_Impl( Window& rChild, const Size& rSize,
115 				   SfxChildAlignment eAlignment, sal_Bool bIsVisible ):
116 		pWin(&rChild), aSize(rSize), eAlign(eAlignment), bResize(sal_False),
117 		bCanGetFocus( sal_False ), bSetFocus( sal_False )
118 	{
119 		nVisible = bIsVisible ? CHILD_VISIBLE : CHILD_NOT_VISIBLE;
120 	}
121 };
122 
123 //--------------------------------------------------------------------
124 class SfxChildWinController_Impl : public SfxControllerItem
125 {
126 	SfxWorkWindow*	pWorkwin;
127 
128 	public:
129 					SfxChildWinController_Impl( sal_uInt16 nId, SfxWorkWindow *pWin );
130 	virtual void	StateChanged( sal_uInt16 nSID, SfxItemState eState,
131 							const SfxPoolItem* pState );
132 };
133 
134 struct SfxChildWin_Impl
135 {
136 	sal_uInt16							nSaveId;		// die ChildWindow-Id
137 	sal_uInt16							nInterfaceId;	// der aktuelle Context
138 	sal_uInt16							nId;        	// aktuelle Id
139 	SfxChildWindow* 				pWin;
140 	sal_Bool							bCreate;
141 	SfxChildWinInfo					aInfo;
142 	SfxChild_Impl*					pCli;			// != 0 bei direkten Children
143 	sal_uInt16							nVisibility;
144 	sal_Bool							bEnable;
145 	sal_Bool							bDisabled;
146 
147 	SfxChildWin_Impl( sal_uInt32 nID ) :
148 		nSaveId((sal_uInt16) (nID & 0xFFFF) ),
149 		nInterfaceId((sal_uInt16) (nID >> 16)),
150 		nId(nSaveId),
151 		pWin(0),
152 		bCreate(sal_False),
153 		pCli(0),
154 		nVisibility( sal_False ),
155 		bEnable( sal_True ),
156 		bDisabled( sal_False )
157 	{}
158 };
159 
160 enum SfxChildIdentifier
161 {
162 	SFX_CHILDWIN_STATBAR,
163 	SFX_CHILDWIN_OBJECTBAR,
164 	SFX_CHILDWIN_DOCKINGWINDOW,
165 	SFX_CHILDWIN_SPLITWINDOW
166 };
167 
168 enum SfxDockingConfig
169 {
170 	SFX_SETDOCKINGRECTS,
171 	SFX_ALIGNDOCKINGWINDOW,
172 	SFX_TOGGLEFLOATMODE,
173 	SFX_MOVEDOCKINGWINDOW
174 };
175 
176 DECL_PTRARRAY( SfxChildList_Impl, SfxChild_Impl*, 2, 2 )
177 DECL_PTRARRAY( SfxChildWindows_Impl, SfxChildWin_Impl*, 2, 2 )
178 
179 
180 struct SfxObjectBarList_Impl
181 {
182 	std::deque<SfxObjectBar_Impl>	aArr;
183 	sal_uInt16 					nAct;
184 
185 	SfxObjectBar_Impl 		operator[] ( sal_uInt16 n )
186 							{ return aArr[n]; }
187 	SfxObjectBar_Impl 		Actual()
188 							{ return aArr[nAct]; }
189 };
190 
191 struct SfxSplitWin_Impl
192 {
193 	SfxSplitWindow*			pSplitWin;
194 	SfxChildWindows_Impl* 	pChildWins;
195 };
196 
197 #define SFX_SPLITWINDOWS_LEFT 	0
198 #define SFX_SPLITWINDOWS_TOP  	2
199 #define SFX_SPLITWINDOWS_RIGHT 	1
200 #define SFX_SPLITWINDOWS_BOTTOM 3
201 #define SFX_SPLITWINDOWS_MAX 	4
202 
203 //--------------------------------------------------------------------
204 
205 class LayoutManagerListener : public ::com::sun::star::frame::XLayoutManagerListener,
206                               public ::com::sun::star::lang::XTypeProvider,
207                               public ::com::sun::star::lang::XComponent,
208                               public ::cppu::OWeakObject
209 {
210     public:
211         LayoutManagerListener( SfxWorkWindow* pWrkWin );
212         virtual ~LayoutManagerListener();
213 
214 	    SFX_DECL_XINTERFACE_XTYPEPROVIDER
215 
216 		void setFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
217 
218         //---------------------------------------------------------------------------------------------------------
219         //  XComponent
220 		//---------------------------------------------------------------------------------------------------------
221         virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
222         virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
223         virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
224 
225         //---------------------------------------------------------------------------------------------------------
226         //  XEventListener
227 		//---------------------------------------------------------------------------------------------------------
228 	    virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
229 
230 		//---------------------------------------------------------------------------------------------------------
231         // XLayoutManagerEventListener
232 		//---------------------------------------------------------------------------------------------------------
233         virtual void SAL_CALL layoutEvent( const ::com::sun::star::lang::EventObject& aSource, ::sal_Int16 eLayoutEvent, const ::com::sun::star::uno::Any& aInfo ) throw (::com::sun::star::uno::RuntimeException);
234 
235     private:
236         sal_Bool                                                                m_bHasFrame;
237         SfxWorkWindow*                                                          m_pWrkWin;
238         ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XFrame > m_xFrame;
239         rtl::OUString                                                           m_aLayoutManagerPropName;
240 };
241 
242 class SfxWorkWindow
243 {
244     friend class UIElementWrapper;
245     friend class LayoutManagerListener;
246 
247 protected:
248 	SvUShorts			  	aSortedList;
249 	SfxStatBar_Impl			aStatBar;
250     std::vector< SfxObjectBar_Impl > aObjBarList;
251 	Rectangle				aClientArea;
252     Rectangle               aUpperClientArea;
253 	SfxWorkWindow*			pParent;
254 	SfxSplitWindow*			pSplit[SFX_SPLITWINDOWS_MAX];
255 	SfxChildList_Impl*	  	pChilds;
256 	SfxChildWindows_Impl* 	pChildWins;
257 	SfxBindings*			pBindings;
258 	Window*					pWorkWin;
259 	SfxShell*				pConfigShell;
260 	Window*					pActiveChild;
261 	sal_uInt16					nUpdateMode;
262 	sal_uInt16					nChilds;
263 	sal_uInt16					nOrigMode;
264     sal_Bool                    bSorted : 1;
265     sal_Bool                    bDockingAllowed : 1;
266     sal_Bool                    bInternalDockingAllowed : 1;
267     sal_Bool                    bAllChildsVisible : 1;
268     sal_Bool                    bIsFullScreen : 1;
269     sal_Bool                    bShowStatusBar : 1;
270     sal_Int32               m_nLock;
271     rtl::OUString           m_aStatusBarResName;
272     rtl::OUString           m_aLayoutManagerPropName;
273     rtl::OUString           m_aTbxTypeName;
274     rtl::OUString           m_aProgressBarResName;
275     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xLayoutManagerListener;
276 
277 protected:
278 	void					CreateChildWin_Impl(SfxChildWin_Impl*,sal_Bool);
279 	void					RemoveChildWin_Impl(SfxChildWin_Impl*);
280 	void				  	Sort_Impl();
281 	void            		AlignChild_Impl( Window& rWindow, const Size& rNewSize,
282 									 SfxChildAlignment eAlign );
283 	SfxChild_Impl* 			FindChild_Impl( const Window& rWindow ) const;
284 	virtual sal_Bool			RequestTopToolSpacePixel_Impl( SvBorder aBorder );
285 	virtual Rectangle       GetTopRect_Impl();
286     SvBorder                Arrange_Impl();
287 	virtual void			SaveStatus_Impl(SfxChildWindow*, const SfxChildWinInfo&);
288     static sal_Bool         IsPluginMode( SfxObjectShell* pObjShell );
289 
290 public:
291 							SfxWorkWindow( Window *pWin, SfxBindings& rBindings, SfxWorkWindow* pParent = NULL);
292 	virtual					~SfxWorkWindow();
293     SystemWindow*           GetTopWindow() const;
294 	SfxBindings&			GetBindings()
295 							{ return *pBindings; }
296 	Window*					GetWindow() const
297 							{ return pWorkWin; }
298 	Rectangle				GetFreeArea( sal_Bool bAutoHide ) const;
299 	void					SetDockingAllowed(sal_Bool bSet)
300 							{ bDockingAllowed = bSet; }
301     void                    SetInternalDockingAllowed(sal_Bool bSet)
302                             { bInternalDockingAllowed = bSet; }
303 	sal_Bool					IsDockingAllowed() const
304 							{ return bDockingAllowed; }
305     sal_Bool                    IsInternalDockingAllowed() const
306                             { return bInternalDockingAllowed; }
307 	SfxWorkWindow*			GetParent_Impl() const
308 							{ return pParent; }
309 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >			CreateDispatch( const String& );
310 
311 	// Methoden f"ur alle Child-Fenster
312     void                    DataChanged_Impl( const DataChangedEvent& rDCEvt );
313 	void            		ReleaseChild_Impl( Window& rWindow );
314 	SfxChild_Impl*          RegisterChild_Impl( Window& rWindow, SfxChildAlignment eAlign, sal_Bool bCanGetFocus=sal_False );
315 	void					ShowChilds_Impl();
316 	void					HideChilds_Impl();
317 	void    				Close_Impl();
318 	sal_Bool    				PrepareClose_Impl();
319 	virtual void			ArrangeChilds_Impl( sal_Bool bForce = sal_True );
320 	void					DeleteControllers_Impl();
321     void                    SaveStatus_Impl();
322 	void 					HidePopups_Impl(sal_Bool bHide, sal_Bool bParent=sal_False, sal_uInt16 nId=0);
323 	void            		ConfigChild_Impl(SfxChildIdentifier,
324 											 SfxDockingConfig, sal_uInt16);
325 	void					MakeChildsVisible_Impl( sal_Bool bVis );
326 	void					ArrangeAutoHideWindows( SfxSplitWindow *pSplit );
327 	sal_Bool					IsAutoHideMode( const SfxSplitWindow *pSplit );
328     void                    EndAutoShow_Impl( Point aPos );
329     void                    SetFullScreen_Impl( sal_Bool bSet ) { bIsFullScreen = bSet; }
330     sal_Bool                    IsFullScreen_Impl() const { return bIsFullScreen; }
331 
332 	// Methoden f"ur Objectbars
333 	virtual void            UpdateObjectBars_Impl();
334 	void            		ResetObjectBars_Impl();
335 	void					SetObjectBar_Impl( sal_uInt16 nPos, sal_uInt32 nResId,
336 									SfxInterface *pIFace, const String* pName=0 );
337 	Window* 				GetObjectBar_Impl( sal_uInt16 nPos, sal_uInt32 nResId );
338 	bool    				KnowsObjectBar_Impl( sal_uInt16 nPos ) const;
339     sal_Bool                    IsVisible_Impl();
340     void                    MakeVisible_Impl( sal_Bool );
341 	void					SetObjectBarVisibility_Impl( sal_uInt16 nVis );
342 	sal_Bool					IsContainer_Impl() const;
343     void                    Lock_Impl( sal_Bool );
344 	void					NextObjectBar_Impl( sal_uInt16 nPos );
345 	sal_uInt16  				HasNextObjectBar_Impl( sal_uInt16 nPos, String* pStr=0 );
346     void                    SetObjectBarCustomizeMode_Impl( sal_Bool );
347 
348 	// Methoden f"ur ChildWindows
349 	void            		UpdateChildWindows_Impl();
350 	void					ResetChildWindows_Impl();
351 	void					SetChildWindowVisible_Impl( sal_uInt32, sal_Bool, sal_uInt16 );
352     void                    ToggleChildWindow_Impl(sal_uInt16,sal_Bool);
353 	sal_Bool					HasChildWindow_Impl(sal_uInt16);
354 	sal_Bool					KnowsChildWindow_Impl(sal_uInt16);
355     void                    ShowChildWindow_Impl(sal_uInt16, sal_Bool bVisible, sal_Bool bSetFocus);
356     void                    SetChildWindow_Impl(sal_uInt16, sal_Bool bOn, sal_Bool bSetFocus);
357 	SfxChildWindow* 		GetChildWindow_Impl(sal_uInt16);
358 	virtual void			InitializeChild_Impl(SfxChildWin_Impl*);
359 	SfxSplitWindow*			GetSplitWindow_Impl(SfxChildAlignment);
360 
361 	sal_Bool                    IsVisible_Impl( sal_uInt16 nMode ) const;
362 	void 					DisableChildWindow_Impl( sal_uInt16 nId, sal_Bool bDisable );
363 	sal_Bool					IsFloating( sal_uInt16 nId );
364 	void 					ChangeWindow_Impl( Window *pNew );
365 	void					SetActiveChild_Impl( Window *pChild );
366 	Window*					GetActiveChild_Impl();
367 	virtual sal_Bool			ActivateNextChild_Impl( sal_Bool bForward = sal_True );
368     bool                    AllowChildWindowCreation_Impl( const SfxChildWin_Impl& i_rCW ) const;
369 
370 	// Methoden f"ur StatusBar
371     void                    SetTempStatusBar_Impl( sal_Bool bSet );
372 	void					ResetStatusBar_Impl();
373 	void					SetStatusBar_Impl(sal_uInt32 nResId, SfxShell *pShell, SfxBindings& );
374 	void					UpdateStatusBar_Impl();
375     ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > GetStatusIndicator();
376     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrameInterface();
377 };
378 
379 class SfxFrameWorkWin_Impl : public SfxWorkWindow
380 {
381     SfxFrame*           pMasterFrame;
382     SfxFrame*           pFrame;
383 public:
384                         SfxFrameWorkWin_Impl( Window* pWin, SfxFrame* pFrm, SfxFrame* pMaster );
385 	virtual void        ArrangeChilds_Impl( sal_Bool bForce = sal_True );
386 	virtual void        UpdateObjectBars_Impl();
387 	virtual Rectangle   GetTopRect_Impl();
388 };
389 
390 
391 #endif
392