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