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