LibreOffice Module framework (master) 1
layoutmanager.hxx
Go to the documentation of this file.
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#pragma once
21
24
25#include <com/sun/star/lang/XServiceInfo.hpp>
26#include <com/sun/star/frame/XLayoutManager2.hpp>
27#include <com/sun/star/ui/XUIConfigurationManager.hpp>
28#include <com/sun/star/frame/XModuleManager2.hpp>
29#include <com/sun/star/awt/XWindowListener.hpp>
30#include <com/sun/star/util/XURLTransformer.hpp>
31#include <com/sun/star/ui/XUIElementFactoryManager.hpp>
32#include <com/sun/star/ui/DockingArea.hpp>
33#include <com/sun/star/awt/XTopWindow2.hpp>
34
41#include <comphelper/uno3.hxx>
42#include <vcl/timer.hxx>
43
44class MenuBar;
45namespace framework
46{
47
48 class ToolbarLayoutManager;
49 class GlobalSettings;
50 namespace detail
51 {
52 class InfoHelperBuilder;
53 }
54 typedef ::cppu::WeakImplHelper < css::lang::XServiceInfo
55 , css::frame::XLayoutManager2
56 , css::awt::XWindowListener
59 class LayoutManager final : public LayoutManager_Base ,
60 private cppu::BaseMutex,
63 {
64 public:
65 LayoutManager( const css::uno::Reference< css::uno::XComponentContext >& xContext );
66 virtual ~LayoutManager() override;
67
71 virtual OUString SAL_CALL getImplementationName() override
72 {
73 return "com.sun.star.comp.framework.LayoutManager";
74 }
75
76 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
77 {
79 }
80
81 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
82 {
83 css::uno::Sequence< OUString > aSeq { "com.sun.star.frame.LayoutManager" };
84 return aSeq;
85 }
86
87 // XLayoutManager
88 virtual void SAL_CALL attachFrame( const css::uno::Reference< css::frame::XFrame >& Frame ) override;
89 virtual void SAL_CALL reset() override;
90 virtual css::awt::Rectangle SAL_CALL getCurrentDockingArea( ) override;
91 virtual css::uno::Reference< css::ui::XDockingAreaAcceptor > SAL_CALL getDockingAreaAcceptor() override;
92 virtual void SAL_CALL setDockingAreaAcceptor( const css::uno::Reference< css::ui::XDockingAreaAcceptor >& xDockingAreaAcceptor ) final override;
93 virtual void SAL_CALL createElement( const OUString& aName ) override;
94 virtual void SAL_CALL destroyElement( const OUString& aName ) override;
95 virtual sal_Bool SAL_CALL requestElement( const OUString& ResourceURL ) override;
96 virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL getElement( const OUString& aName ) override;
97 virtual css::uno::Sequence< css::uno::Reference< css::ui::XUIElement > > SAL_CALL getElements( ) override;
98 virtual sal_Bool SAL_CALL showElement( const OUString& aName ) override;
99 virtual sal_Bool SAL_CALL hideElement( const OUString& aName ) override;
100 virtual sal_Bool SAL_CALL dockWindow( const OUString& aName, css::ui::DockingArea DockingArea, const css::awt::Point& Pos ) override;
101 virtual sal_Bool SAL_CALL dockAllWindows( ::sal_Int16 nElementType ) override;
102 virtual sal_Bool SAL_CALL floatWindow( const OUString& aName ) override;
103 virtual sal_Bool SAL_CALL lockWindow( const OUString& ResourceURL ) override;
104 virtual sal_Bool SAL_CALL unlockWindow( const OUString& ResourceURL ) override;
105 virtual void SAL_CALL setElementSize( const OUString& aName, const css::awt::Size& aSize ) override;
106 virtual void SAL_CALL setElementPos( const OUString& aName, const css::awt::Point& aPos ) override;
107 virtual void SAL_CALL setElementPosSize( const OUString& aName, const css::awt::Point& aPos, const css::awt::Size& aSize ) override;
108 virtual sal_Bool SAL_CALL isElementVisible( const OUString& aName ) override;
109 virtual sal_Bool SAL_CALL isElementFloating( const OUString& aName ) override;
110 virtual sal_Bool SAL_CALL isElementDocked( const OUString& aName ) override;
111 virtual sal_Bool SAL_CALL isElementLocked( const OUString& ResourceURL ) override;
112 virtual css::awt::Size SAL_CALL getElementSize( const OUString& aName ) override;
113 virtual css::awt::Point SAL_CALL getElementPos( const OUString& aName ) override;
114 virtual void SAL_CALL lock( ) override;
115 virtual void SAL_CALL unlock( ) override;
116 virtual void SAL_CALL doLayout( ) override;
117 virtual void SAL_CALL setVisible( sal_Bool bVisible ) override;
118 virtual sal_Bool SAL_CALL isVisible() override;
119
120 // XMenuBarMergingAcceptor
121
122 virtual sal_Bool SAL_CALL setMergedMenuBar( const css::uno::Reference< css::container::XIndexAccess >& xMergedMenuBar ) override;
123 virtual void SAL_CALL removeMergedMenuBar( ) override;
124
125 // XWindowListener
126 virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) override;
127 virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) override;
128 virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) override;
129 virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) override;
130
131 // XFrameActionListener
132 virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) override;
133
134 // XEventListener
136 virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override;
137
138 // XUIConfigurationListener
139 virtual void SAL_CALL elementInserted( const css::ui::ConfigurationEvent& Event ) override;
140 virtual void SAL_CALL elementRemoved( const css::ui::ConfigurationEvent& Event ) override;
141 virtual void SAL_CALL elementReplaced( const css::ui::ConfigurationEvent& Event ) override;
142
143 // XLayoutManagerEventBroadcaster
144 virtual void SAL_CALL addLayoutManagerEventListener( const css::uno::Reference< css::frame::XLayoutManagerListener >& aLayoutManagerListener ) override;
145 virtual void SAL_CALL removeLayoutManagerEventListener( const css::uno::Reference< css::frame::XLayoutManagerListener >& aLayoutManagerListener ) override;
146
147 DECL_LINK( MenuBarClose, void *, void);
148 DECL_LINK( WindowEventListener, VclWindowEvent&, void );
149
150 // called from ToolbarLayoutManager
151 void requestLayout();
152
154 static bool readWindowStateData( const OUString& rName, UIElement& rElementData,
155 const css::uno::Reference< css::container::XNameAccess > &rPersistentWindowState,
156 std::unique_ptr<GlobalSettings> &rGlobalSettings, bool &bInGlobalSettings,
157 const css::uno::Reference< css::uno::XComponentContext > &rComponentContext );
158
159 private:
160 DECL_LINK(AsyncLayoutHdl, Timer *, void);
161
162 // menu bar
163
164 void implts_createMenuBar( const OUString& rMenuBarName );
165 void impl_clearUpMenuBar();
166 void implts_reset( bool bAttach );
168 bool implts_resetMenuBar();
169 void implts_createMSCompatibleMenuBar(const OUString& rName);
170
171 // locking
172
173 void implts_lock();
174 bool implts_unlock();
175
176 // query
177
178 css::uno::Reference< css::ui::XUIElement > implts_findElement( std::u16string_view aName );
179
180 bool implts_readWindowStateData( const OUString& rName, UIElement& rElementData );
181 void implts_writeWindowStateData( const OUString& rName, const UIElement& rElementData );
185 css::uno::Reference< css::ui::XUIElement > implts_createDockingWindow( const OUString& aElementName );
186
188 css::uno::Reference< css::ui::XUIElement > implts_createElement( const OUString& aName );
189
190 // layouting methods
191 bool implts_resizeContainerWindow( const css::awt::Size& rContainerSize, const css::awt::Point& rComponentPos );
193
195 css::awt::Rectangle implts_calcDockingAreaSizes();
196 bool implts_doLayout( bool bForceRequestBorderSpace, bool bOuterResize );
197 void implts_doLayout_notify( bool bOuterResize );
198
199 // internal methods to control status/progress bar
202 void implts_createStatusBar( const OUString& rStatusBarName );
205 void implts_setStatusBarPosSize( const ::Point& rPos, const ::Size& rSize );
206 bool implts_showStatusBar( bool bStoreState=false );
207 bool implts_hideStatusBar( bool bStoreState=false );
208 void implts_readStatusBarState( const OUString& rStatusBarName );
212 void implts_setOffset( const sal_Int32 nBottomOffset );
213
216 const css::uno::Reference< css::container::XIndexAccess >& xMergedMenuBar );
219
220 void implts_setVisibleState( bool bShow );
221 void implts_updateUIElementsVisibleState( bool bShow );
222 void implts_setCurrentUIVisibility( bool bShow );
223 void implts_notifyListeners(short nEvent, const css::uno::Any& rInfoParam);
224
225 // OPropertySetHelper
226
227 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
228 const css::uno::Any& aValue ) override;
229 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
230 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
231
232 css::uno::Reference< css::uno::XComponentContext > m_xContext;
233 css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer;
234 css::uno::Reference< css::frame::XFrame > m_xFrame;
235 css::uno::Reference< css::ui::XUIConfigurationManager > m_xModuleCfgMgr;
236 css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocCfgMgr;
237 css::uno::Reference< css::awt::XWindow > m_xContainerWindow;
238 css::uno::Reference< css::awt::XTopWindow2 > m_xContainerTopWindow;
239 sal_Int32 m_nLockCount;
250 css::awt::Rectangle m_aDockingArea;
251 css::uno::Reference< css::ui::XDockingAreaAcceptor > m_xDockingAreaAcceptor;
253 css::uno::Reference< css::ui::XUIElement > m_xMenuBar;
256 css::uno::Reference< css::ui::XUIElement > m_xProgressBarBackup;
257 css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;
258 css::uno::Reference< css::ui::XUIElementFactoryManager > m_xUIElementFactoryManager;
259 css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowState;
260 css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowStateSupplier;
261 std::unique_ptr<GlobalSettings> m_pGlobalSettings;
266
268 };
269
270} // namespace framework
271
272/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SAL_CALL disposing()
css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowStateSupplier
virtual void SAL_CALL reset() override
virtual void SAL_CALL windowMoved(const css::awt::WindowEvent &aEvent) override
css::uno::Reference< css::ui::XUIElement > m_xProgressBarBackup
virtual void SAL_CALL windowHidden(const css::lang::EventObject &aEvent) override
css::uno::Reference< css::frame::XFrame > m_xFrame
css::uno::Reference< css::awt::XTopWindow2 > m_xContainerTopWindow
virtual sal_Bool SAL_CALL hideElement(const OUString &aName) override
virtual css::awt::Size SAL_CALL getElementSize(const OUString &aName) override
virtual sal_Bool SAL_CALL dockAllWindows(::sal_Int16 nElementType) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL setElementSize(const OUString &aName, const css::awt::Size &aSize) override
css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowState
css::uno::Reference< css::ui::XUIElement > implts_createDockingWindow(const OUString &aElementName)
bool implts_showStatusBar(bool bStoreState=false)
css::awt::Rectangle implts_calcDockingAreaSizes()
DECL_LINK(WindowEventListener, VclWindowEvent &, void)
virtual void SAL_CALL removeLayoutManagerEventListener(const css::uno::Reference< css::frame::XLayoutManagerListener > &aLayoutManagerListener) override
virtual sal_Bool SAL_CALL lockWindow(const OUString &ResourceURL) override
void implts_setCurrentUIVisibility(bool bShow)
void implts_setStatusBarPosSize(const ::Point &rPos, const ::Size &rSize)
virtual sal_Bool SAL_CALL isElementLocked(const OUString &ResourceURL) override
virtual void SAL_CALL windowResized(const css::awt::WindowEvent &aEvent) override
virtual void SAL_CALL elementRemoved(const css::ui::ConfigurationEvent &Event) override
void implts_notifyListeners(short nEvent, const css::uno::Any &rInfoParam)
css::uno::Reference< css::ui::XUIConfigurationManager > m_xModuleCfgMgr
virtual css::uno::Sequence< css::uno::Reference< css::ui::XUIElement > > SAL_CALL getElements() override
virtual void SAL_CALL elementReplaced(const css::ui::ConfigurationEvent &Event) override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &aValue) override
virtual void SAL_CALL setDockingAreaAcceptor(const css::uno::Reference< css::ui::XDockingAreaAcceptor > &xDockingAreaAcceptor) final override
css::uno::Reference< css::ui::XUIElement > implts_findElement(std::u16string_view aName)
bool implts_doLayout(bool bForceRequestBorderSpace, bool bOuterResize)
css::uno::Reference< css::awt::XWindow > m_xContainerWindow
css::uno::Reference< css::ui::XUIElementFactoryManager > m_xUIElementFactoryManager
virtual css::awt::Rectangle SAL_CALL getCurrentDockingArea() override
void implts_setVisibleState(bool bShow)
virtual void SAL_CALL setVisible(sal_Bool bVisible) override
virtual sal_Bool SAL_CALL setMergedMenuBar(const css::uno::Reference< css::container::XIndexAccess > &xMergedMenuBar) override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual ~LayoutManager() override
virtual void SAL_CALL createElement(const OUString &aName) override
void implts_doLayout_notify(bool bOuterResize)
virtual sal_Bool SAL_CALL unlockWindow(const OUString &ResourceURL) override
LayoutManager(const css::uno::Reference< css::uno::XComponentContext > &xContext)
void implts_toggleFloatingUIElementsVisibility(bool bActive)
rtl::Reference< ToolbarLayoutManager > m_xToolbarManager
::Size implts_getContainerWindowOutputSize()
virtual void SAL_CALL addLayoutManagerEventListener(const css::uno::Reference< css::frame::XLayoutManagerListener > &aLayoutManagerListener) override
virtual sal_Bool SAL_CALL floatWindow(const OUString &aName) override
DECL_LINK(AsyncLayoutHdl, Timer *, void)
void implts_createMSCompatibleMenuBar(const OUString &rName)
virtual sal_Bool SAL_CALL isElementVisible(const OUString &aName) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual void SAL_CALL attachFrame(const css::uno::Reference< css::frame::XFrame > &Frame) override
void implts_writeWindowStateData(const OUString &rName, const UIElement &rElementData)
DECL_LINK(MenuBarClose, void *, void)
virtual void SAL_CALL destroyElement(const OUString &aName) override
virtual css::uno::Reference< css::ui::XDockingAreaAcceptor > SAL_CALL getDockingAreaAcceptor() override
rtl::Reference< MenuBarManager > m_xInplaceMenuBar
virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent &aEvent) override
void implts_setOffset(const sal_Int32 nBottomOffset)
virtual sal_Bool SAL_CALL showElement(const OUString &aName) override
virtual sal_Bool SAL_CALL requestElement(const OUString &ResourceURL) override
virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL getElement(const OUString &aName) override
css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager
css::uno::Reference< css::ui::XUIElement > implts_createElement(const OUString &aName)
css::uno::Reference< css::ui::XDockingAreaAcceptor > m_xDockingAreaAcceptor
virtual void SAL_CALL lock() override
virtual OUString SAL_CALL getImplementationName() override
declaration of XInterface, XTypeProvider, XServiceInfo
bool implts_resizeContainerWindow(const css::awt::Size &rContainerSize, const css::awt::Point &rComponentPos)
virtual sal_Bool SAL_CALL dockWindow(const OUString &aName, css::ui::DockingArea DockingArea, const css::awt::Point &Pos) override
void implts_reset(bool bAttach)
void implts_readStatusBarState(const OUString &rStatusBarName)
bool implts_isEmbeddedLayoutManager() const
virtual css::awt::Point SAL_CALL getElementPos(const OUString &aName) override
virtual void SAL_CALL windowShown(const css::lang::EventObject &aEvent) override
css::awt::Rectangle m_aDockingArea
css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocCfgMgr
css::uno::Reference< css::ui::XUIElement > m_xMenuBar
std::unique_ptr< GlobalSettings > m_pGlobalSettings
virtual void SAL_CALL elementInserted(const css::ui::ConfigurationEvent &Event) override
void implts_updateUIElementsVisibleState(bool bShow)
virtual sal_Bool SAL_CALL isVisible() override
virtual sal_Bool SAL_CALL isElementDocked(const OUString &aName) override
css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer
reference to factory, which has created this instance.
virtual void SAL_CALL doLayout() override
void implts_setInplaceMenuBar(const css::uno::Reference< css::container::XIndexAccess > &xMergedMenuBar)
virtual void SAL_CALL disposing(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL unlock() override
static bool readWindowStateData(const OUString &rName, UIElement &rElementData, const css::uno::Reference< css::container::XNameAccess > &rPersistentWindowState, std::unique_ptr< GlobalSettings > &rGlobalSettings, bool &bInGlobalSettings, const css::uno::Reference< css::uno::XComponentContext > &rComponentContext)
Reading of settings - shared with ToolbarLayoutManager.
bool implts_readWindowStateData(const OUString &rName, UIElement &rElementData)
void implts_createMenuBar(const OUString &rMenuBarName)
void implts_createStatusBar(const OUString &rStatusBarName)
virtual void SAL_CALL setElementPosSize(const OUString &aName, const css::awt::Point &aPos, const css::awt::Size &aSize) override
bool implts_hideStatusBar(bool bStoreState=false)
virtual void SAL_CALL removeMergedMenuBar() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL isElementFloating(const OUString &aName) override
virtual sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
virtual void SAL_CALL setElementPos(const OUString &aName, const css::awt::Point &aPos) override
comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer
Sequence< sal_Int8 > aSeq
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
::cppu::WeakImplHelper< css::lang::XServiceInfo, css::frame::XLayoutManager2, css::awt::XWindowListener > LayoutManager_Base
::comphelper::OPropertyContainer LayoutManager_PBase
bool bVisible
unsigned char sal_Bool
#define DECLARE_XTYPEPROVIDER()
#define DECLARE_XINTERFACE()