Bump version to 4.1-6
[LibreOffice.git] / sfx2 / source / inc / workwin.hxx
blob1d83befb2425b220c536aa4c3f2391e042e5b66b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _SFXWORKWIN_HXX
20 #define _SFXWORKWIN_HXX
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>
32 #include <rtl/ustring.hxx>
33 #include <osl/mutex.hxx>
35 #include <sfx2/sfx.hrc>
36 #include <sfx2/childwin.hxx>
37 #include <sfx2/shell.hxx>
38 #include <sfx2/ctrlitem.hxx>
39 #include <sfx2/viewfrm.hxx>
41 class SfxSplitWindow;
42 class SfxWorkWindow;
44 //====================================================================
45 // This struct makes all relevant Informationen available of Toolboxes
47 struct SfxObjectBar_Impl
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 sal_Bool bDestroy;
54 String aName;
55 SfxInterface* pIFace;
57 SfxObjectBar_Impl() :
58 nId(0),
59 nMode(0),
60 bDestroy(sal_False),
61 pIFace(0)
65 //------------------------------------------------------------------------------
66 // This struct makes all relevant Informationen available of the status bar
68 struct SfxStatBar_Impl
70 sal_uInt16 nId;
71 sal_Bool bOn;
72 sal_Bool bTemp;
74 SfxStatBar_Impl() :
75 nId(0),
76 bOn(sal_True),
77 bTemp(sal_False)
81 //------------------------------------------------------------------------------
83 #define CHILD_NOT_VISIBLE 0
84 #define CHILD_ACTIVE 1 // not disabled through HidePopups
85 #define CHILD_NOT_HIDDEN 2 // not disabled through HideChildWindow
86 #define CHILD_FITS_IN 4 // not too large for output size of the parent
87 #define CHILD_VISIBLE (CHILD_NOT_HIDDEN | CHILD_ACTIVE | CHILD_FITS_IN)
89 struct SfxChild_Impl
91 Window* pWin;
92 Size aSize;
93 SfxChildAlignment eAlign;
94 sal_uInt16 nVisible;
95 sal_Bool bResize;
96 sal_Bool bCanGetFocus;
97 sal_Bool bSetFocus;
99 SfxChild_Impl( Window& rChild, const Size& rSize,
100 SfxChildAlignment eAlignment, sal_Bool bIsVisible ):
101 pWin(&rChild), aSize(rSize), eAlign(eAlignment), bResize(sal_False),
102 bCanGetFocus( sal_False ), bSetFocus( sal_False )
104 nVisible = bIsVisible ? CHILD_VISIBLE : CHILD_NOT_VISIBLE;
108 struct SfxChildWin_Impl
110 sal_uInt16 nSaveId; // the ChildWindow-Id
111 sal_uInt16 nInterfaceId; // the current context
112 sal_uInt16 nId; // current Id
113 SfxChildWindow* pWin;
114 sal_Bool bCreate;
115 SfxChildWinInfo aInfo;
116 SfxChild_Impl* pCli; // != 0 at direct Children
117 sal_uInt16 nVisibility;
118 sal_Bool bEnable;
119 sal_Bool bDisabled;
121 SfxChildWin_Impl( sal_uInt32 nID ) :
122 nSaveId((sal_uInt16) (nID & 0xFFFF) ),
123 nInterfaceId((sal_uInt16) (nID >> 16)),
124 nId(nSaveId),
125 pWin(0),
126 bCreate(sal_False),
127 pCli(0),
128 nVisibility( sal_False ),
129 bEnable( sal_True ),
130 bDisabled( sal_False )
134 enum SfxChildIdentifier
136 SFX_CHILDWIN_STATBAR,
137 SFX_CHILDWIN_OBJECTBAR,
138 SFX_CHILDWIN_DOCKINGWINDOW,
139 SFX_CHILDWIN_SPLITWINDOW
142 enum SfxDockingConfig
144 SFX_SETDOCKINGRECTS,
145 SFX_ALIGNDOCKINGWINDOW,
146 SFX_TOGGLEFLOATMODE,
147 SFX_MOVEDOCKINGWINDOW
150 typedef std::vector<SfxChild_Impl*> SfxChildList_Impl;
151 typedef std::vector<SfxChildWin_Impl*> SfxChildWindows_Impl;
154 struct SfxObjectBarList_Impl
156 std::deque<SfxObjectBar_Impl> aArr;
157 sal_uInt16 nAct;
159 SfxObjectBar_Impl operator[] ( sal_uInt16 n )
160 { return aArr[n]; }
161 SfxObjectBar_Impl Actual()
162 { return aArr[nAct]; }
165 #define SFX_SPLITWINDOWS_LEFT 0
166 #define SFX_SPLITWINDOWS_TOP 2
167 #define SFX_SPLITWINDOWS_RIGHT 1
168 #define SFX_SPLITWINDOWS_BOTTOM 3
169 #define SFX_SPLITWINDOWS_MAX 4
171 //--------------------------------------------------------------------
173 class LayoutManagerListener : public ::com::sun::star::frame::XLayoutManagerListener,
174 public ::com::sun::star::lang::XTypeProvider,
175 public ::com::sun::star::lang::XComponent,
176 public ::cppu::OWeakObject
178 public:
179 LayoutManagerListener( SfxWorkWindow* pWrkWin );
180 virtual ~LayoutManagerListener();
182 SFX_DECL_XINTERFACE_XTYPEPROVIDER
184 void setFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
186 //---------------------------------------------------------------------------------------------------------
187 // XComponent
188 //---------------------------------------------------------------------------------------------------------
189 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
190 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
191 virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
193 //---------------------------------------------------------------------------------------------------------
194 // XEventListener
195 //---------------------------------------------------------------------------------------------------------
196 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
198 //---------------------------------------------------------------------------------------------------------
199 // XLayoutManagerEventListener
200 //---------------------------------------------------------------------------------------------------------
201 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);
203 private:
204 sal_Bool m_bHasFrame;
205 SfxWorkWindow* m_pWrkWin;
206 ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XFrame > m_xFrame;
207 OUString m_aLayoutManagerPropName;
210 class SfxWorkWindow
212 friend class LayoutManagerListener;
214 protected:
215 std::vector<sal_uInt16> aSortedList;
216 SfxStatBar_Impl aStatBar;
217 std::vector< SfxObjectBar_Impl > aObjBarList;
218 Rectangle aClientArea;
219 Rectangle aUpperClientArea;
220 SfxWorkWindow* pParent;
221 SfxSplitWindow* pSplit[SFX_SPLITWINDOWS_MAX];
222 SfxChildList_Impl aChildren;
223 SfxChildWindows_Impl aChildWins;
224 SfxBindings* pBindings;
225 Window* pWorkWin;
226 SfxShell* pConfigShell;
227 Window* pActiveChild;
228 sal_uInt16 nUpdateMode;
229 sal_uInt16 nChildren;
230 sal_uInt16 nOrigMode;
231 sal_Bool bSorted : 1;
232 sal_Bool bDockingAllowed : 1;
233 sal_Bool bInternalDockingAllowed : 1;
234 sal_Bool bAllChildrenVisible : 1;
235 sal_Bool bIsFullScreen : 1;
236 sal_Bool bShowStatusBar : 1;
237 sal_Int32 m_nLock;
238 OUString m_aStatusBarResName;
239 OUString m_aLayoutManagerPropName;
240 OUString m_aTbxTypeName;
241 OUString m_aProgressBarResName;
242 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xLayoutManagerListener;
244 protected:
245 void CreateChildWin_Impl(SfxChildWin_Impl*,sal_Bool);
246 void RemoveChildWin_Impl(SfxChildWin_Impl*);
247 void Sort_Impl();
248 SfxChild_Impl* FindChild_Impl( const Window& rWindow ) const;
249 virtual sal_Bool RequestTopToolSpacePixel_Impl( SvBorder aBorder );
250 virtual Rectangle GetTopRect_Impl();
251 SvBorder Arrange_Impl();
252 virtual void SaveStatus_Impl(SfxChildWindow*, const SfxChildWinInfo&);
253 static sal_Bool IsPluginMode( SfxObjectShell* pObjShell );
255 public:
256 SfxWorkWindow( Window *pWin, SfxBindings& rBindings, SfxWorkWindow* pParent = NULL);
257 virtual ~SfxWorkWindow();
258 SfxBindings& GetBindings()
259 { return *pBindings; }
260 Window* GetWindow() const
261 { return pWorkWin; }
262 Rectangle GetFreeArea( sal_Bool bAutoHide ) const;
263 void SetDockingAllowed(sal_Bool bSet)
264 { bDockingAllowed = bSet; }
265 void SetInternalDockingAllowed(sal_Bool bSet)
266 { bInternalDockingAllowed = bSet; }
267 sal_Bool IsDockingAllowed() const
268 { return bDockingAllowed; }
269 sal_Bool IsInternalDockingAllowed() const
270 { return bInternalDockingAllowed; }
271 SfxWorkWindow* GetParent_Impl() const
272 { return pParent; }
274 // Methods for all Child windows
275 void DataChanged_Impl( const DataChangedEvent& rDCEvt );
276 void ReleaseChild_Impl( Window& rWindow );
277 SfxChild_Impl* RegisterChild_Impl( Window& rWindow, SfxChildAlignment eAlign, sal_Bool bCanGetFocus=sal_False );
278 void ShowChildren_Impl();
279 void HideChildren_Impl();
280 sal_Bool PrepareClose_Impl();
281 virtual void ArrangeChildren_Impl( sal_Bool bForce = sal_True );
282 void DeleteControllers_Impl();
283 void HidePopups_Impl(sal_Bool bHide, sal_Bool bParent=sal_False, sal_uInt16 nId=0);
284 void ConfigChild_Impl(SfxChildIdentifier,
285 SfxDockingConfig, sal_uInt16);
286 void MakeChildrenVisible_Impl( sal_Bool bVis );
287 void ArrangeAutoHideWindows( SfxSplitWindow *pSplit );
288 sal_Bool IsAutoHideMode( const SfxSplitWindow *pSplit );
289 void EndAutoShow_Impl( Point aPos );
290 void SetFullScreen_Impl( sal_Bool bSet ) { bIsFullScreen = bSet; }
291 sal_Bool IsFullScreen_Impl() const { return bIsFullScreen; }
293 // Methods for Objectbars
294 virtual void UpdateObjectBars_Impl();
295 void ResetObjectBars_Impl();
296 void SetObjectBar_Impl( sal_uInt16 nPos, sal_uInt32 nResId,
297 SfxInterface *pIFace, const String* pName=0 );
298 bool KnowsObjectBar_Impl( sal_uInt16 nPos ) const;
299 sal_Bool IsVisible_Impl();
300 void MakeVisible_Impl( sal_Bool );
301 void SetObjectBarVisibility_Impl( sal_uInt16 nVis );
302 sal_Bool IsContainer_Impl() const;
303 void Lock_Impl( sal_Bool );
305 // Methods for ChildWindows
306 void UpdateChildWindows_Impl();
307 void ResetChildWindows_Impl();
308 void SetChildWindowVisible_Impl( sal_uInt32, sal_Bool, sal_uInt16 );
309 void ToggleChildWindow_Impl(sal_uInt16,sal_Bool);
310 sal_Bool HasChildWindow_Impl(sal_uInt16);
311 sal_Bool KnowsChildWindow_Impl(sal_uInt16);
312 void ShowChildWindow_Impl(sal_uInt16, sal_Bool bVisible, sal_Bool bSetFocus);
313 void SetChildWindow_Impl(sal_uInt16, sal_Bool bOn, sal_Bool bSetFocus);
314 SfxChildWindow* GetChildWindow_Impl(sal_uInt16);
315 virtual void InitializeChild_Impl(SfxChildWin_Impl*);
316 SfxSplitWindow* GetSplitWindow_Impl(SfxChildAlignment);
318 sal_Bool IsVisible_Impl( sal_uInt16 nMode ) const;
319 sal_Bool IsFloating( sal_uInt16 nId );
320 void SetActiveChild_Impl( Window *pChild );
321 virtual sal_Bool ActivateNextChild_Impl( sal_Bool bForward = sal_True );
322 bool AllowChildWindowCreation_Impl( const SfxChildWin_Impl& i_rCW ) const;
324 // Methods for StatusBar
325 void ResetStatusBar_Impl();
326 void SetStatusBar_Impl(sal_uInt32 nResId, SfxShell *pShell, SfxBindings& );
327 void UpdateStatusBar_Impl();
328 ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > GetStatusIndicator();
329 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrameInterface();
332 class SfxFrameWorkWin_Impl : public SfxWorkWindow
334 SfxFrame* pMasterFrame;
335 SfxFrame* pFrame;
336 public:
337 SfxFrameWorkWin_Impl( Window* pWin, SfxFrame* pFrm, SfxFrame* pMaster );
338 virtual void ArrangeChildren_Impl( sal_Bool bForce = sal_True );
339 virtual void UpdateObjectBars_Impl();
340 virtual Rectangle GetTopRect_Impl();
344 #endif
346 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */