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