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 .
20 #ifndef __FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_
21 #define __FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_
23 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
24 with solaris headers ...
28 #include <threadhelp/threadhelpbase.hxx>
29 #include <threadhelp/resetableguard.hxx>
30 #include <threadhelp/writeguard.hxx>
31 #include <threadhelp/readguard.hxx>
32 #include <macros/generic.hxx>
33 #include <macros/xinterface.hxx>
34 #include <macros/xtypeprovider.hxx>
35 #include <macros/xserviceinfo.hxx>
36 #include <properties.h>
38 #include <uielement/menubarmanager.hxx>
39 #include <uiconfiguration/windowstateconfiguration.hxx>
40 #include <framework/addonsoptions.hxx>
41 #include <uielement/uielement.hxx>
42 #include <helper/ilayoutnotifications.hxx>
44 #include <com/sun/star/lang/XServiceInfo.hpp>
45 #include <com/sun/star/lang/XTypeProvider.hpp>
46 #include <com/sun/star/frame/XLayoutManager.hpp>
47 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
48 #include <com/sun/star/ui/XUIConfiguration.hpp>
49 #include <com/sun/star/frame/XModuleManager2.hpp>
50 #include <com/sun/star/frame/XFrameActionListener.hpp>
51 #include <com/sun/star/awt/XWindowListener.hpp>
52 #include <com/sun/star/util/XURLTransformer.hpp>
53 #include <com/sun/star/ui/XUIElementFactory.hpp>
54 #include <com/sun/star/ui/XUIElementFactoryManager.hpp>
55 #include <com/sun/star/ui/DockingArea.hpp>
56 #include <com/sun/star/awt/XTopWindow2.hpp>
57 #include <com/sun/star/awt/XDockableWindow.hpp>
58 #include <com/sun/star/awt/XDockableWindowListener.hpp>
59 #include <com/sun/star/frame/XMenuBarMergingAcceptor.hpp>
60 #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp>
62 #include <cppuhelper/propshlp.hxx>
63 #include <cppuhelper/implbase7.hxx>
64 #include <cppuhelper/interfacecontainer.hxx>
65 #include <comphelper/propertycontainer.hxx>
66 #include <tools/wintypes.hxx>
67 #include <svtools/miscopt.hxx>
68 #include <vcl/toolbox.hxx>
69 #include <vcl/timer.hxx>
74 class ToolbarLayoutManager
;
78 class InfoHelperBuilder
;
80 typedef ::cppu::WeakImplHelper7
< ::com::sun::star::lang::XServiceInfo
81 , ::com::sun::star::frame::XLayoutManager
82 , ::com::sun::star::awt::XWindowListener
83 , ::com::sun::star::frame::XFrameActionListener
84 , ::com::sun::star::ui::XUIConfigurationListener
85 , ::com::sun::star::frame::XMenuBarMergingAcceptor
86 , ::com::sun::star::frame::XLayoutManagerEventBroadcaster
88 typedef ::comphelper::OPropertyContainer LayoutManager_PBase
;
89 class LayoutManager
: public LayoutManager_Base
,
91 // Order is necessary for right initialization!
92 private ThreadHelpBase
, // Struct for right initalization of mutex member! Must be first of baseclasses.
93 public ::cppu::OBroadcastHelper
,
94 public ILayoutNotifications
,
95 public LayoutManager_PBase
98 enum { DOCKINGAREAS_COUNT
= 4 };
100 LayoutManager( const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& rSMGR
);
101 virtual ~LayoutManager();
103 /** declaration of XInterface, XTypeProvider, XServiceInfo */
104 FWK_DECLARE_XINTERFACE
105 FWK_DECLARE_XTYPEPROVIDER
108 //---------------------------------------------------------------------------------------------------------
110 //---------------------------------------------------------------------------------------------------------
111 virtual void SAL_CALL
attachFrame( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& Frame
) throw (::com::sun::star::uno::RuntimeException
);
112 virtual void SAL_CALL
reset() throw (::com::sun::star::uno::RuntimeException
);
113 virtual ::com::sun::star::awt::Rectangle SAL_CALL
getCurrentDockingArea( ) throw (::com::sun::star::uno::RuntimeException
);
114 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XDockingAreaAcceptor
> SAL_CALL
getDockingAreaAcceptor() throw (::com::sun::star::uno::RuntimeException
);
115 virtual void SAL_CALL
setDockingAreaAcceptor( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XDockingAreaAcceptor
>& xDockingAreaAcceptor
) throw (::com::sun::star::uno::RuntimeException
);
116 virtual void SAL_CALL
createElement( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
117 virtual void SAL_CALL
destroyElement( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
118 virtual ::sal_Bool SAL_CALL
requestElement( const OUString
& ResourceURL
) throw (::com::sun::star::uno::RuntimeException
);
119 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIElement
> SAL_CALL
getElement( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
120 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIElement
> > SAL_CALL
getElements( ) throw (::com::sun::star::uno::RuntimeException
);
121 virtual sal_Bool SAL_CALL
showElement( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
122 virtual sal_Bool SAL_CALL
hideElement( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
123 virtual sal_Bool SAL_CALL
dockWindow( const OUString
& aName
, ::com::sun::star::ui::DockingArea DockingArea
, const ::com::sun::star::awt::Point
& Pos
) throw (::com::sun::star::uno::RuntimeException
);
124 virtual ::sal_Bool SAL_CALL
dockAllWindows( ::sal_Int16 nElementType
) throw (::com::sun::star::uno::RuntimeException
);
125 virtual sal_Bool SAL_CALL
floatWindow( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
126 virtual ::sal_Bool SAL_CALL
lockWindow( const OUString
& ResourceURL
) throw (::com::sun::star::uno::RuntimeException
);
127 virtual ::sal_Bool SAL_CALL
unlockWindow( const OUString
& ResourceURL
) throw (::com::sun::star::uno::RuntimeException
);
128 virtual void SAL_CALL
setElementSize( const OUString
& aName
, const ::com::sun::star::awt::Size
& aSize
) throw (::com::sun::star::uno::RuntimeException
);
129 virtual void SAL_CALL
setElementPos( const OUString
& aName
, const ::com::sun::star::awt::Point
& aPos
) throw (::com::sun::star::uno::RuntimeException
);
130 virtual void SAL_CALL
setElementPosSize( const OUString
& aName
, const ::com::sun::star::awt::Point
& aPos
, const ::com::sun::star::awt::Size
& aSize
) throw (::com::sun::star::uno::RuntimeException
);
131 virtual sal_Bool SAL_CALL
isElementVisible( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
132 virtual sal_Bool SAL_CALL
isElementFloating( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
133 virtual sal_Bool SAL_CALL
isElementDocked( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
134 virtual ::sal_Bool SAL_CALL
isElementLocked( const OUString
& ResourceURL
) throw (::com::sun::star::uno::RuntimeException
);
135 virtual ::com::sun::star::awt::Size SAL_CALL
getElementSize( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
136 virtual ::com::sun::star::awt::Point SAL_CALL
getElementPos( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
137 virtual void SAL_CALL
lock( ) throw (::com::sun::star::uno::RuntimeException
);
138 virtual void SAL_CALL
unlock( ) throw (::com::sun::star::uno::RuntimeException
);
139 virtual void SAL_CALL
doLayout( ) throw (::com::sun::star::uno::RuntimeException
);
140 virtual void SAL_CALL
setVisible( sal_Bool bVisible
) throw (::com::sun::star::uno::RuntimeException
);
141 virtual sal_Bool SAL_CALL
isVisible() throw (::com::sun::star::uno::RuntimeException
);
143 //---------------------------------------------------------------------------------------------------------
144 // XMenuBarMergingAcceptor
145 //---------------------------------------------------------------------------------------------------------
146 virtual sal_Bool SAL_CALL
setMergedMenuBar( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xMergedMenuBar
)
147 throw (::com::sun::star::uno::RuntimeException
);
148 virtual void SAL_CALL
removeMergedMenuBar( ) throw (::com::sun::star::uno::RuntimeException
);
150 //---------------------------------------------------------------------------------------------------------
152 //---------------------------------------------------------------------------------------------------------
153 virtual void SAL_CALL
windowResized( const css::awt::WindowEvent
& aEvent
) throw( css::uno::RuntimeException
);
154 virtual void SAL_CALL
windowMoved( const css::awt::WindowEvent
& aEvent
) throw( css::uno::RuntimeException
);
155 virtual void SAL_CALL
windowShown( const css::lang::EventObject
& aEvent
) throw( css::uno::RuntimeException
);
156 virtual void SAL_CALL
windowHidden( const css::lang::EventObject
& aEvent
) throw( css::uno::RuntimeException
);
158 //---------------------------------------------------------------------------------------------------------
159 // XFrameActionListener
160 //---------------------------------------------------------------------------------------------------------
161 virtual void SAL_CALL
frameAction( const css::frame::FrameActionEvent
& aEvent
) throw ( css::uno::RuntimeException
);
163 //---------------------------------------------------------------------------------------------------------
165 //---------------------------------------------------------------------------------------------------------
166 using cppu::OPropertySetHelper::disposing
;
167 virtual void SAL_CALL
disposing( const css::lang::EventObject
& aEvent
) throw( css::uno::RuntimeException
);
169 //---------------------------------------------------------------------------------------------------------
170 // XUIConfigurationListener
171 //---------------------------------------------------------------------------------------------------------
172 virtual void SAL_CALL
elementInserted( const ::com::sun::star::ui::ConfigurationEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
173 virtual void SAL_CALL
elementRemoved( const ::com::sun::star::ui::ConfigurationEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
174 virtual void SAL_CALL
elementReplaced( const ::com::sun::star::ui::ConfigurationEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
176 //---------------------------------------------------------------------------------------------------------
177 // XLayoutManagerEventBroadcaster
178 //---------------------------------------------------------------------------------------------------------
179 virtual void SAL_CALL
addLayoutManagerEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManagerListener
>& aLayoutManagerListener
) throw (::com::sun::star::uno::RuntimeException
);
180 virtual void SAL_CALL
removeLayoutManagerEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManagerListener
>& aLayoutManagerListener
) throw (::com::sun::star::uno::RuntimeException
);
182 DECL_LINK(MenuBarClose
, void *);
183 DECL_LINK( WindowEventListener
, VclSimpleEvent
* );
185 //---------------------------------------------------------------------------------------------------------
186 // ILayoutNotifications
187 //---------------------------------------------------------------------------------------------------------
188 virtual void requestLayout( Hint eHint
);
190 /// Reading of settings - shared with ToolbarLayoutManager.
191 static sal_Bool
readWindowStateData( const OUString
& rName
, UIElement
& rElementData
,
192 LockHelper
&rLock
, const css::uno::Reference
< css::container::XNameAccess
> &rPersistentWindowState
,
193 GlobalSettings
* &rGlobalSettings
, bool &bInGlobalSettings
,
194 const css::uno::Reference
< css::uno::XComponentContext
> &rComponentContext
);
197 DECL_LINK(AsyncLayoutHdl
, void *);
200 //---------------------------------------------------------------------------------------------------------
202 //---------------------------------------------------------------------------------------------------------
204 //---------------------------------------------------------------------------------------------------------
206 //---------------------------------------------------------------------------------------------------------
207 void impl_clearUpMenuBar();
208 void implts_reset( sal_Bool bAttach
);
209 void implts_updateMenuBarClose();
210 sal_Bool
implts_resetMenuBar();
212 //---------------------------------------------------------------------------------------------------------
214 //---------------------------------------------------------------------------------------------------------
216 sal_Bool
implts_unlock();
218 //---------------------------------------------------------------------------------------------------------
220 //---------------------------------------------------------------------------------------------------------
221 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIElement
> implts_findElement( const OUString
& aName
);
223 void implts_writeNewStateData( const OUString aName
, const ::com::sun::star::uno::Reference
< com::sun::star::awt::XWindow
>& xWindow
);
224 sal_Bool
implts_readWindowStateData( const OUString
& rName
, UIElement
& rElementData
);
225 void implts_writeWindowStateData( const OUString
& rName
, const UIElement
& rElementData
);
226 void implts_setElementData( UIElement
& rUIElement
, const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XDockableWindow
>& rDockWindow
);
227 void implts_sortUIElements();
228 void implts_destroyElements();
229 void implts_toggleFloatingUIElementsVisibility( sal_Bool bActive
);
230 void implts_reparentChildWindows();
231 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIElement
> implts_createDockingWindow( const OUString
& aElementName
);
233 sal_Bool
implts_isEmbeddedLayoutManager() const;
234 sal_Int16
implts_getCurrentSymbolsSize();
235 sal_Int16
implts_getCurrentSymbolsStyle();
236 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIElement
> implts_createElement( const OUString
& aName
);
239 sal_Bool
implts_resizeContainerWindow( const ::com::sun::star::awt::Size
& rContainerSize
, const ::com::sun::star::awt::Point
& rComponentPos
);
240 ::Size
implts_getTopBottomDockingAreaSizes();
241 ::Size
implts_getContainerWindowOutputSize();
243 void implts_setDockingAreaWindowSizes( const css::awt::Rectangle
& rBorderSpace
);
244 ::com::sun::star::awt::Rectangle
implts_calcDockingAreaSizes();
245 sal_Bool
implts_doLayout( sal_Bool bForceRequestBorderSpace
, sal_Bool bOuterResize
);
246 void implts_doLayout_notify( sal_Bool bOuterResize
);
248 // internal methods to control status/progress bar
249 ::Size
implts_getStatusBarSize();
250 void implts_destroyStatusBar();
251 void implts_createStatusBar( const OUString
& rStatusBarName
);
252 void implts_createProgressBar();
253 void implts_destroyProgressBar();
254 void implts_setStatusBarPosSize( const ::Point
& rPos
, const ::Size
& rSize
);
255 sal_Bool
implts_showStatusBar( sal_Bool bStoreState
=sal_False
);
256 sal_Bool
implts_hideStatusBar( sal_Bool bStoreState
=sal_False
);
257 void implts_readStatusBarState( const OUString
& rStatusBarName
);
258 sal_Bool
implts_showProgressBar();
259 sal_Bool
implts_hideProgressBar();
260 void implts_backupProgressBarWrapper();
261 void implts_setOffset( const sal_Int32 nBottomOffset
);
263 void implts_setInplaceMenuBar(
264 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xMergedMenuBar
)
265 throw (::com::sun::star::uno::RuntimeException
);
266 void implts_resetInplaceMenuBar()
267 throw (::com::sun::star::uno::RuntimeException
);
269 void implts_setVisibleState( sal_Bool bShow
);
270 void implts_updateUIElementsVisibleState( sal_Bool bShow
);
271 void implts_setCurrentUIVisibility( sal_Bool bShow
);
272 void implts_notifyListeners( short nEvent
, ::com::sun::star::uno::Any aInfoParam
);
274 DECL_LINK( OptionsChanged
, void* );
275 DECL_LINK( SettingsChanged
, void* );
277 //---------------------------------------------------------------------------------------------------------
278 // OPropertySetHelper
279 //---------------------------------------------------------------------------------------------------------
280 virtual sal_Bool SAL_CALL
convertFastPropertyValue ( com::sun::star::uno::Any
& aConvertedValue
,
281 com::sun::star::uno::Any
& aOldValue
,
283 const com::sun::star::uno::Any
& aValue
) throw( com::sun::star::lang::IllegalArgumentException
);
284 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
,
285 const com::sun::star::uno::Any
& aValue
) throw( com::sun::star::uno::Exception
);
286 using cppu::OPropertySetHelper::getFastPropertyValue
;
287 virtual void SAL_CALL
getFastPropertyValue( com::sun::star::uno::Any
& aValue
,
288 sal_Int32 nHandle
) const;
289 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
290 virtual ::com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException
);
292 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xSMGR
; /** reference to factory, which has created this instance. */
293 css::uno::Reference
< css::util::XURLTransformer
> m_xURLTransformer
;
294 css::uno::Reference
< css::frame::XFrame
> m_xFrame
;
295 css::uno::Reference
< ::com::sun::star::ui::XUIConfigurationManager
> m_xModuleCfgMgr
;
296 css::uno::Reference
< ::com::sun::star::ui::XUIConfigurationManager
> m_xDocCfgMgr
;
297 css::uno::WeakReference
< css::frame::XModel
> m_xModel
;
298 css::uno::Reference
< css::awt::XWindow
> m_xContainerWindow
;
299 css::uno::Reference
< css::awt::XTopWindow2
> m_xContainerTopWindow
;
300 sal_Int32 m_nLockCount
;
302 bool m_bInplaceMenuSet
;
303 bool m_bDockingInProgress
;
305 bool m_bComponentAttached
;
308 bool m_bParentWindowVisible
;
309 bool m_bMustDoLayout
;
310 bool m_bAutomaticToolbars
;
311 bool m_bStoreWindowState
;
312 bool m_bHideCurrentUI
;
313 bool m_bGlobalSettings
;
314 bool m_bPreserveContentSize
;
315 bool m_bMenuBarCloser
;
316 css::awt::Rectangle m_aDockingArea
;
317 css::uno::Reference
< ::com::sun::star::ui::XDockingAreaAcceptor
> m_xDockingAreaAcceptor
;
318 css::uno::Reference
< ::com::sun::star::lang::XComponent
> m_xInplaceMenuBar
;
319 MenuBarManager
* m_pInplaceMenuBar
;
320 css::uno::Reference
< ::com::sun::star::ui::XUIElement
> m_xMenuBar
;
321 UIElement m_aStatusBarElement
;
322 UIElement m_aProgressBarElement
;
323 com::sun::star::uno::Reference
< ::com::sun::star::ui::XUIElement
> m_xProgressBarBackup
;
324 css::uno::Reference
< ::com::sun::star::frame::XModuleManager2
> m_xModuleManager
;
325 css::uno::Reference
< ::com::sun::star::ui::XUIElementFactoryManager
> m_xUIElementFactoryManager
;
326 css::uno::Reference
< ::com::sun::star::container::XNameAccess
> m_xPersistentWindowState
;
327 css::uno::Reference
< ::com::sun::star::container::XNameAccess
> m_xPersistentWindowStateSupplier
;
328 GlobalSettings
* m_pGlobalSettings
;
329 OUString m_aModuleIdentifier
;
330 sal_Int16 m_eSymbolsSize
;
331 sal_Int16 m_eSymbolsStyle
;
332 Timer m_aAsyncLayoutTimer
;
333 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer
; // container for ALL Listener
334 ToolbarLayoutManager
* m_pToolbarManager
;
335 css::uno::Reference
< ::com::sun::star::ui::XUIConfigurationListener
> m_xToolbarManager
;
337 friend class detail::InfoHelperBuilder
;
340 } // namespace framework
342 #endif // __FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_
344 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */