1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: workwin.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SFXWORKWIN_HXX
31 #define _SFXWORKWIN_HXX
34 #include <com/sun/star/frame/XDispatch.hpp>
35 #include <com/sun/star/frame/XFrame.hpp>
36 #ifndef _COM_SUN_STAR_UI_XUILEMENT_HPP_
37 #include <com/sun/star/ui/XUIElement.hpp>
39 #include <com/sun/star/task/XStatusIndicator.hpp>
40 #include <com/sun/star/frame/XLayoutManagerListener.hpp>
41 #include <cppuhelper/weak.hxx>
42 #include <cppuhelper/propshlp.hxx>
44 #define _SVSTDARR_USHORTS
45 #include <svtools/svstdarr.hxx> // SvUShorts
46 #include <rtl/ustring.hxx>
47 #include <vos/mutex.hxx>
49 #include <sfx2/sfx.hrc>
50 #include <sfx2/childwin.hxx>
51 #include <sfx2/shell.hxx>
52 #include <sfx2/minarray.hxx>
53 #include <sfx2/ctrlitem.hxx>
54 #include <sfx2/viewfrm.hxx>
56 class SfxInPlaceEnv_Impl
;
57 class SfxPlugInEnv_Impl
;
61 //====================================================================
62 // Dieser struct h"alt alle relevanten Informationen "uber Toolboxen bereit.
64 struct SfxObjectBar_Impl
66 USHORT nId
; // Resource - und ConfigId der Toolbox
67 USHORT nMode
; // spezielle Sichtbarkeitsflags
82 //------------------------------------------------------------------------------
83 // Dieser struct h"alt alle relevanten Informationen "uber die Statuszeile bereit.
84 struct SfxStatBar_Impl
97 //------------------------------------------------------------------------------
99 #define CHILD_NOT_VISIBLE 0
100 #define CHILD_ACTIVE 1 // nicht durch HidePopups ausgeschaltet
101 #define CHILD_NOT_HIDDEN 2 // nicht durch HideChildWindow ausgeschaltet
102 #define CHILD_FITS_IN 4 // nicht zu gro\s f"ur OutputSize des parent
103 #define CHILD_VISIBLE (CHILD_NOT_HIDDEN | CHILD_ACTIVE | CHILD_FITS_IN)
104 #define CHILD_ISVISIBLE (CHILD_NOT_HIDDEN | CHILD_ACTIVE)
110 SfxChildAlignment eAlign
;
116 SfxChild_Impl( Window
& rChild
, const Size
& rSize
,
117 SfxChildAlignment eAlignment
, BOOL bIsVisible
):
118 pWin(&rChild
), aSize(rSize
), eAlign(eAlignment
), bResize(FALSE
),
119 bCanGetFocus( FALSE
), bSetFocus( FALSE
)
121 nVisible
= bIsVisible
? CHILD_VISIBLE
: CHILD_NOT_VISIBLE
;
125 //--------------------------------------------------------------------
126 class SfxChildWinController_Impl
: public SfxControllerItem
128 SfxWorkWindow
* pWorkwin
;
131 SfxChildWinController_Impl( USHORT nId
, SfxWorkWindow
*pWin
);
132 virtual void StateChanged( USHORT nSID
, SfxItemState eState
,
133 const SfxPoolItem
* pState
);
136 struct SfxChildWin_Impl
138 USHORT nSaveId
; // die ChildWindow-Id
139 USHORT nInterfaceId
; // der aktuelle Context
140 USHORT nId
; // aktuelle Id
141 SfxChildWindow
* pWin
;
143 SfxChildWinInfo aInfo
;
144 SfxChild_Impl
* pCli
; // != 0 bei direkten Children
149 SfxChildWin_Impl( sal_uInt32 nID
) :
150 nSaveId((USHORT
) (nID
& 0xFFFF) ),
151 nInterfaceId((USHORT
) (nID
>> 16)),
156 nVisibility( FALSE
),
162 enum SfxChildIdentifier
164 SFX_CHILDWIN_STATBAR
,
165 SFX_CHILDWIN_OBJECTBAR
,
166 SFX_CHILDWIN_DOCKINGWINDOW
,
167 SFX_CHILDWIN_SPLITWINDOW
170 enum SfxDockingConfig
173 SFX_ALIGNDOCKINGWINDOW
,
175 SFX_MOVEDOCKINGWINDOW
178 DECL_PTRARRAY( SfxChildList_Impl
, SfxChild_Impl
*, 2, 2 )
179 DECL_PTRARRAY( SfxChildWindows_Impl
, SfxChildWin_Impl
*, 2, 2 )
181 SV_DECL_OBJARR( SfxObjectBarArr_Impl
, SfxObjectBar_Impl
, 1, 2 )
183 struct SfxObjectBarList_Impl
185 SfxObjectBarArr_Impl aArr
;
188 SfxObjectBar_Impl
operator[] ( USHORT n
)
190 SfxObjectBar_Impl
Actual()
191 { return aArr
[nAct
]; }
194 struct SfxSplitWin_Impl
196 SfxSplitWindow
* pSplitWin
;
197 SfxChildWindows_Impl
* pChildWins
;
200 #define SFX_SPLITWINDOWS_LEFT 0
201 #define SFX_SPLITWINDOWS_TOP 2
202 #define SFX_SPLITWINDOWS_RIGHT 1
203 #define SFX_SPLITWINDOWS_BOTTOM 3
204 #define SFX_SPLITWINDOWS_MAX 4
206 //--------------------------------------------------------------------
208 class LayoutManagerListener
: public ::com::sun::star::frame::XLayoutManagerListener
,
209 public ::com::sun::star::lang::XTypeProvider
,
210 public ::com::sun::star::lang::XComponent
,
211 public ::cppu::OWeakObject
214 LayoutManagerListener( SfxWorkWindow
* pWrkWin
);
215 virtual ~LayoutManagerListener();
217 SFX_DECL_XINTERFACE_XTYPEPROVIDER
219 void setFrame( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
);
221 //---------------------------------------------------------------------------------------------------------
223 //---------------------------------------------------------------------------------------------------------
224 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
225 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
226 virtual void SAL_CALL
dispose() throw( ::com::sun::star::uno::RuntimeException
);
228 //---------------------------------------------------------------------------------------------------------
230 //---------------------------------------------------------------------------------------------------------
231 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& aEvent
) throw( ::com::sun::star::uno::RuntimeException
);
233 //---------------------------------------------------------------------------------------------------------
234 // XLayoutManagerEventListener
235 //---------------------------------------------------------------------------------------------------------
236 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
);
239 sal_Bool m_bHasFrame
;
240 SfxWorkWindow
* m_pWrkWin
;
241 ::com::sun::star::uno::WeakReference
< ::com::sun::star::frame::XFrame
> m_xFrame
;
242 rtl::OUString m_aLayoutManagerPropName
;
247 friend class UIElementWrapper
;
248 friend class LayoutManagerListener
;
251 SvUShorts aSortedList
;
252 SfxStatBar_Impl aStatBar
;
253 std::vector
< SfxObjectBar_Impl
> aObjBarList
;
254 Rectangle aClientArea
;
255 Rectangle aUpperClientArea
;
256 SfxWorkWindow
* pParent
;
257 SfxSplitWindow
* pSplit
[SFX_SPLITWINDOWS_MAX
];
258 SfxChildList_Impl
* pChilds
;
259 SfxChildWindows_Impl
* pChildWins
;
260 SfxBindings
* pBindings
;
262 SfxShell
* pConfigShell
;
263 Window
* pActiveChild
;
268 BOOL bDockingAllowed
: 1;
269 BOOL bInternalDockingAllowed
: 1;
270 BOOL bAllChildsVisible
: 1;
271 BOOL bIsFullScreen
: 1;
272 BOOL bShowStatusBar
: 1;
274 rtl::OUString m_aStatusBarResName
;
275 rtl::OUString m_aLayoutManagerPropName
;
276 rtl::OUString m_aTbxTypeName
;
277 rtl::OUString m_aProgressBarResName
;
278 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> m_xLayoutManagerListener
;
281 void CreateChildWin_Impl(SfxChildWin_Impl
*,BOOL
);
282 void RemoveChildWin_Impl(SfxChildWin_Impl
*);
284 void AlignChild_Impl( Window
& rWindow
, const Size
& rNewSize
,
285 SfxChildAlignment eAlign
);
286 SfxChild_Impl
* FindChild_Impl( const Window
& rWindow
) const;
287 virtual BOOL
RequestTopToolSpacePixel_Impl( SvBorder aBorder
);
288 virtual Rectangle
GetTopRect_Impl();
289 SvBorder
Arrange_Impl();
290 virtual void SaveStatus_Impl(SfxChildWindow
*, const SfxChildWinInfo
&);
291 static sal_Bool
IsPluginMode( SfxObjectShell
* pObjShell
);
294 SfxWorkWindow( Window
*pWin
, SfxBindings
& rBindings
, SfxWorkWindow
* pParent
= NULL
);
295 virtual ~SfxWorkWindow();
296 SystemWindow
* GetTopWindow() const;
297 SfxBindings
& GetBindings()
298 { return *pBindings
; }
299 Window
* GetWindow() const
301 Rectangle
GetFreeArea( BOOL bAutoHide
) const;
302 void SetDockingAllowed(BOOL bSet
)
303 { bDockingAllowed
= bSet
; }
304 void SetInternalDockingAllowed(BOOL bSet
)
305 { bInternalDockingAllowed
= bSet
; }
306 BOOL
IsDockingAllowed() const
307 { return bDockingAllowed
; }
308 BOOL
IsInternalDockingAllowed() const
309 { return bInternalDockingAllowed
; }
310 SfxWorkWindow
* GetParent_Impl() const
312 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> CreateDispatch( const String
& );
314 // Methoden f"ur alle Child-Fenster
315 void DataChanged_Impl( const DataChangedEvent
& rDCEvt
);
316 void ReleaseChild_Impl( Window
& rWindow
);
317 SfxChild_Impl
* RegisterChild_Impl( Window
& rWindow
, SfxChildAlignment eAlign
, BOOL bCanGetFocus
=FALSE
);
318 void ShowChilds_Impl();
319 void HideChilds_Impl();
321 BOOL
PrepareClose_Impl();
322 virtual void ArrangeChilds_Impl( BOOL bForce
= TRUE
);
323 void DeleteControllers_Impl();
324 void SaveStatus_Impl();
325 void HidePopups_Impl(BOOL bHide
, BOOL bParent
=FALSE
, USHORT nId
=0);
326 void ConfigChild_Impl(SfxChildIdentifier
,
327 SfxDockingConfig
, USHORT
);
328 void MakeChildsVisible_Impl( BOOL bVis
);
329 void ArrangeAutoHideWindows( SfxSplitWindow
*pSplit
);
330 BOOL
IsAutoHideMode( const SfxSplitWindow
*pSplit
);
331 void EndAutoShow_Impl( Point aPos
);
332 void SetFullScreen_Impl( BOOL bSet
) { bIsFullScreen
= bSet
; }
333 BOOL
IsFullScreen_Impl() const { return bIsFullScreen
; }
335 // Methoden f"ur Objectbars
336 virtual void UpdateObjectBars_Impl();
337 void ResetObjectBars_Impl();
338 void SetObjectBar_Impl( USHORT nPos
, sal_uInt32 nResId
,
339 SfxInterface
*pIFace
, const String
* pName
=0 );
340 Window
* GetObjectBar_Impl( USHORT nPos
, sal_uInt32 nResId
);
341 FASTBOOL
KnowsObjectBar_Impl( USHORT nPos
) const;
342 BOOL
IsVisible_Impl();
343 void MakeVisible_Impl( BOOL
);
344 void SetObjectBarVisibility_Impl( USHORT nVis
);
345 BOOL
IsContainer_Impl() const;
346 void Lock_Impl( BOOL
);
347 void NextObjectBar_Impl( USHORT nPos
);
348 USHORT
HasNextObjectBar_Impl( USHORT nPos
, String
* pStr
=0 );
349 void SetObjectBarCustomizeMode_Impl( BOOL
);
351 // Methoden f"ur ChildWindows
352 void UpdateChildWindows_Impl();
353 void ResetChildWindows_Impl();
354 void SetChildWindowVisible_Impl( sal_uInt32
, BOOL
, USHORT
);
355 void ToggleChildWindow_Impl(USHORT
,BOOL
);
356 BOOL
HasChildWindow_Impl(USHORT
);
357 BOOL
KnowsChildWindow_Impl(USHORT
);
358 void ShowChildWindow_Impl(USHORT
, BOOL bVisible
, BOOL bSetFocus
);
359 void SetChildWindow_Impl(USHORT
, BOOL bOn
, BOOL bSetFocus
);
360 SfxChildWindow
* GetChildWindow_Impl(USHORT
);
361 virtual void InitializeChild_Impl(SfxChildWin_Impl
*);
362 SfxSplitWindow
* GetSplitWindow_Impl(SfxChildAlignment
);
364 BOOL
IsVisible_Impl( USHORT nMode
) const;
365 void DisableChildWindow_Impl( USHORT nId
, BOOL bDisable
);
366 BOOL
IsFloating( USHORT nId
);
367 void ChangeWindow_Impl( Window
*pNew
);
368 void SetActiveChild_Impl( Window
*pChild
);
369 Window
* GetActiveChild_Impl();
370 virtual BOOL
ActivateNextChild_Impl( BOOL bForward
= TRUE
);
372 // Methoden f"ur StatusBar
373 void SetTempStatusBar_Impl( BOOL bSet
);
374 void ResetStatusBar_Impl();
375 void SetStatusBar_Impl(sal_uInt32 nResId
, SfxShell
*pShell
, SfxBindings
& );
376 void UpdateStatusBar_Impl();
377 ::com::sun::star::uno::Reference
< ::com::sun::star::task::XStatusIndicator
> GetStatusIndicator();
378 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> GetFrameInterface();
381 class SfxFrameWorkWin_Impl
: public SfxWorkWindow
383 SfxFrame
* pMasterFrame
;
386 SfxFrameWorkWin_Impl( Window
* pWin
, SfxFrame
* pFrm
, SfxFrame
* pMaster
);
387 virtual void ArrangeChilds_Impl( BOOL bForce
= TRUE
);
388 virtual void UpdateObjectBars_Impl();
389 virtual Rectangle
GetTopRect_Impl();