Branch data 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 : : #ifndef _SFXWORKWIN_HXX
20 : : #define _SFXWORKWIN_HXX
21 : :
22 : : #include <vector>
23 : : #include <deque>
24 : : #include <com/sun/star/frame/XDispatch.hpp>
25 : : #include <com/sun/star/frame/XFrame.hpp>
26 : : #include <com/sun/star/ui/XUIElement.hpp>
27 : : #include <com/sun/star/task/XStatusIndicator.hpp>
28 : : #include <com/sun/star/frame/XLayoutManagerListener.hpp>
29 : : #include <cppuhelper/weak.hxx>
30 : : #include <cppuhelper/propshlp.hxx>
31 : :
32 : : #include <rtl/ustring.hxx>
33 : : #include <osl/mutex.hxx>
34 : :
35 : : #include <sfx2/sfx.hrc>
36 : : #include <sfx2/childwin.hxx>
37 : : #include <sfx2/shell.hxx>
38 : : #include <sfx2/minarray.hxx>
39 : : #include <sfx2/ctrlitem.hxx>
40 : : #include <sfx2/viewfrm.hxx>
41 : :
42 : : class SfxSplitWindow;
43 : : class SfxWorkWindow;
44 : :
45 : : //====================================================================
46 : : // This struct makes all relevant Informationen available of Toolboxes
47 : :
48 : 86423 : struct SfxObjectBar_Impl
49 : : {
50 : : sal_uInt16 nId; // Resource - and ConfigId of Toolbox
51 : : sal_uInt16 nMode; // special visibility flags
52 : : sal_uInt16 nPos;
53 : : sal_uInt16 nIndex;
54 : : sal_Bool bDestroy;
55 : : String aName;
56 : : SfxInterface* pIFace;
57 : :
58 : 26099 : SfxObjectBar_Impl() :
59 : : nId(0),
60 : : nMode(0),
61 : : bDestroy(sal_False),
62 : 26099 : pIFace(0)
63 : 26099 : {}
64 : : };
65 : :
66 : : //------------------------------------------------------------------------------
67 : : // This struct makes all relevant Informationen available of the status bar
68 : :
69 : : struct SfxStatBar_Impl
70 : : {
71 : : sal_uInt16 nId;
72 : : sal_Bool bOn;
73 : : sal_Bool bTemp;
74 : :
75 : 1711 : SfxStatBar_Impl() :
76 : : nId(0),
77 : : bOn(sal_True),
78 : 1711 : bTemp(sal_False)
79 : 1711 : {}
80 : : };
81 : :
82 : : //------------------------------------------------------------------------------
83 : :
84 : : #define CHILD_NOT_VISIBLE 0
85 : : #define CHILD_ACTIVE 1 // not disabled through HidePopups
86 : : #define CHILD_NOT_HIDDEN 2 // not disabled through HideChildWindow
87 : : #define CHILD_FITS_IN 4 // not too large for output size of the parent
88 : : #define CHILD_VISIBLE (CHILD_NOT_HIDDEN | CHILD_ACTIVE | CHILD_FITS_IN)
89 : :
90 : : struct SfxChild_Impl
91 : : {
92 : : Window* pWin;
93 : : Size aSize;
94 : : SfxChildAlignment eAlign;
95 : : sal_uInt16 nVisible;
96 : : sal_Bool bResize;
97 : : sal_Bool bCanGetFocus;
98 : : sal_Bool bSetFocus;
99 : :
100 : 1199 : SfxChild_Impl( Window& rChild, const Size& rSize,
101 : : SfxChildAlignment eAlignment, sal_Bool bIsVisible ):
102 : : pWin(&rChild), aSize(rSize), eAlign(eAlignment), bResize(sal_False),
103 : 1199 : bCanGetFocus( sal_False ), bSetFocus( sal_False )
104 : : {
105 [ + + ]: 1199 : nVisible = bIsVisible ? CHILD_VISIBLE : CHILD_NOT_VISIBLE;
106 : 1199 : }
107 : : };
108 : :
109 : 52609 : struct SfxChildWin_Impl
110 : : {
111 : : sal_uInt16 nSaveId; // the ChildWindow-Id
112 : : sal_uInt16 nInterfaceId; // the current context
113 : : sal_uInt16 nId; // current Id
114 : : SfxChildWindow* pWin;
115 : : sal_Bool bCreate;
116 : : SfxChildWinInfo aInfo;
117 : : SfxChild_Impl* pCli; // != 0 at direct Children
118 : : sal_uInt16 nVisibility;
119 : : sal_Bool bEnable;
120 : : sal_Bool bDisabled;
121 : :
122 : 55546 : SfxChildWin_Impl( sal_uInt32 nID ) :
123 : : nSaveId((sal_uInt16) (nID & 0xFFFF) ),
124 : : nInterfaceId((sal_uInt16) (nID >> 16)),
125 : : nId(nSaveId),
126 : : pWin(0),
127 : : bCreate(sal_False),
128 : : pCli(0),
129 : : nVisibility( sal_False ),
130 : : bEnable( sal_True ),
131 : 55546 : bDisabled( sal_False )
132 : 55546 : {}
133 : : };
134 : :
135 : : enum SfxChildIdentifier
136 : : {
137 : : SFX_CHILDWIN_STATBAR,
138 : : SFX_CHILDWIN_OBJECTBAR,
139 : : SFX_CHILDWIN_DOCKINGWINDOW,
140 : : SFX_CHILDWIN_SPLITWINDOW
141 : : };
142 : :
143 : : enum SfxDockingConfig
144 : : {
145 : : SFX_SETDOCKINGRECTS,
146 : : SFX_ALIGNDOCKINGWINDOW,
147 : : SFX_TOGGLEFLOATMODE,
148 : : SFX_MOVEDOCKINGWINDOW
149 : : };
150 : :
151 : 287673 : DECL_PTRARRAY( SfxChildList_Impl, SfxChild_Impl*, 2, 2 )
152 : 6441770 : DECL_PTRARRAY( SfxChildWindows_Impl, SfxChildWin_Impl*, 2, 2 )
153 : :
154 : :
155 : : struct SfxObjectBarList_Impl
156 : : {
157 : : std::deque<SfxObjectBar_Impl> aArr;
158 : : sal_uInt16 nAct;
159 : :
160 : : SfxObjectBar_Impl operator[] ( sal_uInt16 n )
161 : : { return aArr[n]; }
162 : : SfxObjectBar_Impl Actual()
163 : : { return aArr[nAct]; }
164 : : };
165 : :
166 : : struct SfxSplitWin_Impl
167 : : {
168 : : SfxSplitWindow* pSplitWin;
169 : : SfxChildWindows_Impl* pChildWins;
170 : : };
171 : :
172 : : #define SFX_SPLITWINDOWS_LEFT 0
173 : : #define SFX_SPLITWINDOWS_TOP 2
174 : : #define SFX_SPLITWINDOWS_RIGHT 1
175 : : #define SFX_SPLITWINDOWS_BOTTOM 3
176 : : #define SFX_SPLITWINDOWS_MAX 4
177 : :
178 : : //--------------------------------------------------------------------
179 : :
180 : : class LayoutManagerListener : public ::com::sun::star::frame::XLayoutManagerListener,
181 : : public ::com::sun::star::lang::XTypeProvider,
182 : : public ::com::sun::star::lang::XComponent,
183 : : public ::cppu::OWeakObject
184 : : {
185 : : public:
186 : : LayoutManagerListener( SfxWorkWindow* pWrkWin );
187 : : virtual ~LayoutManagerListener();
188 : :
189 : : SFX_DECL_XINTERFACE_XTYPEPROVIDER
190 : :
191 : : void setFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
192 : :
193 : : //---------------------------------------------------------------------------------------------------------
194 : : // XComponent
195 : : //---------------------------------------------------------------------------------------------------------
196 : : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
197 : : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
198 : : virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
199 : :
200 : : //---------------------------------------------------------------------------------------------------------
201 : : // XEventListener
202 : : //---------------------------------------------------------------------------------------------------------
203 : : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
204 : :
205 : : //---------------------------------------------------------------------------------------------------------
206 : : // XLayoutManagerEventListener
207 : : //---------------------------------------------------------------------------------------------------------
208 : : 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);
209 : :
210 : : private:
211 : : sal_Bool m_bHasFrame;
212 : : SfxWorkWindow* m_pWrkWin;
213 : : ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XFrame > m_xFrame;
214 : : rtl::OUString m_aLayoutManagerPropName;
215 : : };
216 : :
217 : : class SfxWorkWindow
218 : : {
219 : : friend class LayoutManagerListener;
220 : :
221 : : protected:
222 : : std::vector<sal_uInt16> aSortedList;
223 : : SfxStatBar_Impl aStatBar;
224 : : std::vector< SfxObjectBar_Impl > aObjBarList;
225 : : Rectangle aClientArea;
226 : : Rectangle aUpperClientArea;
227 : : SfxWorkWindow* pParent;
228 : : SfxSplitWindow* pSplit[SFX_SPLITWINDOWS_MAX];
229 : : SfxChildList_Impl* pChildren;
230 : : SfxChildWindows_Impl* pChildWins;
231 : : SfxBindings* pBindings;
232 : : Window* pWorkWin;
233 : : SfxShell* pConfigShell;
234 : : Window* pActiveChild;
235 : : sal_uInt16 nUpdateMode;
236 : : sal_uInt16 nChildren;
237 : : sal_uInt16 nOrigMode;
238 : : sal_Bool bSorted : 1;
239 : : sal_Bool bDockingAllowed : 1;
240 : : sal_Bool bInternalDockingAllowed : 1;
241 : : sal_Bool bAllChildrenVisible : 1;
242 : : sal_Bool bIsFullScreen : 1;
243 : : sal_Bool bShowStatusBar : 1;
244 : : sal_Int32 m_nLock;
245 : : rtl::OUString m_aStatusBarResName;
246 : : rtl::OUString m_aLayoutManagerPropName;
247 : : rtl::OUString m_aTbxTypeName;
248 : : rtl::OUString m_aProgressBarResName;
249 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xLayoutManagerListener;
250 : :
251 : : protected:
252 : : void CreateChildWin_Impl(SfxChildWin_Impl*,sal_Bool);
253 : : void RemoveChildWin_Impl(SfxChildWin_Impl*);
254 : : void Sort_Impl();
255 : : SfxChild_Impl* FindChild_Impl( const Window& rWindow ) const;
256 : : virtual sal_Bool RequestTopToolSpacePixel_Impl( SvBorder aBorder );
257 : : virtual Rectangle GetTopRect_Impl();
258 : : SvBorder Arrange_Impl();
259 : : virtual void SaveStatus_Impl(SfxChildWindow*, const SfxChildWinInfo&);
260 : : static sal_Bool IsPluginMode( SfxObjectShell* pObjShell );
261 : :
262 : : public:
263 : : SfxWorkWindow( Window *pWin, SfxBindings& rBindings, SfxWorkWindow* pParent = NULL);
264 : : virtual ~SfxWorkWindow();
265 : 47409 : SfxBindings& GetBindings()
266 : 47409 : { return *pBindings; }
267 : 0 : Window* GetWindow() const
268 : 0 : { return pWorkWin; }
269 : : Rectangle GetFreeArea( sal_Bool bAutoHide ) const;
270 : 0 : void SetDockingAllowed(sal_Bool bSet)
271 : 0 : { bDockingAllowed = bSet; }
272 : 0 : void SetInternalDockingAllowed(sal_Bool bSet)
273 : 0 : { bInternalDockingAllowed = bSet; }
274 : 29726 : sal_Bool IsDockingAllowed() const
275 : 29726 : { return bDockingAllowed; }
276 : 312 : sal_Bool IsInternalDockingAllowed() const
277 : 312 : { return bInternalDockingAllowed; }
278 : 6480 : SfxWorkWindow* GetParent_Impl() const
279 : 6480 : { return pParent; }
280 : :
281 : : // Methods for all Child windows
282 : : void DataChanged_Impl( const DataChangedEvent& rDCEvt );
283 : : void ReleaseChild_Impl( Window& rWindow );
284 : : SfxChild_Impl* RegisterChild_Impl( Window& rWindow, SfxChildAlignment eAlign, sal_Bool bCanGetFocus=sal_False );
285 : : void ShowChildren_Impl();
286 : : void HideChildren_Impl();
287 : : sal_Bool PrepareClose_Impl();
288 : : virtual void ArrangeChildren_Impl( sal_Bool bForce = sal_True );
289 : : void DeleteControllers_Impl();
290 : : void HidePopups_Impl(sal_Bool bHide, sal_Bool bParent=sal_False, sal_uInt16 nId=0);
291 : : void ConfigChild_Impl(SfxChildIdentifier,
292 : : SfxDockingConfig, sal_uInt16);
293 : : void MakeChildrenVisible_Impl( sal_Bool bVis );
294 : : void ArrangeAutoHideWindows( SfxSplitWindow *pSplit );
295 : : sal_Bool IsAutoHideMode( const SfxSplitWindow *pSplit );
296 : : void EndAutoShow_Impl( Point aPos );
297 : 0 : void SetFullScreen_Impl( sal_Bool bSet ) { bIsFullScreen = bSet; }
298 : : sal_Bool IsFullScreen_Impl() const { return bIsFullScreen; }
299 : :
300 : : // Methods for Objectbars
301 : : virtual void UpdateObjectBars_Impl();
302 : : void ResetObjectBars_Impl();
303 : : void SetObjectBar_Impl( sal_uInt16 nPos, sal_uInt32 nResId,
304 : : SfxInterface *pIFace, const String* pName=0 );
305 : : bool KnowsObjectBar_Impl( sal_uInt16 nPos ) const;
306 : : sal_Bool IsVisible_Impl();
307 : : void MakeVisible_Impl( sal_Bool );
308 : : void SetObjectBarVisibility_Impl( sal_uInt16 nVis );
309 : : sal_Bool IsContainer_Impl() const;
310 : : void Lock_Impl( sal_Bool );
311 : :
312 : : // Methods for ChildWindows
313 : : void UpdateChildWindows_Impl();
314 : : void ResetChildWindows_Impl();
315 : : void SetChildWindowVisible_Impl( sal_uInt32, sal_Bool, sal_uInt16 );
316 : : void ToggleChildWindow_Impl(sal_uInt16,sal_Bool);
317 : : sal_Bool HasChildWindow_Impl(sal_uInt16);
318 : : sal_Bool KnowsChildWindow_Impl(sal_uInt16);
319 : : void ShowChildWindow_Impl(sal_uInt16, sal_Bool bVisible, sal_Bool bSetFocus);
320 : : void SetChildWindow_Impl(sal_uInt16, sal_Bool bOn, sal_Bool bSetFocus);
321 : : SfxChildWindow* GetChildWindow_Impl(sal_uInt16);
322 : : virtual void InitializeChild_Impl(SfxChildWin_Impl*);
323 : : SfxSplitWindow* GetSplitWindow_Impl(SfxChildAlignment);
324 : :
325 : : sal_Bool IsVisible_Impl( sal_uInt16 nMode ) const;
326 : : sal_Bool IsFloating( sal_uInt16 nId );
327 : : void SetActiveChild_Impl( Window *pChild );
328 : : virtual sal_Bool ActivateNextChild_Impl( sal_Bool bForward = sal_True );
329 : : bool AllowChildWindowCreation_Impl( const SfxChildWin_Impl& i_rCW ) const;
330 : :
331 : : // Methods for StatusBar
332 : : void ResetStatusBar_Impl();
333 : : void SetStatusBar_Impl(sal_uInt32 nResId, SfxShell *pShell, SfxBindings& );
334 : : void UpdateStatusBar_Impl();
335 : : ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > GetStatusIndicator();
336 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrameInterface();
337 : : };
338 : :
339 [ - + ]: 3240 : class SfxFrameWorkWin_Impl : public SfxWorkWindow
340 : : {
341 : : SfxFrame* pMasterFrame;
342 : : SfxFrame* pFrame;
343 : : public:
344 : : SfxFrameWorkWin_Impl( Window* pWin, SfxFrame* pFrm, SfxFrame* pMaster );
345 : : virtual void ArrangeChildren_Impl( sal_Bool bForce = sal_True );
346 : : virtual void UpdateObjectBars_Impl();
347 : : virtual Rectangle GetTopRect_Impl();
348 : : };
349 : :
350 : :
351 : : #endif
352 : :
353 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|