Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_FRAMEWORK_INC_SERVICES_LAYOUTMANAGER_HXX
21 : #define INCLUDED_FRAMEWORK_INC_SERVICES_LAYOUTMANAGER_HXX
22 :
23 : #include <macros/xinterface.hxx>
24 : #include <macros/xtypeprovider.hxx>
25 : #include <properties.h>
26 : #include <stdtypes.h>
27 : #include <uielement/menubarmanager.hxx>
28 : #include <framework/addonsoptions.hxx>
29 : #include <uielement/uielement.hxx>
30 : #include <helper/ilayoutnotifications.hxx>
31 :
32 : #include <com/sun/star/lang/XServiceInfo.hpp>
33 : #include <com/sun/star/lang/XTypeProvider.hpp>
34 : #include <com/sun/star/frame/XLayoutManager2.hpp>
35 : #include <com/sun/star/ui/XUIConfigurationManager.hpp>
36 : #include <com/sun/star/ui/XUIConfiguration.hpp>
37 : #include <com/sun/star/frame/XModuleManager2.hpp>
38 : #include <com/sun/star/frame/XFrameActionListener.hpp>
39 : #include <com/sun/star/awt/XWindowListener.hpp>
40 : #include <com/sun/star/util/XURLTransformer.hpp>
41 : #include <com/sun/star/ui/XUIElementFactory.hpp>
42 : #include <com/sun/star/ui/XUIElementFactoryManager.hpp>
43 : #include <com/sun/star/ui/DockingArea.hpp>
44 : #include <com/sun/star/awt/XTopWindow2.hpp>
45 : #include <com/sun/star/awt/XDockableWindow.hpp>
46 : #include <com/sun/star/awt/XDockableWindowListener.hpp>
47 : #include <com/sun/star/frame/XMenuBarMergingAcceptor.hpp>
48 : #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp>
49 :
50 : #include <cppuhelper/basemutex.hxx>
51 : #include <cppuhelper/propshlp.hxx>
52 : #include <cppuhelper/implbase3.hxx>
53 : #include <cppuhelper/interfacecontainer.hxx>
54 : #include <cppuhelper/supportsservice.hxx>
55 : #include <comphelper/propertycontainer.hxx>
56 : #include <tools/wintypes.hxx>
57 : #include <svtools/miscopt.hxx>
58 : #include <vcl/toolbox.hxx>
59 : #include <vcl/timer.hxx>
60 :
61 : class MenuBar;
62 : namespace framework
63 : {
64 : class ToolbarLayoutManager;
65 : class GlobalSettings;
66 : namespace detail
67 : {
68 : class InfoHelperBuilder;
69 : }
70 : typedef ::cppu::WeakImplHelper3 < ::com::sun::star::lang::XServiceInfo
71 : , ::com::sun::star::frame::XLayoutManager2
72 : , ::com::sun::star::awt::XWindowListener
73 : > LayoutManager_Base;
74 : typedef ::comphelper::OPropertyContainer LayoutManager_PBase;
75 : class LayoutManager : public LayoutManager_Base ,
76 : private cppu::BaseMutex,
77 : public ::cppu::OBroadcastHelper ,
78 : public ILayoutNotifications ,
79 : public LayoutManager_PBase
80 : {
81 : public:
82 : enum { DOCKINGAREAS_COUNT = 4 };
83 :
84 : LayoutManager( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xContext );
85 : virtual ~LayoutManager();
86 :
87 : /** declaration of XInterface, XTypeProvider, XServiceInfo */
88 : FWK_DECLARE_XINTERFACE
89 : FWK_DECLARE_XTYPEPROVIDER
90 0 : virtual OUString SAL_CALL getImplementationName()
91 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
92 : {
93 0 : return OUString("com.sun.star.comp.framework.LayoutManager");
94 : }
95 :
96 0 : virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
97 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
98 : {
99 0 : return cppu::supportsService(this, ServiceName);
100 : }
101 :
102 0 : virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
103 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
104 : {
105 0 : css::uno::Sequence< OUString > aSeq(1);
106 0 : aSeq[0] = OUString("com.sun.star.frame.LayoutManager");
107 0 : return aSeq;
108 : }
109 :
110 : // XLayoutManager
111 : virtual void SAL_CALL attachFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 : virtual void SAL_CALL reset() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 : virtual ::com::sun::star::awt::Rectangle SAL_CALL getCurrentDockingArea( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > SAL_CALL getDockingAreaAcceptor() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 : virtual void SAL_CALL setDockingAreaAcceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor >& xDockingAreaAcceptor ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 : virtual void SAL_CALL createElement( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
117 : virtual void SAL_CALL destroyElement( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 : virtual sal_Bool SAL_CALL requestElement( const OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL getElement( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
121 : virtual sal_Bool SAL_CALL showElement( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 : virtual sal_Bool SAL_CALL hideElement( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
124 : virtual sal_Bool SAL_CALL dockAllWindows( ::sal_Int16 nElementType ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
125 : virtual sal_Bool SAL_CALL floatWindow( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 : virtual sal_Bool SAL_CALL lockWindow( const OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 : virtual sal_Bool SAL_CALL unlockWindow( const OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
128 : virtual void SAL_CALL setElementSize( const OUString& aName, const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 : virtual void SAL_CALL setElementPos( const OUString& aName, const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
131 : virtual sal_Bool SAL_CALL isElementVisible( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
132 : virtual sal_Bool SAL_CALL isElementFloating( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
133 : virtual sal_Bool SAL_CALL isElementDocked( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 : virtual sal_Bool SAL_CALL isElementLocked( const OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135 : virtual ::com::sun::star::awt::Size SAL_CALL getElementSize( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
136 : virtual ::com::sun::star::awt::Point SAL_CALL getElementPos( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
137 : virtual void SAL_CALL lock( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
138 : virtual void SAL_CALL unlock( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
139 : virtual void SAL_CALL doLayout( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
140 : virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 : virtual sal_Bool SAL_CALL isVisible() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 :
143 : // XMenuBarMergingAcceptor
144 :
145 : virtual sal_Bool SAL_CALL setMergedMenuBar( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xMergedMenuBar )
146 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 : virtual void SAL_CALL removeMergedMenuBar( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
148 :
149 : // XWindowListener
150 : virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
151 : virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
152 : virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
153 : virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
154 :
155 : // XFrameActionListener
156 : virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
157 :
158 : // XEventListener
159 : using cppu::OPropertySetHelper::disposing;
160 : virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
161 :
162 : // XUIConfigurationListener
163 : virtual void SAL_CALL elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
164 : virtual void SAL_CALL elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
165 : virtual void SAL_CALL elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
166 :
167 : // XLayoutManagerEventBroadcaster
168 : virtual void SAL_CALL addLayoutManagerEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManagerListener >& aLayoutManagerListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
169 : virtual void SAL_CALL removeLayoutManagerEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManagerListener >& aLayoutManagerListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
170 :
171 : DECL_LINK(MenuBarClose, void *);
172 : DECL_LINK( WindowEventListener, VclSimpleEvent* );
173 :
174 : // ILayoutNotifications
175 :
176 : virtual void requestLayout( Hint eHint ) SAL_OVERRIDE;
177 :
178 : /// Reading of settings - shared with ToolbarLayoutManager.
179 : static bool readWindowStateData( const OUString& rName, UIElement& rElementData,
180 : const css::uno::Reference< css::container::XNameAccess > &rPersistentWindowState,
181 : GlobalSettings* &rGlobalSettings, bool &bInGlobalSettings,
182 : const css::uno::Reference< css::uno::XComponentContext > &rComponentContext );
183 :
184 : protected:
185 : DECL_LINK(AsyncLayoutHdl, void *);
186 :
187 : private:
188 :
189 : // helper
190 :
191 : // menu bar
192 :
193 : void impl_clearUpMenuBar();
194 : void implts_reset( bool bAttach );
195 : void implts_updateMenuBarClose();
196 : bool implts_resetMenuBar();
197 :
198 : // locking
199 :
200 : void implts_lock();
201 : bool implts_unlock();
202 :
203 : // query
204 :
205 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > implts_findElement( const OUString& aName );
206 :
207 : void implts_writeNewStateData( const OUString& aName, const ::com::sun::star::uno::Reference< com::sun::star::awt::XWindow >& xWindow );
208 : bool implts_readWindowStateData( const OUString& rName, UIElement& rElementData );
209 : void implts_writeWindowStateData( const OUString& rName, const UIElement& rElementData );
210 : void implts_setElementData( UIElement& rUIElement, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindow >& rDockWindow );
211 : void implts_sortUIElements();
212 : void implts_destroyElements();
213 : void implts_toggleFloatingUIElementsVisibility( bool bActive );
214 : void implts_reparentChildWindows();
215 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > implts_createDockingWindow( const OUString& aElementName );
216 :
217 : bool implts_isEmbeddedLayoutManager() const;
218 : sal_Int16 implts_getCurrentSymbolsSize();
219 : sal_Int16 implts_getCurrentSymbolsStyle();
220 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > implts_createElement( const OUString& aName );
221 :
222 : // layouting methods
223 : bool implts_resizeContainerWindow( const ::com::sun::star::awt::Size& rContainerSize, const ::com::sun::star::awt::Point& rComponentPos );
224 : ::Size implts_getTopBottomDockingAreaSizes();
225 : ::Size implts_getContainerWindowOutputSize();
226 :
227 : void implts_setDockingAreaWindowSizes( const css::awt::Rectangle& rBorderSpace );
228 : ::com::sun::star::awt::Rectangle implts_calcDockingAreaSizes();
229 : bool implts_doLayout( bool bForceRequestBorderSpace, bool bOuterResize );
230 : void implts_doLayout_notify( bool bOuterResize );
231 :
232 : // internal methods to control status/progress bar
233 : ::Size implts_getStatusBarSize();
234 : void implts_destroyStatusBar();
235 : void implts_createStatusBar( const OUString& rStatusBarName );
236 : void implts_createProgressBar();
237 : void implts_destroyProgressBar();
238 : void implts_setStatusBarPosSize( const ::Point& rPos, const ::Size& rSize );
239 : bool implts_showStatusBar( bool bStoreState=false );
240 : bool implts_hideStatusBar( bool bStoreState=false );
241 : void implts_readStatusBarState( const OUString& rStatusBarName );
242 : bool implts_showProgressBar();
243 : bool implts_hideProgressBar();
244 : void implts_backupProgressBarWrapper();
245 : void implts_setOffset( const sal_Int32 nBottomOffset );
246 :
247 : void implts_setInplaceMenuBar(
248 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xMergedMenuBar )
249 : throw (::com::sun::star::uno::RuntimeException);
250 : void implts_resetInplaceMenuBar()
251 : throw (::com::sun::star::uno::RuntimeException);
252 :
253 : void implts_setVisibleState( bool bShow );
254 : void implts_updateUIElementsVisibleState( bool bShow );
255 : void implts_setCurrentUIVisibility( bool bShow );
256 : void implts_notifyListeners( short nEvent, ::com::sun::star::uno::Any aInfoParam );
257 :
258 : DECL_LINK( OptionsChanged, void* );
259 : DECL_LINK( SettingsChanged, void* );
260 :
261 : // OPropertySetHelper
262 :
263 : virtual sal_Bool SAL_CALL convertFastPropertyValue ( com::sun::star::uno::Any& aConvertedValue ,
264 : com::sun::star::uno::Any& aOldValue ,
265 : sal_Int32 nHandle ,
266 : const com::sun::star::uno::Any& aValue ) throw( com::sun::star::lang::IllegalArgumentException ) SAL_OVERRIDE;
267 : virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
268 : const com::sun::star::uno::Any& aValue ) throw( com::sun::star::uno::Exception, std::exception ) SAL_OVERRIDE;
269 : using cppu::OPropertySetHelper::getFastPropertyValue;
270 : virtual void SAL_CALL getFastPropertyValue( com::sun::star::uno::Any& aValue ,
271 : sal_Int32 nHandle ) const SAL_OVERRIDE;
272 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
273 : virtual ::com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
274 :
275 : css::uno::Reference< css::uno::XComponentContext > m_xContext; /** reference to factory, which has created this instance. */
276 : css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer;
277 : css::uno::Reference< css::frame::XFrame > m_xFrame;
278 : css::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xModuleCfgMgr;
279 : css::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xDocCfgMgr;
280 : css::uno::WeakReference< css::frame::XModel > m_xModel;
281 : css::uno::Reference< css::awt::XWindow > m_xContainerWindow;
282 : css::uno::Reference< css::awt::XTopWindow2 > m_xContainerTopWindow;
283 : sal_Int32 m_nLockCount;
284 : bool m_bActive;
285 : bool m_bInplaceMenuSet;
286 : bool m_bDockingInProgress;
287 : bool m_bMenuVisible;
288 : bool m_bComponentAttached;
289 : bool m_bDoLayout;
290 : bool m_bVisible;
291 : bool m_bParentWindowVisible;
292 : bool m_bMustDoLayout;
293 : bool m_bAutomaticToolbars;
294 : bool m_bStoreWindowState;
295 : bool m_bHideCurrentUI;
296 : bool m_bGlobalSettings;
297 : bool m_bPreserveContentSize;
298 : bool m_bMenuBarCloser;
299 : css::awt::Rectangle m_aDockingArea;
300 : css::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > m_xDockingAreaAcceptor;
301 : css::uno::Reference< ::com::sun::star::lang::XComponent > m_xInplaceMenuBar;
302 : MenuBarManager* m_pInplaceMenuBar;
303 : css::uno::Reference< ::com::sun::star::ui::XUIElement > m_xMenuBar;
304 : UIElement m_aStatusBarElement;
305 : UIElement m_aProgressBarElement;
306 : com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > m_xProgressBarBackup;
307 : css::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager;
308 : css::uno::Reference< ::com::sun::star::ui::XUIElementFactoryManager > m_xUIElementFactoryManager;
309 : css::uno::Reference< ::com::sun::star::container::XNameAccess > m_xPersistentWindowState;
310 : css::uno::Reference< ::com::sun::star::container::XNameAccess > m_xPersistentWindowStateSupplier;
311 : GlobalSettings* m_pGlobalSettings;
312 : OUString m_aModuleIdentifier;
313 : Timer m_aAsyncLayoutTimer;
314 : ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; // container for ALL Listener
315 : ToolbarLayoutManager* m_pToolbarManager;
316 : css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener > m_xToolbarManager;
317 :
318 : friend class detail::InfoHelperBuilder;
319 : };
320 :
321 : } // namespace framework
322 :
323 : #endif // INCLUDED_FRAMEWORK_INC_SERVICES_LAYOUTMANAGER_HXX
324 :
325 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|