1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * $RCSfile: layoutmanager.hxx,v $ 10 * $Revision: 1.34 $ 11 * 12 * This file is part of OpenOffice.org. 13 * 14 * OpenOffice.org is free software: you can redistribute it and/or modify 15 * it under the terms of the GNU Lesser General Public License version 3 16 * only, as published by the Free Software Foundation. 17 * 18 * OpenOffice.org is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU Lesser General Public License version 3 for more details 22 * (a copy is included in the LICENSE file that accompanied this code). 23 * 24 * You should have received a copy of the GNU Lesser General Public License 25 * version 3 along with OpenOffice.org. If not, see 26 * <http://www.openoffice.org/license.html> 27 * for a copy of the LGPLv3 License. 28 * 29 ************************************************************************/ 30 31 #ifndef __FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_ 32 #define __FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_ 33 34 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble 35 with solaris headers ... 36 */ 37 #include <vector> 38 39 //_________________________________________________________________________________________________________________ 40 // my own includes 41 //_________________________________________________________________________________________________________________ 42 #include <threadhelp/threadhelpbase.hxx> 43 #include <threadhelp/resetableguard.hxx> 44 #include <threadhelp/writeguard.hxx> 45 #include <threadhelp/readguard.hxx> 46 #include <macros/generic.hxx> 47 #include <macros/xinterface.hxx> 48 #include <macros/xtypeprovider.hxx> 49 #include <macros/xserviceinfo.hxx> 50 #include <stdtypes.h> 51 #include <properties.h> 52 #include <stdtypes.h> 53 #include <uielement/menubarmanager.hxx> 54 #include <uiconfiguration/windowstateconfiguration.hxx> 55 #include <framework/addonsoptions.hxx> 56 #include <uielement/panelwindow.hxx> 57 #include <uielement/uielement.hxx> 58 #include <helper/ilayoutnotifications.hxx> 59 60 //_________________________________________________________________________________________________________________ 61 // interface includes 62 //_________________________________________________________________________________________________________________ 63 #include <com/sun/star/lang/XServiceInfo.hpp> 64 #include <com/sun/star/lang/XTypeProvider.hpp> 65 #include <com/sun/star/frame/XLayoutManager.hpp> 66 #include <com/sun/star/ui/XUIConfigurationManager.hpp> 67 #include <com/sun/star/ui/XUIConfiguration.hpp> 68 #include <com/sun/star/frame/XModuleManager.hpp> 69 #include <com/sun/star/frame/XFrameActionListener.hpp> 70 #include <com/sun/star/awt/XWindowListener.hpp> 71 #include <com/sun/star/util/XURLTransformer.hpp> 72 #include <com/sun/star/ui/XUIElementFactory.hpp> 73 #include <com/sun/star/frame/XInplaceLayout.hpp> 74 #include <com/sun/star/ui/DockingArea.hpp> 75 #include <com/sun/star/awt/XTopWindow2.hpp> 76 #include <com/sun/star/awt/XDockableWindow.hpp> 77 #include <com/sun/star/awt/XDockableWindowListener.hpp> 78 #include <com/sun/star/frame/XMenuBarMergingAcceptor.hpp> 79 #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp> 80 81 //_________________________________________________________________________________________________________________ 82 // other includes 83 //_________________________________________________________________________________________________________________ 84 #include <cppuhelper/propshlp.hxx> 85 #include <cppuhelper/implbase8.hxx> 86 #include <cppuhelper/interfacecontainer.hxx> 87 #include <comphelper/propertycontainer.hxx> 88 #include <tools/wintypes.hxx> 89 #include <svtools/miscopt.hxx> 90 #include <vcl/toolbox.hxx> 91 #include <vcl/timer.hxx> 92 93 class MenuBar; 94 namespace framework 95 { 96 class ToolbarLayoutManager; 97 class PanelManager; 98 class GlobalSettings; 99 typedef ::cppu::WeakImplHelper8 < ::com::sun::star::lang::XServiceInfo 100 , ::com::sun::star::frame::XLayoutManager 101 , ::com::sun::star::awt::XWindowListener 102 , ::com::sun::star::frame::XFrameActionListener 103 , ::com::sun::star::ui::XUIConfigurationListener 104 , ::com::sun::star::frame::XInplaceLayout 105 , ::com::sun::star::frame::XMenuBarMergingAcceptor 106 , ::com::sun::star::frame::XLayoutManagerEventBroadcaster 107 > LayoutManager_Base; 108 typedef ::comphelper::OPropertyContainer LayoutManager_PBase; 109 class LayoutManager : public LayoutManager_Base , 110 // base classes 111 // Order is neccessary for right initialization! 112 private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses. 113 public ::cppu::OBroadcastHelper , 114 public ILayoutNotifications , 115 public LayoutManager_PBase 116 { 117 public: 118 enum { DOCKINGAREAS_COUNT = 4 }; 119 120 LayoutManager( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMGR ); 121 virtual ~LayoutManager(); 122 123 /** declaration of XInterface, XTypeProvider, XServiceInfo */ 124 FWK_DECLARE_XINTERFACE 125 FWK_DECLARE_XTYPEPROVIDER 126 DECLARE_XSERVICEINFO 127 128 //--------------------------------------------------------------------------------------------------------- 129 // XLayoutManager 130 //--------------------------------------------------------------------------------------------------------- 131 virtual void SAL_CALL attachFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::uno::RuntimeException); 132 virtual void SAL_CALL reset() throw (::com::sun::star::uno::RuntimeException); 133 virtual ::com::sun::star::awt::Rectangle SAL_CALL getCurrentDockingArea( ) throw (::com::sun::star::uno::RuntimeException); 134 virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > SAL_CALL getDockingAreaAcceptor() throw (::com::sun::star::uno::RuntimeException); 135 virtual void SAL_CALL setDockingAreaAcceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor >& xDockingAreaAcceptor ) throw (::com::sun::star::uno::RuntimeException); 136 virtual void SAL_CALL createElement( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 137 virtual void SAL_CALL destroyElement( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 138 virtual ::sal_Bool SAL_CALL requestElement( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException); 139 virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL getElement( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 140 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); 141 virtual sal_Bool SAL_CALL showElement( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 142 virtual sal_Bool SAL_CALL hideElement( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 143 virtual sal_Bool SAL_CALL dockWindow( const ::rtl::OUString& aName, ::com::sun::star::ui::DockingArea DockingArea, const ::com::sun::star::awt::Point& Pos ) throw (::com::sun::star::uno::RuntimeException); 144 virtual ::sal_Bool SAL_CALL dockAllWindows( ::sal_Int16 nElementType ) throw (::com::sun::star::uno::RuntimeException); 145 virtual sal_Bool SAL_CALL floatWindow( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 146 virtual ::sal_Bool SAL_CALL lockWindow( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException); 147 virtual ::sal_Bool SAL_CALL unlockWindow( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException); 148 virtual void SAL_CALL setElementSize( const ::rtl::OUString& aName, const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException); 149 virtual void SAL_CALL setElementPos( const ::rtl::OUString& aName, const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException); 150 virtual void SAL_CALL setElementPosSize( const ::rtl::OUString& aName, const ::com::sun::star::awt::Point& aPos, const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException); 151 virtual sal_Bool SAL_CALL isElementVisible( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 152 virtual sal_Bool SAL_CALL isElementFloating( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 153 virtual sal_Bool SAL_CALL isElementDocked( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 154 virtual ::sal_Bool SAL_CALL isElementLocked( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::uno::RuntimeException); 155 virtual ::com::sun::star::awt::Size SAL_CALL getElementSize( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 156 virtual ::com::sun::star::awt::Point SAL_CALL getElementPos( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); 157 virtual void SAL_CALL lock( ) throw (::com::sun::star::uno::RuntimeException); 158 virtual void SAL_CALL unlock( ) throw (::com::sun::star::uno::RuntimeException); 159 virtual void SAL_CALL doLayout( ) throw (::com::sun::star::uno::RuntimeException); 160 virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw (::com::sun::star::uno::RuntimeException); 161 virtual sal_Bool SAL_CALL isVisible() throw (::com::sun::star::uno::RuntimeException); 162 163 //--------------------------------------------------------------------------------------------------------- 164 // XInplaceLayout 165 //--------------------------------------------------------------------------------------------------------- 166 virtual void SAL_CALL setInplaceMenuBar( sal_Int64 pInplaceMenuBarPointer ) throw (::com::sun::star::uno::RuntimeException); 167 virtual void SAL_CALL resetInplaceMenuBar( ) throw (::com::sun::star::uno::RuntimeException); 168 169 //--------------------------------------------------------------------------------------------------------- 170 // XMenuBarMergingAcceptor 171 //--------------------------------------------------------------------------------------------------------- 172 virtual sal_Bool SAL_CALL setMergedMenuBar( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xMergedMenuBar ) 173 throw (::com::sun::star::uno::RuntimeException); 174 virtual void SAL_CALL removeMergedMenuBar( ) throw (::com::sun::star::uno::RuntimeException); 175 176 //--------------------------------------------------------------------------------------------------------- 177 // XWindowListener 178 //--------------------------------------------------------------------------------------------------------- 179 virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) throw( css::uno::RuntimeException ); 180 virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) throw( css::uno::RuntimeException ); 181 virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException ); 182 virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException ); 183 184 //--------------------------------------------------------------------------------------------------------- 185 // XFrameActionListener 186 //--------------------------------------------------------------------------------------------------------- 187 virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) throw ( css::uno::RuntimeException ); 188 189 //--------------------------------------------------------------------------------------------------------- 190 // XEventListener 191 //--------------------------------------------------------------------------------------------------------- 192 using cppu::OPropertySetHelper::disposing; 193 virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException ); 194 195 //--------------------------------------------------------------------------------------------------------- 196 // XUIConfigurationListener 197 //--------------------------------------------------------------------------------------------------------- 198 virtual void SAL_CALL elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 199 virtual void SAL_CALL elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 200 virtual void SAL_CALL elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 201 202 //--------------------------------------------------------------------------------------------------------- 203 // XLayoutManagerEventBroadcaster 204 //--------------------------------------------------------------------------------------------------------- 205 virtual void SAL_CALL addLayoutManagerEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManagerListener >& aLayoutManagerListener ) throw (::com::sun::star::uno::RuntimeException); 206 virtual void SAL_CALL removeLayoutManagerEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManagerListener >& aLayoutManagerListener ) throw (::com::sun::star::uno::RuntimeException); 207 208 DECL_LINK( MenuBarClose, MenuBar * ); 209 DECL_LINK( WindowEventListener, VclSimpleEvent* ); 210 211 //--------------------------------------------------------------------------------------------------------- 212 // ILayoutNotifications 213 //--------------------------------------------------------------------------------------------------------- 214 virtual void requestLayout( Hint eHint ); 215 216 protected: 217 DECL_LINK( AsyncLayoutHdl, Timer * ); 218 219 private: 220 //--------------------------------------------------------------------------------------------------------- 221 // helper 222 //--------------------------------------------------------------------------------------------------------- 223 224 //--------------------------------------------------------------------------------------------------------- 225 // menu bar 226 //--------------------------------------------------------------------------------------------------------- 227 void impl_clearUpMenuBar(); 228 void implts_reset( sal_Bool bAttach ); 229 void implts_setMenuBarCloser(sal_Bool bCloserState); 230 void implts_updateMenuBarClose(); 231 sal_Bool implts_resetMenuBar(); 232 233 //--------------------------------------------------------------------------------------------------------- 234 // locking 235 //--------------------------------------------------------------------------------------------------------- 236 void implts_lock(); 237 sal_Bool implts_unlock(); 238 239 //--------------------------------------------------------------------------------------------------------- 240 // query 241 //--------------------------------------------------------------------------------------------------------- 242 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > implts_findElement( const rtl::OUString& aName ); 243 UIElement& impl_findElement( const rtl::OUString& aName ); 244 245 void implts_writeNewStateData( const rtl::OUString aName, const ::com::sun::star::uno::Reference< com::sun::star::awt::XWindow >& xWindow ); 246 sal_Bool implts_readWindowStateData( const rtl::OUString& rName, UIElement& rElementData ); 247 void implts_writeWindowStateData( const rtl::OUString& rName, const UIElement& rElementData ); 248 void implts_setElementData( UIElement& rUIElement, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindow >& rDockWindow ); 249 void implts_sortUIElements(); 250 void implts_destroyElements(); 251 void implts_toggleFloatingUIElementsVisibility( sal_Bool bActive ); 252 void implts_reparentChildWindows(); 253 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > implts_createDockingWindow( const ::rtl::OUString& aElementName ); 254 255 sal_Bool implts_isEmbeddedLayoutManager() const; 256 sal_Int16 implts_getCurrentSymbolsSize(); 257 sal_Int16 implts_getCurrentSymbolsStyle(); 258 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > implts_createElement( const rtl::OUString& aName ); 259 260 // layouting methods 261 sal_Bool implts_resizeContainerWindow( const ::com::sun::star::awt::Size& rContainerSize, const ::com::sun::star::awt::Point& rComponentPos ); 262 ::Size implts_getTopBottomDockingAreaSizes(); 263 ::Size implts_getContainerWindowOutputSize(); 264 265 void implts_setDockingAreaWindowSizes( const css::awt::Rectangle& rBorderSpace ); 266 ::com::sun::star::awt::Rectangle implts_calcDockingAreaSizes(); 267 sal_Bool implts_doLayout( sal_Bool bForceRequestBorderSpace, sal_Bool bOuterResize ); 268 void implts_doLayout_notify( sal_Bool bOuterResize ); 269 270 // internal methods to control status/progress bar 271 ::Size implts_getStatusBarSize(); 272 void implts_destroyStatusBar(); 273 void implts_createStatusBar( const rtl::OUString& rStatusBarName ); 274 void implts_createProgressBar(); 275 void implts_destroyProgressBar(); 276 void implts_setStatusBarPosSize( const ::Point& rPos, const ::Size& rSize ); 277 sal_Bool implts_showStatusBar( sal_Bool bStoreState=sal_False ); 278 sal_Bool implts_hideStatusBar( sal_Bool bStoreState=sal_False ); 279 void implts_readStatusBarState( const rtl::OUString& rStatusBarName ); 280 sal_Bool implts_showProgressBar(); 281 sal_Bool implts_hideProgressBar(); 282 void implts_backupProgressBarWrapper(); 283 void implts_setOffset( const sal_Int32 nBottomOffset ); 284 285 void implts_setInplaceMenuBar( 286 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xMergedMenuBar ) 287 throw (::com::sun::star::uno::RuntimeException); 288 void implts_resetInplaceMenuBar() 289 throw (::com::sun::star::uno::RuntimeException); 290 291 void implts_setVisibleState( sal_Bool bShow ); 292 void implts_updateUIElementsVisibleState( sal_Bool bShow ); 293 void implts_setCurrentUIVisibility( sal_Bool bShow ); 294 void implts_notifyListeners( short nEvent, ::com::sun::star::uno::Any aInfoParam ); 295 296 DECL_LINK( OptionsChanged, void* ); 297 DECL_LINK( SettingsChanged, void* ); 298 299 //--------------------------------------------------------------------------------------------------------- 300 // OPropertySetHelper 301 //--------------------------------------------------------------------------------------------------------- 302 virtual sal_Bool SAL_CALL convertFastPropertyValue ( com::sun::star::uno::Any& aConvertedValue , 303 com::sun::star::uno::Any& aOldValue , 304 sal_Int32 nHandle , 305 const com::sun::star::uno::Any& aValue ) throw( com::sun::star::lang::IllegalArgumentException ); 306 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , 307 const com::sun::star::uno::Any& aValue ) throw( com::sun::star::uno::Exception ); 308 using cppu::OPropertySetHelper::getFastPropertyValue; 309 virtual void SAL_CALL getFastPropertyValue( com::sun::star::uno::Any& aValue , 310 sal_Int32 nHandle ) const; 311 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 312 virtual ::com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException); 313 314 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; /** reference to factory, which has created this instance. */ 315 css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; 316 css::uno::Reference< css::container::XIndexAccess > m_xDisplayAccess; 317 css::uno::Reference< css::frame::XFrame > m_xFrame; 318 css::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xModuleCfgMgr; 319 css::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xDocCfgMgr; 320 css::uno::WeakReference< css::frame::XModel > m_xModel; 321 css::uno::Reference< css::awt::XWindow > m_xContainerWindow; 322 css::uno::Reference< css::awt::XTopWindow2 > m_xContainerTopWindow; 323 sal_Int32 m_nLockCount; 324 bool m_bActive; 325 bool m_bInplaceMenuSet; 326 bool m_bDockingInProgress; 327 bool m_bMenuVisible; 328 bool m_bComponentAttached; 329 bool m_bDoLayout; 330 bool m_bVisible; 331 bool m_bParentWindowVisible; 332 bool m_bMustDoLayout; 333 bool m_bAutomaticToolbars; 334 bool m_bStoreWindowState; 335 bool m_bHideCurrentUI; 336 bool m_bGlobalSettings; 337 bool m_bPreserveContentSize; 338 bool m_bMenuBarCloser; 339 css::awt::Rectangle m_aDockingArea; 340 css::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > m_xDockingAreaAcceptor; 341 css::uno::Reference< ::com::sun::star::lang::XComponent > m_xInplaceMenuBar; 342 MenuBarManager* m_pInplaceMenuBar; 343 css::uno::Reference< ::com::sun::star::ui::XUIElement > m_xMenuBar; 344 UIElement m_aStatusBarElement; 345 UIElement m_aProgressBarElement; 346 com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > m_xProgressBarBackup; 347 css::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager; 348 css::uno::Reference< ::com::sun::star::ui::XUIElementFactory > m_xUIElementFactoryManager; 349 css::uno::Reference< ::com::sun::star::container::XNameAccess > m_xPersistentWindowState; 350 css::uno::Reference< ::com::sun::star::container::XNameAccess > m_xPersistentWindowStateSupplier; 351 GlobalSettings* m_pGlobalSettings; 352 rtl::OUString m_aModuleIdentifier; 353 rtl::OUString m_aStatusBarAlias; 354 rtl::OUString m_aProgressBarAlias; 355 rtl::OUString m_aPropDocked; 356 rtl::OUString m_aPropVisible; 357 rtl::OUString m_aPropDockingArea; 358 rtl::OUString m_aPropDockPos; 359 rtl::OUString m_aPropPos; 360 rtl::OUString m_aPropSize; 361 rtl::OUString m_aPropUIName; 362 rtl::OUString m_aPropStyle; 363 rtl::OUString m_aPropLocked; 364 rtl::OUString m_aCustomizeCmd; 365 sal_Int16 m_eSymbolsSize; 366 sal_Int16 m_eSymbolsStyle; 367 Timer m_aAsyncLayoutTimer; 368 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; // container for ALL Listener 369 PanelManager* m_pPanelManager; 370 ToolbarLayoutManager* m_pToolbarManager; 371 css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener > m_xToolbarManager; 372 }; 373 374 } // namespace framework 375 376 #endif // __FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_ 377