1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
27 #ifndef _SFXWORKWIN_HXX
28 #define _SFXWORKWIN_HXX
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>
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>
42 #define _SVSTDARR_USHORTS
43 #include <svl/svstdarr.hxx> // SvUShorts
44 #include <rtl/ustring.hxx>
45 #include <vos/mutex.hxx>
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>
54 class SfxInPlaceEnv_Impl
;
55 class SfxPlugInEnv_Impl
;
59 //====================================================================
60 // Dieser struct h"alt alle relevanten Informationen "uber Toolboxen bereit.
62 struct SfxObjectBar_Impl
64 sal_uInt16 nId
; // Resource - und ConfigId der Toolbox
65 sal_uInt16 nMode
; // spezielle Sichtbarkeitsflags
80 //------------------------------------------------------------------------------
81 // Dieser struct h"alt alle relevanten Informationen "uber die Statuszeile bereit.
82 struct SfxStatBar_Impl
95 //------------------------------------------------------------------------------
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)
108 SfxChildAlignment eAlign
;
111 sal_Bool bCanGetFocus
;
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
)
119 nVisible
= bIsVisible
? CHILD_VISIBLE
: CHILD_NOT_VISIBLE
;
123 //--------------------------------------------------------------------
124 class SfxChildWinController_Impl
: public SfxControllerItem
126 SfxWorkWindow
* pWorkwin
;
129 SfxChildWinController_Impl( sal_uInt16 nId
, SfxWorkWindow
*pWin
);
130 virtual void StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
131 const SfxPoolItem
* pState
);
134 struct SfxChildWin_Impl
136 sal_uInt16 nSaveId
; // die ChildWindow-Id
137 sal_uInt16 nInterfaceId
; // der aktuelle Context
138 sal_uInt16 nId
; // aktuelle Id
139 SfxChildWindow
* pWin
;
141 SfxChildWinInfo aInfo
;
142 SfxChild_Impl
* pCli
; // != 0 bei direkten Children
143 sal_uInt16 nVisibility
;
147 SfxChildWin_Impl( sal_uInt32 nID
) :
148 nSaveId((sal_uInt16
) (nID
& 0xFFFF) ),
149 nInterfaceId((sal_uInt16
) (nID
>> 16)),
154 nVisibility( sal_False
),
156 bDisabled( sal_False
)
160 enum SfxChildIdentifier
162 SFX_CHILDWIN_STATBAR
,
163 SFX_CHILDWIN_OBJECTBAR
,
164 SFX_CHILDWIN_DOCKINGWINDOW
,
165 SFX_CHILDWIN_SPLITWINDOW
168 enum SfxDockingConfig
171 SFX_ALIGNDOCKINGWINDOW
,
173 SFX_MOVEDOCKINGWINDOW
176 DECL_PTRARRAY( SfxChildList_Impl
, SfxChild_Impl
*, 2, 2 )
177 DECL_PTRARRAY( SfxChildWindows_Impl
, SfxChildWin_Impl
*, 2, 2 )
180 struct SfxObjectBarList_Impl
182 std::deque
<SfxObjectBar_Impl
> aArr
;
185 SfxObjectBar_Impl
operator[] ( sal_uInt16 n
)
187 SfxObjectBar_Impl
Actual()
188 { return aArr
[nAct
]; }
191 struct SfxSplitWin_Impl
193 SfxSplitWindow
* pSplitWin
;
194 SfxChildWindows_Impl
* pChildWins
;
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
203 //--------------------------------------------------------------------
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
211 LayoutManagerListener( SfxWorkWindow
* pWrkWin
);
212 virtual ~LayoutManagerListener();
214 SFX_DECL_XINTERFACE_XTYPEPROVIDER
216 void setFrame( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
);
218 //---------------------------------------------------------------------------------------------------------
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
);
225 //---------------------------------------------------------------------------------------------------------
227 //---------------------------------------------------------------------------------------------------------
228 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& aEvent
) throw( ::com::sun::star::uno::RuntimeException
);
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
);
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
;
244 friend class UIElementWrapper
;
245 friend class LayoutManagerListener
;
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
;
259 SfxShell
* pConfigShell
;
260 Window
* pActiveChild
;
261 sal_uInt16 nUpdateMode
;
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;
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
;
278 void CreateChildWin_Impl(SfxChildWin_Impl
*,sal_Bool
);
279 void RemoveChildWin_Impl(SfxChildWin_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
);
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
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
309 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> CreateDispatch( const String
& );
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();
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
; }
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
);
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
);
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;
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();
379 class SfxFrameWorkWin_Impl
: public SfxWorkWindow
381 SfxFrame
* pMasterFrame
;
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();