1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_SFX2_SOURCE_INC_WORKWIN_HXX
20 #define INCLUDED_SFX2_SOURCE_INC_WORKWIN_HXX
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>
32 #include <rtl/ustring.hxx>
33 #include <osl/mutex.hxx>
34 #include <o3tl/typed_flags_set.hxx>
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>
46 // 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
67 // This struct makes all relevant Informationen available of the status bar
69 struct SfxStatBar_Impl
83 enum class SfxChildVisibility
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)
93 template<> struct typed_flags
<SfxChildVisibility
> : is_typed_flags
<SfxChildVisibility
, 0x07> {};
99 VclPtr
<vcl::Window
> pWin
;
101 SfxChildAlignment eAlign
;
102 SfxChildVisibility nVisible
;
107 SfxChild_Impl( vcl::Window
& rChild
, const Size
& rSize
,
108 SfxChildAlignment eAlignment
, bool bIsVisible
):
109 pWin(&rChild
), aSize(rSize
), eAlign(eAlignment
), bResize(false),
110 bCanGetFocus( false ), bSetFocus( false )
112 nVisible
= bIsVisible
? SfxChildVisibility::VISIBLE
: SfxChildVisibility::NOT_VISIBLE
;
116 struct SfxChildWin_Impl
118 sal_uInt16 nSaveId
; // the ChildWindow-Id
119 sal_uInt16 nInterfaceId
; // the current context
120 sal_uInt16 nId
; // current Id
121 SfxChildWindow
* pWin
;
123 SfxChildWinInfo aInfo
;
124 SfxChild_Impl
* pCli
; // != 0 at direct Children
125 sal_uInt16 nVisibility
;
129 SfxChildWin_Impl( sal_uInt32 nID
) :
130 nSaveId((sal_uInt16
) (nID
& 0xFFFF) ),
131 nInterfaceId((sal_uInt16
) (nID
>> 16)),
136 nVisibility( SFX_VISIBILITY_UNVISIBLE
),
142 enum class SfxChildIdentifier
150 enum class SfxDockingConfig
158 typedef std::vector
<SfxChild_Impl
*> SfxChildList_Impl
;
159 typedef std::vector
<SfxChildWin_Impl
*> SfxChildWindows_Impl
;
162 struct SfxObjectBarList_Impl
164 std::deque
<SfxObjectBar_Impl
> aArr
;
167 SfxObjectBar_Impl
operator[] ( sal_uInt16 n
)
169 SfxObjectBar_Impl
Actual()
170 { return aArr
[nAct
]; }
173 #define SFX_SPLITWINDOWS_LEFT 0
174 #define SFX_SPLITWINDOWS_TOP 2
175 #define SFX_SPLITWINDOWS_RIGHT 1
176 #define SFX_SPLITWINDOWS_MAX 4
180 class LayoutManagerListener
: public ::cppu::WeakImplHelper2
<
181 css::frame::XLayoutManagerListener
,
182 css::lang::XComponent
>
185 LayoutManagerListener( SfxWorkWindow
* pWrkWin
);
186 virtual ~LayoutManagerListener();
188 void setFrame( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
);
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
;
200 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& aEvent
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
203 // XLayoutManagerEventListener
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
;
209 SfxWorkWindow
* m_pWrkWin
;
210 ::com::sun::star::uno::WeakReference
< ::com::sun::star::frame::XFrame
> m_xFrame
;
211 OUString m_aLayoutManagerPropName
;
216 friend class LayoutManagerListener
;
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
;
236 bool bDockingAllowed
: 1;
237 bool bInternalDockingAllowed
: 1;
238 bool bAllChildrenVisible
: 1;
239 bool bIsFullScreen
: 1;
240 bool bShowStatusBar
: 1;
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
;
249 void CreateChildWin_Impl(SfxChildWin_Impl
*,bool);
250 void RemoveChildWin_Impl(SfxChildWin_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
);
260 SfxWorkWindow( vcl::Window
*pWin
, SfxBindings
& rBindings
, SfxWorkWindow
* pParent
= NULL
);
261 virtual ~SfxWorkWindow();
262 SfxBindings
& GetBindings()
263 { return *pBindings
; }
264 vcl::Window
* GetWindow() const
266 Rectangle
GetFreeArea( bool bAutoHide
) const;
267 void SetDockingAllowed(bool bSet
)
268 { bDockingAllowed
= bSet
; }
269 void SetInternalDockingAllowed(bool bSet
)
270 { bInternalDockingAllowed
= bSet
; }
271 bool IsDockingAllowed() const
272 { return bDockingAllowed
; }
273 bool IsInternalDockingAllowed() const
274 { return bInternalDockingAllowed
; }
275 SfxWorkWindow
* GetParent_Impl() const
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 void SetFullScreen_Impl( bool bSet
) { bIsFullScreen
= bSet
; }
295 bool IsFullScreen_Impl() const { return bIsFullScreen
; }
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 );
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
);
322 bool IsVisible_Impl( sal_uInt16 nMode
) const;
323 bool IsFloating( sal_uInt16 nId
);
324 void SetActiveChild_Impl( vcl::Window
*pChild
);
325 VclPtr
<vcl::Window
> GetActiveChild_Impl() const { return pActiveChild
; }
326 bool ActivateNextChild_Impl( bool bForward
= true );
327 bool AllowChildWindowCreation_Impl( const SfxChildWin_Impl
& i_rCW
) const;
329 // Methods for StatusBar
330 void ResetStatusBar_Impl();
331 void SetStatusBar_Impl(sal_uInt32 nResId
, SfxShell
*pShell
, SfxBindings
& );
332 void UpdateStatusBar_Impl();
333 ::com::sun::star::uno::Reference
< ::com::sun::star::task::XStatusIndicator
> GetStatusIndicator();
334 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> GetFrameInterface();
337 class SfxFrameWorkWin_Impl
: public SfxWorkWindow
339 SfxFrame
* pMasterFrame
;
342 SfxFrameWorkWin_Impl( vcl::Window
* pWin
, SfxFrame
* pFrm
, SfxFrame
* pMaster
);
343 virtual void ArrangeChildren_Impl( bool bForce
= true ) SAL_OVERRIDE
;
344 virtual void UpdateObjectBars_Impl() SAL_OVERRIDE
;
345 virtual Rectangle
GetTopRect_Impl() SAL_OVERRIDE
;
351 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */