/src/libreoffice/framework/inc/services/layoutmanager.hxx
Line | Count | Source |
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 | | |
22 | | #include <uielement/menubarmanager.hxx> |
23 | | #include <uielement/uielement.hxx> |
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 | | |
35 | | #include <cppuhelper/basemutex.hxx> |
36 | | #include <cppuhelper/propshlp.hxx> |
37 | | #include <cppuhelper/implbase.hxx> |
38 | | #include <comphelper/multicontainer2.hxx> |
39 | | #include <cppuhelper/supportsservice.hxx> |
40 | | #include <comphelper/propertycontainer.hxx> |
41 | | #include <comphelper/uno3.hxx> |
42 | | #include <vcl/timer.hxx> |
43 | | |
44 | | namespace framework |
45 | | { |
46 | | class MenuBarWrapper; |
47 | | class ProgressBarWrapper; |
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 |
57 | | > LayoutManager_Base; |
58 | | typedef ::comphelper::OPropertyContainer LayoutManager_PBase; |
59 | | class LayoutManager final : public LayoutManager_Base , |
60 | | private cppu::BaseMutex, |
61 | | public ::cppu::OBroadcastHelper , |
62 | | public LayoutManager_PBase |
63 | | { |
64 | | public: |
65 | | LayoutManager( const css::uno::Reference< css::uno::XComponentContext >& xContext ); |
66 | | virtual ~LayoutManager() override; |
67 | | |
68 | | /** declaration of XInterface, XTypeProvider, XServiceInfo */ |
69 | | DECLARE_XINTERFACE() |
70 | | DECLARE_XTYPEPROVIDER() |
71 | | virtual OUString SAL_CALL getImplementationName() override |
72 | 0 | { |
73 | 0 | return u"com.sun.star.comp.framework.LayoutManager"_ustr; |
74 | 0 | } |
75 | | |
76 | | virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override |
77 | 0 | { |
78 | 0 | return cppu::supportsService(this, ServiceName); |
79 | 0 | } |
80 | | |
81 | | virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override |
82 | 0 | { |
83 | 0 | css::uno::Sequence< OUString > aSeq { u"com.sun.star.frame.LayoutManager"_ustr }; |
84 | 0 | return aSeq; |
85 | 0 | } |
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 |
135 | | using cppu::OPropertySetHelper::disposing; |
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 | | |
153 | | /// Reading of settings - shared with ToolbarLayoutManager. |
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 ); |
167 | | void implts_updateMenuBarClose(); |
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 ); |
182 | | void implts_destroyElements(); |
183 | | void implts_toggleFloatingUIElementsVisibility( bool bActive ); |
184 | | void implts_reparentChildWindows(); |
185 | | css::uno::Reference< css::ui::XUIElement > implts_createDockingWindow( const OUString& aElementName ); |
186 | | |
187 | | bool implts_isEmbeddedLayoutManager() const; |
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 ); |
192 | | ::Size implts_getContainerWindowOutputSize(); |
193 | | |
194 | | void implts_setDockingAreaWindowSizes(); |
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 |
200 | | ::Size implts_getStatusBarSize(); |
201 | | void implts_destroyStatusBar(); |
202 | | void implts_createStatusBar( const OUString& rStatusBarName ); |
203 | | void implts_createProgressBar(); |
204 | | void implts_destroyProgressBar(); |
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 ); |
209 | | bool implts_showProgressBar(); |
210 | | bool implts_hideProgressBar(); |
211 | | void implts_backupProgressBarWrapper(); |
212 | | void implts_setOffset( const sal_Int32 nBottomOffset ); |
213 | | |
214 | | /// @throws css::uno::RuntimeException |
215 | | void implts_setInplaceMenuBar( |
216 | | const css::uno::Reference< css::container::XIndexAccess >& xMergedMenuBar ); |
217 | | /// @throws css::uno::RuntimeException |
218 | | void implts_resetInplaceMenuBar(); |
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; /** reference to factory, which has created this instance. */ |
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; |
240 | | bool m_bInplaceMenuSet; |
241 | | bool m_bMenuVisible; |
242 | | bool m_bVisible; |
243 | | bool m_bParentWindowVisible; |
244 | | bool m_bMustDoLayout; |
245 | | bool m_bAutomaticToolbars; |
246 | | bool m_bHideCurrentUI; |
247 | | bool m_bGlobalSettings; |
248 | | bool m_bPreserveContentSize; |
249 | | bool m_bMenuBarCloseButton; |
250 | | css::awt::Rectangle m_aDockingArea; |
251 | | css::uno::Reference< css::ui::XDockingAreaAcceptor > m_xDockingAreaAcceptor; |
252 | | rtl::Reference< MenuBarManager > m_xInplaceMenuBar; |
253 | | rtl::Reference< MenuBarWrapper > m_xMenuBar; |
254 | | UIElement m_aStatusBarElement; |
255 | | UIElement m_aProgressBarElement; |
256 | | rtl::Reference< ProgressBarWrapper > 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; |
262 | | OUString m_aModuleIdentifier; |
263 | | Timer m_aAsyncLayoutTimer; |
264 | | comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer; // container for ALL Listener |
265 | | rtl::Reference< ToolbarLayoutManager > m_xToolbarManager; |
266 | | bool m_bInSetCurrentUIVisibility; |
267 | | |
268 | | friend class detail::InfoHelperBuilder; |
269 | | }; |
270 | | |
271 | | } // namespace framework |
272 | | |
273 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |