Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / framework / inc / services / layoutmanager.hxx
blobeaecc6fa8e8751723aa4ba5c2137723411ed10b4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 INCLUDED_FRAMEWORK_INC_SERVICES_LAYOUTMANAGER_HXX
21 #define INCLUDED_FRAMEWORK_INC_SERVICES_LAYOUTMANAGER_HXX
23 #include <properties.h>
24 #include <stdtypes.h>
25 #include <uielement/menubarmanager.hxx>
26 #include <framework/addonsoptions.hxx>
27 #include <uielement/uielement.hxx>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/lang/XTypeProvider.hpp>
31 #include <com/sun/star/frame/XLayoutManager2.hpp>
32 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
33 #include <com/sun/star/ui/XUIConfiguration.hpp>
34 #include <com/sun/star/frame/XModuleManager2.hpp>
35 #include <com/sun/star/awt/XWindowListener.hpp>
36 #include <com/sun/star/util/XURLTransformer.hpp>
37 #include <com/sun/star/ui/XUIElementFactory.hpp>
38 #include <com/sun/star/ui/XUIElementFactoryManager.hpp>
39 #include <com/sun/star/ui/DockingArea.hpp>
40 #include <com/sun/star/awt/XTopWindow2.hpp>
41 #include <com/sun/star/awt/XDockableWindow.hpp>
42 #include <com/sun/star/awt/XDockableWindowListener.hpp>
44 #include <cppuhelper/basemutex.hxx>
45 #include <cppuhelper/propshlp.hxx>
46 #include <cppuhelper/implbase.hxx>
47 #include <cppuhelper/interfacecontainer.hxx>
48 #include <cppuhelper/supportsservice.hxx>
49 #include <comphelper/propertycontainer.hxx>
50 #include <comphelper/uno3.hxx>
51 #include <tools/wintypes.hxx>
52 #include <svtools/miscopt.hxx>
53 #include <vcl/toolbox.hxx>
54 #include <vcl/timer.hxx>
56 class MenuBar;
57 namespace framework
60 class ToolbarLayoutManager;
61 class GlobalSettings;
62 namespace detail
64 class InfoHelperBuilder;
66 typedef ::cppu::WeakImplHelper < css::lang::XServiceInfo
67 , css::frame::XLayoutManager2
68 , css::awt::XWindowListener
69 > LayoutManager_Base;
70 typedef ::comphelper::OPropertyContainer LayoutManager_PBase;
71 class LayoutManager final : public LayoutManager_Base ,
72 private cppu::BaseMutex,
73 public ::cppu::OBroadcastHelper ,
74 public LayoutManager_PBase
76 public:
77 LayoutManager( const css::uno::Reference< css::uno::XComponentContext >& xContext );
78 virtual ~LayoutManager() override;
80 /** declaration of XInterface, XTypeProvider, XServiceInfo */
81 DECLARE_XINTERFACE()
82 DECLARE_XTYPEPROVIDER()
83 virtual OUString SAL_CALL getImplementationName() override
85 return OUString("com.sun.star.comp.framework.LayoutManager");
88 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
90 return cppu::supportsService(this, ServiceName);
93 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
95 css::uno::Sequence< OUString > aSeq { "com.sun.star.frame.LayoutManager" };
96 return aSeq;
99 // XLayoutManager
100 virtual void SAL_CALL attachFrame( const css::uno::Reference< css::frame::XFrame >& Frame ) override;
101 virtual void SAL_CALL reset() override;
102 virtual css::awt::Rectangle SAL_CALL getCurrentDockingArea( ) override;
103 virtual css::uno::Reference< css::ui::XDockingAreaAcceptor > SAL_CALL getDockingAreaAcceptor() override;
104 virtual void SAL_CALL setDockingAreaAcceptor( const css::uno::Reference< css::ui::XDockingAreaAcceptor >& xDockingAreaAcceptor ) final override;
105 virtual void SAL_CALL createElement( const OUString& aName ) override;
106 virtual void SAL_CALL destroyElement( const OUString& aName ) override;
107 virtual sal_Bool SAL_CALL requestElement( const OUString& ResourceURL ) override;
108 virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL getElement( const OUString& aName ) override;
109 virtual css::uno::Sequence< css::uno::Reference< css::ui::XUIElement > > SAL_CALL getElements( ) override;
110 virtual sal_Bool SAL_CALL showElement( const OUString& aName ) override;
111 virtual sal_Bool SAL_CALL hideElement( const OUString& aName ) override;
112 virtual sal_Bool SAL_CALL dockWindow( const OUString& aName, css::ui::DockingArea DockingArea, const css::awt::Point& Pos ) override;
113 virtual sal_Bool SAL_CALL dockAllWindows( ::sal_Int16 nElementType ) override;
114 virtual sal_Bool SAL_CALL floatWindow( const OUString& aName ) override;
115 virtual sal_Bool SAL_CALL lockWindow( const OUString& ResourceURL ) override;
116 virtual sal_Bool SAL_CALL unlockWindow( const OUString& ResourceURL ) override;
117 virtual void SAL_CALL setElementSize( const OUString& aName, const css::awt::Size& aSize ) override;
118 virtual void SAL_CALL setElementPos( const OUString& aName, const css::awt::Point& aPos ) override;
119 virtual void SAL_CALL setElementPosSize( const OUString& aName, const css::awt::Point& aPos, const css::awt::Size& aSize ) override;
120 virtual sal_Bool SAL_CALL isElementVisible( const OUString& aName ) override;
121 virtual sal_Bool SAL_CALL isElementFloating( const OUString& aName ) override;
122 virtual sal_Bool SAL_CALL isElementDocked( const OUString& aName ) override;
123 virtual sal_Bool SAL_CALL isElementLocked( const OUString& ResourceURL ) override;
124 virtual css::awt::Size SAL_CALL getElementSize( const OUString& aName ) override;
125 virtual css::awt::Point SAL_CALL getElementPos( const OUString& aName ) override;
126 virtual void SAL_CALL lock( ) override;
127 virtual void SAL_CALL unlock( ) override;
128 virtual void SAL_CALL doLayout( ) override;
129 virtual void SAL_CALL setVisible( sal_Bool bVisible ) override;
130 virtual sal_Bool SAL_CALL isVisible() override;
132 // XMenuBarMergingAcceptor
134 virtual sal_Bool SAL_CALL setMergedMenuBar( const css::uno::Reference< css::container::XIndexAccess >& xMergedMenuBar ) override;
135 virtual void SAL_CALL removeMergedMenuBar( ) override;
137 // XWindowListener
138 virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) override;
139 virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) override;
140 virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) override;
141 virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) override;
143 // XFrameActionListener
144 virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) override;
146 // XEventListener
147 using cppu::OPropertySetHelper::disposing;
148 virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override;
150 // XUIConfigurationListener
151 virtual void SAL_CALL elementInserted( const css::ui::ConfigurationEvent& Event ) override;
152 virtual void SAL_CALL elementRemoved( const css::ui::ConfigurationEvent& Event ) override;
153 virtual void SAL_CALL elementReplaced( const css::ui::ConfigurationEvent& Event ) override;
155 // XLayoutManagerEventBroadcaster
156 virtual void SAL_CALL addLayoutManagerEventListener( const css::uno::Reference< css::frame::XLayoutManagerListener >& aLayoutManagerListener ) override;
157 virtual void SAL_CALL removeLayoutManagerEventListener( const css::uno::Reference< css::frame::XLayoutManagerListener >& aLayoutManagerListener ) override;
159 DECL_LINK( MenuBarClose, void *, void);
160 DECL_LINK( WindowEventListener, VclWindowEvent&, void );
162 // called from ToolbarLayoutManager
163 void requestLayout();
165 /// Reading of settings - shared with ToolbarLayoutManager.
166 static bool readWindowStateData( const OUString& rName, UIElement& rElementData,
167 const css::uno::Reference< css::container::XNameAccess > &rPersistentWindowState,
168 std::unique_ptr<GlobalSettings> &rGlobalSettings, bool &bInGlobalSettings,
169 const css::uno::Reference< css::uno::XComponentContext > &rComponentContext );
171 private:
172 DECL_LINK(AsyncLayoutHdl, Timer *, void);
174 // menu bar
176 void impl_clearUpMenuBar();
177 void implts_reset( bool bAttach );
178 void implts_updateMenuBarClose();
179 bool implts_resetMenuBar();
181 // locking
183 void implts_lock();
184 bool implts_unlock();
186 // query
188 css::uno::Reference< css::ui::XUIElement > implts_findElement( const OUString& aName );
190 bool implts_readWindowStateData( const OUString& rName, UIElement& rElementData );
191 void implts_writeWindowStateData( const OUString& rName, const UIElement& rElementData );
192 void implts_destroyElements();
193 void implts_toggleFloatingUIElementsVisibility( bool bActive );
194 void implts_reparentChildWindows();
195 css::uno::Reference< css::ui::XUIElement > implts_createDockingWindow( const OUString& aElementName );
197 bool implts_isEmbeddedLayoutManager() const;
198 css::uno::Reference< css::ui::XUIElement > implts_createElement( const OUString& aName );
200 // layouting methods
201 bool implts_resizeContainerWindow( const css::awt::Size& rContainerSize, const css::awt::Point& rComponentPos );
202 ::Size implts_getContainerWindowOutputSize();
204 void implts_setDockingAreaWindowSizes();
205 css::awt::Rectangle implts_calcDockingAreaSizes();
206 bool implts_doLayout( bool bForceRequestBorderSpace, bool bOuterResize );
207 void implts_doLayout_notify( bool bOuterResize );
209 // internal methods to control status/progress bar
210 ::Size implts_getStatusBarSize();
211 void implts_destroyStatusBar();
212 void implts_createStatusBar( const OUString& rStatusBarName );
213 void implts_createProgressBar();
214 void implts_destroyProgressBar();
215 void implts_setStatusBarPosSize( const ::Point& rPos, const ::Size& rSize );
216 bool implts_showStatusBar( bool bStoreState=false );
217 bool implts_hideStatusBar( bool bStoreState=false );
218 void implts_readStatusBarState( const OUString& rStatusBarName );
219 bool implts_showProgressBar();
220 bool implts_hideProgressBar();
221 void implts_backupProgressBarWrapper();
222 void implts_setOffset( const sal_Int32 nBottomOffset );
224 /// @throws css::uno::RuntimeException
225 void implts_setInplaceMenuBar(
226 const css::uno::Reference< css::container::XIndexAccess >& xMergedMenuBar );
227 /// @throws css::uno::RuntimeException
228 void implts_resetInplaceMenuBar();
230 void implts_setVisibleState( bool bShow );
231 void implts_updateUIElementsVisibleState( bool bShow );
232 void implts_setCurrentUIVisibility( bool bShow );
233 void implts_notifyListeners(short nEvent, const css::uno::Any& rInfoParam);
235 // OPropertySetHelper
237 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
238 const css::uno::Any& aValue ) override;
239 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
240 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
242 css::uno::Reference< css::uno::XComponentContext > m_xContext; /** reference to factory, which has created this instance. */
243 css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer;
244 css::uno::Reference< css::frame::XFrame > m_xFrame;
245 css::uno::Reference< css::ui::XUIConfigurationManager > m_xModuleCfgMgr;
246 css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocCfgMgr;
247 css::uno::WeakReference< css::frame::XModel > m_xModel;
248 css::uno::Reference< css::awt::XWindow > m_xContainerWindow;
249 css::uno::Reference< css::awt::XTopWindow2 > m_xContainerTopWindow;
250 sal_Int32 m_nLockCount;
251 bool m_bInplaceMenuSet;
252 bool m_bMenuVisible;
253 bool m_bVisible;
254 bool m_bParentWindowVisible;
255 bool m_bMustDoLayout;
256 bool m_bAutomaticToolbars;
257 bool m_bHideCurrentUI;
258 bool m_bGlobalSettings;
259 bool m_bPreserveContentSize;
260 bool m_bMenuBarCloseButton;
261 css::awt::Rectangle m_aDockingArea;
262 css::uno::Reference< css::ui::XDockingAreaAcceptor > m_xDockingAreaAcceptor;
263 rtl::Reference< MenuBarManager > m_xInplaceMenuBar;
264 css::uno::Reference< css::ui::XUIElement > m_xMenuBar;
265 UIElement m_aStatusBarElement;
266 UIElement m_aProgressBarElement;
267 css::uno::Reference< css::ui::XUIElement > m_xProgressBarBackup;
268 css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
269 css::uno::Reference< css::ui::XUIElementFactoryManager > m_xUIElementFactoryManager;
270 css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowState;
271 css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowStateSupplier;
272 std::unique_ptr<GlobalSettings> m_pGlobalSettings;
273 OUString m_aModuleIdentifier;
274 Timer m_aAsyncLayoutTimer;
275 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; // container for ALL Listener
276 rtl::Reference< ToolbarLayoutManager > m_xToolbarManager;
278 friend class detail::InfoHelperBuilder;
281 } // namespace framework
283 #endif // INCLUDED_FRAMEWORK_INC_SERVICES_LAYOUTMANAGER_HXX
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */