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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_framework.hxx" 26 27 // my own includes 28 #include <services/layoutmanager.hxx> 29 #include <helpers.hxx> 30 #include <panelmanager.hxx> 31 #include <threadhelp/resetableguard.hxx> 32 #include <services.h> 33 34 #include <framework/sfxhelperfunctions.hxx> 35 #include <framework/sfxhelperfunctions.hxx> 36 #include <uielement/menubarwrapper.hxx> 37 #include <framework/addonsoptions.hxx> 38 #include <uiconfiguration/windowstateconfiguration.hxx> 39 #include <classes/fwkresid.hxx> 40 #include <classes/resource.hrc> 41 #include <toolkit/helper/convert.hxx> 42 #include <uielement/progressbarwrapper.hxx> 43 #include <uiconfiguration/globalsettings.hxx> 44 #include <toolbarlayoutmanager.hxx> 45 46 // interface includes 47 #include <com/sun/star/beans/XPropertySet.hpp> 48 #include <com/sun/star/beans/PropertyAttribute.hpp> 49 #include <com/sun/star/frame/XModel.hpp> 50 #include <com/sun/star/frame/FrameAction.hpp> 51 #include <com/sun/star/lang/XMultiComponentFactory.hpp> 52 #include <com/sun/star/awt/XTopWindow.hpp> 53 #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp> 54 #include <com/sun/star/lang/SystemDependent.hpp> 55 #include <com/sun/star/awt/VclWindowPeerAttribute.hpp> 56 #include <com/sun/star/awt/PosSize.hpp> 57 #include <com/sun/star/awt/XDevice.hpp> 58 #include <com/sun/star/awt/XSystemDependentWindowPeer.hpp> 59 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> 60 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> 61 #include <com/sun/star/ui/UIElementType.hpp> 62 #include <com/sun/star/container/XNameReplace.hpp> 63 #include <com/sun/star/container/XNameContainer.hpp> 64 #include <com/sun/star/frame/LayoutManagerEvents.hpp> 65 #include <com/sun/star/frame/XDispatchProvider.hpp> 66 #include <com/sun/star/frame/XDispatchHelper.hpp> 67 #include <com/sun/star/lang/DisposedException.hpp> 68 69 // other includes 70 #include <svtools/imgdef.hxx> 71 #include <tools/diagnose_ex.h> 72 #include <vcl/window.hxx> 73 #include <vcl/wrkwin.hxx> 74 #include <vcl/dockingarea.hxx> 75 #include <vcl/svapp.hxx> 76 #include <vcl/i18nhelp.hxx> 77 #include <vcl/wall.hxx> 78 #include <toolkit/helper/vclunohelper.hxx> 79 #include <toolkit/awt/vclxwindow.hxx> 80 #include <toolkit/awt/vclxmenu.hxx> 81 #include <comphelper/mediadescriptor.hxx> 82 #include <comphelper/uno3.hxx> 83 #include <rtl/logfile.hxx> 84 #include <unotools/cmdoptions.hxx> 85 86 #include <algorithm> 87 #include <boost/bind.hpp> 88 89 // using namespace 90 using namespace ::com::sun::star; 91 using namespace ::com::sun::star::uno; 92 using namespace ::com::sun::star::beans; 93 using namespace ::com::sun::star::util; 94 using namespace ::com::sun::star::lang; 95 using namespace ::com::sun::star::container; 96 using namespace ::com::sun::star::ui; 97 using namespace ::com::sun::star::frame; 98 99 100 // ATTENTION! 101 // This value is directly copied from the sfx2 project. 102 // You have to change BOTH values, see sfx2/inc/sfx2/sfxsids.hrc (SID_DOCKWIN_START) 103 static const sal_Int32 DOCKWIN_ID_BASE = 9800; 104 105 namespace framework 106 { 107 108 IMPLEMENT_FORWARD_XTYPEPROVIDER2( LayoutManager, LayoutManager_Base, LayoutManager_PBase ) 109 IMPLEMENT_FORWARD_XINTERFACE2( LayoutManager, LayoutManager_Base, LayoutManager_PBase ) 110 DEFINE_XSERVICEINFO_MULTISERVICE( LayoutManager, ::cppu::OWeakObject, SERVICENAME_LAYOUTMANAGER, IMPLEMENTATIONNAME_LAYOUTMANAGER) 111 DEFINE_INIT_SERVICE( LayoutManager, {} ) 112 113 LayoutManager::LayoutManager( const Reference< XMultiServiceFactory >& xServiceManager ) : LayoutManager_Base() 114 , ThreadHelpBase( &Application::GetSolarMutex()) 115 , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aLock.getShareableOslMutex()) 116 , LayoutManager_PBase( *(static_cast< ::cppu::OBroadcastHelper* >(this)) ) 117 , m_xSMGR( xServiceManager ) 118 , m_xURLTransformer( xServiceManager->createInstance( SERVICENAME_URLTRANSFORMER ), UNO_QUERY ) 119 , m_xDisplayAccess( xServiceManager->createInstance( SERVICENAME_DISPLAYACCESS ), UNO_QUERY ) 120 , m_nLockCount( 0 ) 121 , m_bActive( false ) 122 , m_bInplaceMenuSet( false ) 123 , m_bDockingInProgress( false ) 124 , m_bMenuVisible( true ) 125 , m_bComponentAttached( false ) 126 , m_bDoLayout( false ) 127 , m_bVisible( true ) 128 , m_bParentWindowVisible( false ) 129 , m_bMustDoLayout( true ) 130 , m_bAutomaticToolbars( true ) 131 , m_bStoreWindowState( false ) 132 , m_bHideCurrentUI( false ) 133 , m_bGlobalSettings( false ) 134 , m_bPreserveContentSize( false ) 135 , m_bMenuBarCloser( false ) 136 , m_pInplaceMenuBar( NULL ) 137 , m_xModuleManager( Reference< XModuleManager >( xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY )) 138 , m_xUIElementFactoryManager( Reference< ui::XUIElementFactory >( 139 xServiceManager->createInstance( SERVICENAME_UIELEMENTFACTORYMANAGER ), UNO_QUERY )) 140 , m_xPersistentWindowStateSupplier( Reference< XNameAccess >( 141 xServiceManager->createInstance( SERVICENAME_WINDOWSTATECONFIGURATION ), UNO_QUERY )) 142 , m_pGlobalSettings( 0 ) 143 , m_aStatusBarAlias( RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" )) 144 , m_aProgressBarAlias( RTL_CONSTASCII_USTRINGPARAM( "private:resource/progressbar/progressbar" )) 145 , m_aPropDocked( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_DOCKED )) 146 , m_aPropVisible( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_VISIBLE )) 147 , m_aPropDockingArea( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_DOCKINGAREA )) 148 , m_aPropDockPos( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_DOCKPOS )) 149 , m_aPropPos( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_POS )) 150 , m_aPropSize( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_SIZE )) 151 , m_aPropUIName( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_UINAME )) 152 , m_aPropStyle( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_STYLE )) 153 , m_aPropLocked( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_LOCKED )) 154 , m_aCustomizeCmd( RTL_CONSTASCII_USTRINGPARAM( "ConfigureDialog" )) 155 , m_aListenerContainer( m_aLock.getShareableOslMutex() ) 156 , m_pPanelManager( 0 ) 157 , m_pToolbarManager( 0 ) 158 { 159 // Initialize statusbar member 160 const sal_Bool bRefreshVisibility = sal_False; 161 m_aStatusBarElement.m_aType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "statusbar" )); 162 m_aStatusBarElement.m_aName = m_aStatusBarAlias; 163 164 m_pToolbarManager = new ToolbarLayoutManager( xServiceManager, m_xUIElementFactoryManager, this ); 165 m_xToolbarManager = uno::Reference< ui::XUIConfigurationListener >( static_cast< OWeakObject* >( m_pToolbarManager ), uno::UNO_QUERY ); 166 167 Application::AddEventListener( LINK( this, LayoutManager, SettingsChanged ) ); 168 169 m_aAsyncLayoutTimer.SetTimeout( 50 ); 170 m_aAsyncLayoutTimer.SetTimeoutHdl( LINK( this, LayoutManager, AsyncLayoutHdl ) ); 171 172 registerProperty( LAYOUTMANAGER_PROPNAME_AUTOMATICTOOLBARS, LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS, css::beans::PropertyAttribute::TRANSIENT, &m_bAutomaticToolbars, ::getCppuType( &m_bAutomaticToolbars ) ); 173 registerProperty( LAYOUTMANAGER_PROPNAME_HIDECURRENTUI, LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI, beans::PropertyAttribute::TRANSIENT, &m_bHideCurrentUI, ::getCppuType( &m_bHideCurrentUI ) ); 174 registerProperty( LAYOUTMANAGER_PROPNAME_LOCKCOUNT, LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT, beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::READONLY, &m_nLockCount, getCppuType( &m_nLockCount ) ); 175 registerProperty( LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER, beans::PropertyAttribute::TRANSIENT, &m_bMenuBarCloser, ::getCppuType( &m_bMenuBarCloser ) ); 176 registerPropertyNoMember( LAYOUTMANAGER_PROPNAME_REFRESHVISIBILITY, LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY, beans::PropertyAttribute::TRANSIENT, ::getCppuType( &bRefreshVisibility ), &bRefreshVisibility ); 177 registerProperty( LAYOUTMANAGER_PROPNAME_PRESERVE_CONTENT_SIZE, LAYOUTMANAGER_PROPHANDLE_PRESERVE_CONTENT_SIZE, beans::PropertyAttribute::TRANSIENT, &m_bPreserveContentSize, ::getCppuType( &m_bPreserveContentSize ) ); 178 } 179 180 LayoutManager::~LayoutManager() 181 { 182 Application::RemoveEventListener( LINK( this, LayoutManager, SettingsChanged ) ); 183 m_aAsyncLayoutTimer.Stop(); 184 setDockingAreaAcceptor(NULL); 185 } 186 187 // Internal helper function 188 void LayoutManager::impl_clearUpMenuBar() 189 { 190 implts_lock(); 191 192 // Clear up VCL menu bar to prepare shutdown 193 if ( m_xContainerWindow.is() ) 194 { 195 vos::OGuard aGuard( Application::GetSolarMutex() ); 196 197 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow ); 198 if ( pSysWindow ) 199 { 200 MenuBar* pSetMenuBar = 0; 201 if ( m_xInplaceMenuBar.is() ) 202 pSetMenuBar = (MenuBar *)m_pInplaceMenuBar->GetMenuBar(); 203 else 204 { 205 Reference< awt::XMenuBar > xMenuBar; 206 207 Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY ); 208 if ( xPropSet.is() ) 209 { 210 try 211 { 212 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMenuBar" ))) >>= xMenuBar; 213 } 214 catch ( beans::UnknownPropertyException ) {} 215 catch ( lang::WrappedTargetException ) {} 216 } 217 218 VCLXMenu* pAwtMenuBar = VCLXMenu::GetImplementation( xMenuBar ); 219 if ( pAwtMenuBar ) 220 pSetMenuBar = (MenuBar*)pAwtMenuBar->GetMenu(); 221 } 222 223 MenuBar* pTopMenuBar = pSysWindow->GetMenuBar(); 224 if ( pSetMenuBar == pTopMenuBar ) 225 pSysWindow->SetMenuBar( 0 ); 226 } 227 } 228 229 // reset inplace menubar manager 230 m_pInplaceMenuBar = 0; 231 if ( m_xInplaceMenuBar.is() ) 232 { 233 m_xInplaceMenuBar->dispose(); 234 m_xInplaceMenuBar.clear(); 235 } 236 237 Reference< XComponent > xComp( m_xMenuBar, UNO_QUERY ); 238 if ( xComp.is() ) 239 xComp->dispose(); 240 m_xMenuBar.clear(); 241 implts_unlock(); 242 } 243 244 void LayoutManager::implts_lock() 245 { 246 WriteGuard aWriteLock( m_aLock ); 247 ++m_nLockCount; 248 } 249 250 sal_Bool LayoutManager::implts_unlock() 251 { 252 WriteGuard aWriteLock( m_aLock ); 253 m_nLockCount = std::max( --m_nLockCount, static_cast<sal_Int32>(0) ); 254 return ( m_nLockCount == 0 ); 255 } 256 257 void LayoutManager::implts_reset( sal_Bool bAttached ) 258 { 259 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 260 ReadGuard aReadLock( m_aLock ); 261 Reference< XFrame > xFrame = m_xFrame; 262 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 263 Reference< XUIConfiguration > xModuleCfgMgr( m_xModuleCfgMgr, UNO_QUERY ); 264 Reference< XUIConfiguration > xDocCfgMgr( m_xDocCfgMgr, UNO_QUERY ); 265 Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState ); 266 Reference< XMultiServiceFactory > xServiceManager( m_xSMGR ); 267 Reference< XNameAccess > xPersistentWindowStateSupplier( m_xPersistentWindowStateSupplier ); 268 Reference< awt::XWindowListener > xToolbarManager( m_xToolbarManager, uno::UNO_QUERY ); 269 ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); 270 ::rtl::OUString aModuleIdentifier( m_aModuleIdentifier ); 271 bool bAutomaticToolbars( m_bAutomaticToolbars ); 272 aReadLock.unlock(); 273 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 274 275 implts_lock(); 276 277 Reference< XModel > xModel; 278 if ( xFrame.is() ) 279 { 280 if ( bAttached ) 281 { 282 ::rtl::OUString aOldModuleIdentifier( aModuleIdentifier ); 283 try 284 { 285 aModuleIdentifier = m_xModuleManager->identify( Reference< XInterface >( xFrame, UNO_QUERY ) ); 286 } 287 catch( Exception& ) {} 288 289 if ( aModuleIdentifier.getLength() && aOldModuleIdentifier != aModuleIdentifier ) 290 { 291 Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier; 292 if ( xServiceManager.is() ) 293 xModuleCfgSupplier = Reference< XModuleUIConfigurationManagerSupplier >( 294 xServiceManager->createInstance( SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER ), UNO_QUERY ); 295 296 if ( xModuleCfgMgr.is() ) 297 { 298 try 299 { 300 // Remove listener to old module ui configuration manager 301 xModuleCfgMgr->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 302 } 303 catch ( Exception& ) {} 304 } 305 306 try 307 { 308 // Add listener to new module ui configuration manager 309 xModuleCfgMgr = Reference< XUIConfiguration >( xModuleCfgSupplier->getUIConfigurationManager( aModuleIdentifier ), UNO_QUERY ); 310 if ( xModuleCfgMgr.is() ) 311 xModuleCfgMgr->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 312 } 313 catch ( Exception& ) {} 314 315 try 316 { 317 // Retrieve persistent window state reference for our new module 318 if ( xPersistentWindowStateSupplier.is() ) 319 xPersistentWindowStateSupplier->getByName( aModuleIdentifier ) >>= xPersistentWindowState; 320 } 321 catch ( NoSuchElementException& ) {} 322 catch ( WrappedTargetException& ) {} 323 } 324 325 xModel = impl_getModelFromFrame( xFrame ); 326 if ( xModel.is() ) 327 { 328 Reference< XUIConfigurationManagerSupplier > xUIConfigurationManagerSupplier( xModel, UNO_QUERY ); 329 if ( xUIConfigurationManagerSupplier.is() ) 330 { 331 if ( xDocCfgMgr.is() ) 332 { 333 try 334 { 335 // Remove listener to old ui configuration manager 336 xDocCfgMgr->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 337 } 338 catch ( Exception& ) {} 339 } 340 341 try 342 { 343 xDocCfgMgr = Reference< XUIConfiguration >( xUIConfigurationManagerSupplier->getUIConfigurationManager(), UNO_QUERY ); 344 if ( xDocCfgMgr.is() ) 345 xDocCfgMgr->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 346 } 347 catch ( Exception& ) {} 348 } 349 } 350 } 351 else 352 { 353 // Remove configuration listeners before we can release our references 354 if ( xModuleCfgMgr.is() ) 355 { 356 try 357 { 358 xModuleCfgMgr->removeConfigurationListener( 359 Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 360 } 361 catch ( Exception& ) {} 362 } 363 364 if ( xDocCfgMgr.is() ) 365 { 366 try 367 { 368 xDocCfgMgr->removeConfigurationListener( 369 Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 370 } 371 catch ( Exception& ) {} 372 } 373 374 // Release references to our configuration managers as we currently don't have 375 // an attached module. 376 xModuleCfgMgr.clear(); 377 xDocCfgMgr.clear(); 378 xPersistentWindowState.clear(); 379 aModuleIdentifier = ::rtl::OUString(); 380 } 381 382 Reference< XUIConfigurationManager > xModCfgMgr( xModuleCfgMgr, UNO_QUERY ); 383 Reference< XUIConfigurationManager > xDokCfgMgr( xDocCfgMgr, UNO_QUERY ); 384 385 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 386 WriteGuard aWriteLock( m_aLock ); 387 m_xModel = xModel; 388 m_aDockingArea = awt::Rectangle(); 389 m_bComponentAttached = bAttached; 390 m_aModuleIdentifier = aModuleIdentifier; 391 m_xModuleCfgMgr = xModCfgMgr; 392 m_xDocCfgMgr = xDokCfgMgr; 393 m_xPersistentWindowState = xPersistentWindowState; 394 m_aStatusBarElement.m_bStateRead = sal_False; // reset state to read data again! 395 aWriteLock.unlock(); 396 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 397 398 // reset/notify toolbar layout manager 399 if ( pToolbarManager ) 400 { 401 if ( bAttached ) 402 { 403 pToolbarManager->attach( xFrame, xModCfgMgr, xDokCfgMgr, xPersistentWindowState ); 404 uno::Reference< awt::XWindowPeer > xParent( xContainerWindow, UNO_QUERY ); 405 pToolbarManager->setParentWindow( xParent ); 406 if ( bAutomaticToolbars ) 407 pToolbarManager->createStaticToolbars(); 408 } 409 else 410 { 411 pToolbarManager->reset(); 412 implts_destroyElements(); 413 } 414 } 415 } 416 417 implts_unlock(); 418 } 419 420 sal_Bool LayoutManager::implts_isEmbeddedLayoutManager() const 421 { 422 ReadGuard aReadLock( m_aLock ); 423 Reference< XFrame > xFrame = m_xFrame; 424 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 425 aReadLock.unlock(); 426 427 Reference< awt::XWindow > xFrameContainerWindow = xFrame->getContainerWindow(); 428 if ( xFrameContainerWindow == xContainerWindow ) 429 return sal_False; 430 else 431 return sal_True; 432 } 433 434 void LayoutManager::implts_destroyElements() 435 { 436 WriteGuard aWriteLock( m_aLock ); 437 uno::Reference< ui::XUIConfigurationListener > xThis( m_xToolbarManager ); 438 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 439 aWriteLock.unlock(); 440 441 if ( pToolbarManager ) 442 pToolbarManager->destroyToolbars(); 443 444 implts_destroyStatusBar(); 445 446 aWriteLock.lock(); 447 impl_clearUpMenuBar(); 448 aWriteLock.unlock(); 449 } 450 451 void LayoutManager::implts_toggleFloatingUIElementsVisibility( sal_Bool bActive ) 452 { 453 ReadGuard aReadLock( m_aLock ); 454 uno::Reference< ui::XUIConfigurationListener > xThis( m_xToolbarManager ); 455 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 456 aReadLock.unlock(); 457 458 if ( pToolbarManager ) 459 pToolbarManager->setFloatingToolbarsVisibility( bActive ); 460 } 461 462 uno::Reference< ui::XUIElement > LayoutManager::implts_findElement( const rtl::OUString& aName ) 463 { 464 ::rtl::OUString aElementType; 465 ::rtl::OUString aElementName; 466 467 parseResourceURL( aName, aElementType, aElementName ); 468 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "menubar" )) 469 return m_xMenuBar; 470 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) || ( m_aStatusBarElement.m_aName == aName )) 471 return m_aStatusBarElement.m_xUIElement; 472 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" )) 473 return m_aProgressBarElement.m_xUIElement; 474 475 return uno::Reference< ui::XUIElement >(); 476 } 477 478 UIElement& LayoutManager::impl_findElement( const rtl::OUString& aName ) 479 { 480 static UIElement aEmptyElement; 481 482 ::rtl::OUString aElementType; 483 ::rtl::OUString aElementName; 484 485 parseResourceURL( aName, aElementType, aElementName ); 486 if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) || ( m_aStatusBarElement.m_aName == aName )) 487 return m_aStatusBarElement; 488 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" )) 489 return m_aProgressBarElement; 490 491 return aEmptyElement; 492 } 493 494 sal_Bool LayoutManager::implts_readWindowStateData( const rtl::OUString& aName, UIElement& rElementData ) 495 { 496 sal_Bool bGetSettingsState( sal_False ); 497 498 WriteGuard aWriteLock( m_aLock ); 499 Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState ); 500 aWriteLock.unlock(); 501 502 if ( xPersistentWindowState.is() ) 503 { 504 aWriteLock.lock(); 505 sal_Bool bGlobalSettings( m_bGlobalSettings ); 506 GlobalSettings* pGlobalSettings( 0 ); 507 if ( m_pGlobalSettings == 0 ) 508 { 509 m_pGlobalSettings = new GlobalSettings( m_xSMGR ); 510 bGetSettingsState = sal_True; 511 } 512 pGlobalSettings = m_pGlobalSettings; 513 aWriteLock.unlock(); 514 515 try 516 { 517 Sequence< PropertyValue > aWindowState; 518 if ( xPersistentWindowState->hasByName( aName ) && (xPersistentWindowState->getByName( aName ) >>= aWindowState) ) 519 { 520 sal_Bool bValue( sal_False ); 521 for ( sal_Int32 n = 0; n < aWindowState.getLength(); n++ ) 522 { 523 if ( aWindowState[n].Name == m_aPropDocked ) 524 { 525 if ( aWindowState[n].Value >>= bValue ) 526 rElementData.m_bFloating = !bValue; 527 } 528 else if ( aWindowState[n].Name == m_aPropVisible ) 529 { 530 if ( aWindowState[n].Value >>= bValue ) 531 rElementData.m_bVisible = bValue; 532 } 533 else if ( aWindowState[n].Name == m_aPropDockingArea ) 534 { 535 ui::DockingArea eDockingArea; 536 if ( aWindowState[n].Value >>= eDockingArea ) 537 rElementData.m_aDockedData.m_nDockedArea = sal_Int16( eDockingArea ); 538 } 539 else if ( aWindowState[n].Name == m_aPropDockPos ) 540 { 541 awt::Point aPoint; 542 if ( aWindowState[n].Value >>= aPoint ) 543 { 544 rElementData.m_aDockedData.m_aPos.X() = aPoint.X; 545 rElementData.m_aDockedData.m_aPos.Y() = aPoint.Y; 546 } 547 } 548 else if ( aWindowState[n].Name == m_aPropPos ) 549 { 550 awt::Point aPoint; 551 if ( aWindowState[n].Value >>= aPoint ) 552 { 553 rElementData.m_aFloatingData.m_aPos.X() = aPoint.X; 554 rElementData.m_aFloatingData.m_aPos.Y() = aPoint.Y; 555 } 556 } 557 else if ( aWindowState[n].Name == m_aPropSize ) 558 { 559 awt::Size aSize; 560 if ( aWindowState[n].Value >>= aSize ) 561 { 562 rElementData.m_aFloatingData.m_aSize.Width() = aSize.Width; 563 rElementData.m_aFloatingData.m_aSize.Height() = aSize.Height; 564 } 565 } 566 else if ( aWindowState[n].Name == m_aPropUIName ) 567 aWindowState[n].Value >>= rElementData.m_aUIName; 568 else if ( aWindowState[n].Name == m_aPropStyle ) 569 { 570 sal_Int32 nStyle = 0; 571 if ( aWindowState[n].Value >>= nStyle ) 572 rElementData.m_nStyle = sal_Int16( nStyle ); 573 } 574 else if ( aWindowState[n].Name == m_aPropLocked ) 575 { 576 if ( aWindowState[n].Value >>= bValue ) 577 rElementData.m_aDockedData.m_bLocked = bValue; 578 } 579 else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_CONTEXT )) 580 { 581 if ( aWindowState[n].Value >>= bValue ) 582 rElementData.m_bContextSensitive = bValue; 583 } 584 else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_NOCLOSE )) 585 { 586 if ( aWindowState[n].Value >>= bValue ) 587 rElementData.m_bNoClose = bValue; 588 } 589 else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_CONTEXTACTIVE )) 590 { 591 if ( aWindowState[n].Value >>= bValue ) 592 rElementData.m_bContextActive = bValue; 593 } 594 else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_SOFTCLOSE )) 595 { 596 if ( aWindowState[n].Value >>= bValue ) 597 rElementData.m_bSoftClose = bValue; 598 } 599 } 600 } 601 602 // oversteer values with global settings 603 if ( pGlobalSettings && ( bGetSettingsState || bGlobalSettings )) 604 { 605 if ( pGlobalSettings->HasStatesInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR )) 606 { 607 WriteGuard aWriteLock2( m_aLock ); 608 m_bGlobalSettings = sal_True; 609 aWriteLock2.unlock(); 610 611 uno::Any aValue; 612 sal_Bool bValue = sal_Bool(); 613 if ( pGlobalSettings->GetStateInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR, 614 GlobalSettings::STATEINFO_LOCKED, 615 aValue )) 616 aValue >>= rElementData.m_aDockedData.m_bLocked; 617 if ( pGlobalSettings->GetStateInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR, 618 GlobalSettings::STATEINFO_DOCKED, 619 aValue )) 620 { 621 if ( aValue >>= bValue ) 622 rElementData.m_bFloating = !bValue; 623 } 624 } 625 } 626 627 return sal_True; 628 } 629 catch ( NoSuchElementException& ) {} 630 } 631 632 return sal_False; 633 } 634 635 void LayoutManager::implts_writeWindowStateData( const rtl::OUString& aName, const UIElement& rElementData ) 636 { 637 WriteGuard aWriteLock( m_aLock ); 638 Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState ); 639 640 // set flag to determine that we triggered the notification 641 m_bStoreWindowState = sal_True; 642 aWriteLock.unlock(); 643 644 sal_Bool bPersistent( sal_False ); 645 Reference< XPropertySet > xPropSet( rElementData.m_xUIElement, UNO_QUERY ); 646 if ( xPropSet.is() ) 647 { 648 try 649 { 650 // Check persistent flag of the user interface element 651 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" ))) >>= bPersistent; 652 } 653 catch ( beans::UnknownPropertyException ) 654 { 655 // Non-configurable elements should at least store their dimension/position 656 bPersistent = sal_True; 657 } 658 catch ( lang::WrappedTargetException ) {} 659 } 660 661 if ( bPersistent && xPersistentWindowState.is() ) 662 { 663 try 664 { 665 Sequence< PropertyValue > aWindowState( 8 ); 666 667 aWindowState[0].Name = m_aPropDocked; 668 aWindowState[0].Value = makeAny( sal_Bool( !rElementData.m_bFloating )); 669 aWindowState[1].Name = m_aPropVisible; 670 aWindowState[1].Value = makeAny( sal_Bool( rElementData.m_bVisible )); 671 672 aWindowState[2].Name = m_aPropDockingArea; 673 aWindowState[2].Value = makeAny( static_cast< DockingArea >( rElementData.m_aDockedData.m_nDockedArea ) ); 674 675 awt::Point aPos; 676 aPos.X = rElementData.m_aDockedData.m_aPos.X(); 677 aPos.Y = rElementData.m_aDockedData.m_aPos.Y(); 678 aWindowState[3].Name = m_aPropDockPos; 679 aWindowState[3].Value <<= aPos; 680 681 aPos.X = rElementData.m_aFloatingData.m_aPos.X(); 682 aPos.Y = rElementData.m_aFloatingData.m_aPos.Y(); 683 aWindowState[4].Name = m_aPropPos; 684 aWindowState[4].Value <<= aPos; 685 686 awt::Size aSize; 687 aSize.Width = rElementData.m_aFloatingData.m_aSize.Width(); 688 aSize.Height = rElementData.m_aFloatingData.m_aSize.Height(); 689 aWindowState[5].Name = m_aPropSize; 690 aWindowState[5].Value <<= aSize; 691 aWindowState[6].Name = m_aPropUIName; 692 aWindowState[6].Value = makeAny( rElementData.m_aUIName ); 693 aWindowState[7].Name = m_aPropLocked; 694 aWindowState[7].Value = makeAny( rElementData.m_aDockedData.m_bLocked ); 695 696 if ( xPersistentWindowState->hasByName( aName )) 697 { 698 Reference< XNameReplace > xReplace( xPersistentWindowState, uno::UNO_QUERY ); 699 xReplace->replaceByName( aName, makeAny( aWindowState )); 700 } 701 else 702 { 703 Reference< XNameContainer > xInsert( xPersistentWindowState, uno::UNO_QUERY ); 704 xInsert->insertByName( aName, makeAny( aWindowState )); 705 } 706 } 707 catch ( Exception& ) {} 708 } 709 710 // Reset flag 711 aWriteLock.lock(); 712 m_bStoreWindowState = sal_False; 713 aWriteLock.unlock(); 714 } 715 716 ::Size LayoutManager::implts_getContainerWindowOutputSize() 717 { 718 ::Size aContainerWinSize; 719 Window* pContainerWindow( 0 ); 720 721 // Retrieve output size from container Window 722 vos::OGuard aGuard( Application::GetSolarMutex() ); 723 pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow ); 724 if ( pContainerWindow ) 725 aContainerWinSize = pContainerWindow->GetOutputSizePixel(); 726 727 return aContainerWinSize; 728 } 729 730 Reference< XUIElement > LayoutManager::implts_createElement( const rtl::OUString& aName ) 731 { 732 Reference< ui::XUIElement > xUIElement; 733 734 ReadGuard aReadLock( m_aLock ); 735 Sequence< PropertyValue > aPropSeq( 2 ); 736 aPropSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); 737 aPropSeq[0].Value <<= m_xFrame; 738 aPropSeq[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" )); 739 aPropSeq[1].Value <<= sal_True; 740 741 try 742 { 743 xUIElement = m_xUIElementFactoryManager->createUIElement( aName, aPropSeq ); 744 } 745 catch ( NoSuchElementException& ) {} 746 catch ( IllegalArgumentException& ) {} 747 748 return xUIElement; 749 } 750 751 void LayoutManager::implts_setVisibleState( sal_Bool bShow ) 752 { 753 WriteGuard aWriteLock( m_aLock ); 754 m_aStatusBarElement.m_bMasterHide = !bShow; 755 aWriteLock.unlock(); 756 757 implts_updateUIElementsVisibleState( bShow ); 758 } 759 760 void LayoutManager::implts_updateUIElementsVisibleState( sal_Bool bSetVisible ) 761 { 762 // notify listeners 763 uno::Any a; 764 if ( bSetVisible ) 765 implts_notifyListeners( frame::LayoutManagerEvents::VISIBLE, a ); 766 else 767 implts_notifyListeners( frame::LayoutManagerEvents::INVISIBLE, a ); 768 std::vector< Reference< awt::XWindow > > aWinVector; 769 770 WriteGuard aWriteLock( m_aLock ); 771 Reference< XUIElement > xMenuBar( m_xMenuBar, UNO_QUERY ); 772 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 773 Reference< XComponent > xInplaceMenuBar( m_xInplaceMenuBar ); 774 MenuBarManager* pInplaceMenuBar( m_pInplaceMenuBar ); 775 aWriteLock.unlock(); 776 777 bool bMustDoLayout(false); 778 if (( xMenuBar.is() || xInplaceMenuBar.is() ) && xContainerWindow.is() ) 779 { 780 vos::OGuard aGuard( Application::GetSolarMutex() ); 781 782 MenuBar* pMenuBar( 0 ); 783 if ( xInplaceMenuBar.is() ) 784 pMenuBar = (MenuBar *)pInplaceMenuBar->GetMenuBar(); 785 else 786 { 787 MenuBarWrapper* pMenuBarWrapper = SAL_STATIC_CAST( MenuBarWrapper*, xMenuBar.get() ); 788 pMenuBar = (MenuBar *)pMenuBarWrapper->GetMenuBarManager()->GetMenuBar(); 789 } 790 791 SystemWindow* pSysWindow = getTopSystemWindow( xContainerWindow ); 792 if ( pSysWindow ) 793 { 794 if ( bSetVisible ) 795 pSysWindow->SetMenuBar( pMenuBar ); 796 else 797 pSysWindow->SetMenuBar( 0 ); 798 bMustDoLayout = true; 799 } 800 } 801 802 // Hide/show the statusbar according to bSetVisible 803 if ( bSetVisible ) 804 bMustDoLayout = !implts_showStatusBar(); 805 else 806 bMustDoLayout = !implts_hideStatusBar(); 807 808 aWriteLock.lock(); 809 uno::Reference< ui::XUIConfigurationListener > xThis( m_xToolbarManager ); 810 ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); 811 aWriteLock.unlock(); 812 813 if ( pToolbarManager ) 814 { 815 pToolbarManager->setVisible( bSetVisible ); 816 bMustDoLayout = pToolbarManager->isLayoutDirty(); 817 } 818 819 if ( bMustDoLayout ) 820 implts_doLayout_notify( sal_False ); 821 } 822 823 void LayoutManager::implts_setCurrentUIVisibility( sal_Bool bShow ) 824 { 825 WriteGuard aWriteLock( m_aLock ); 826 if ( !bShow && m_aStatusBarElement.m_bVisible && m_aStatusBarElement.m_xUIElement.is() ) 827 m_aStatusBarElement.m_bMasterHide = true; 828 else if ( bShow && m_aStatusBarElement.m_bVisible ) 829 m_aStatusBarElement.m_bMasterHide = false; 830 aWriteLock.unlock(); 831 832 implts_updateUIElementsVisibleState( bShow ); 833 } 834 835 void LayoutManager::implts_destroyStatusBar() 836 { 837 Reference< XComponent > xCompStatusBar; 838 839 WriteGuard aWriteLock( m_aLock ); 840 m_aStatusBarElement.m_aName = rtl::OUString(); 841 xCompStatusBar = Reference< XComponent >( m_aStatusBarElement.m_xUIElement, UNO_QUERY ); 842 m_aStatusBarElement.m_xUIElement.clear(); 843 aWriteLock.unlock(); 844 845 if ( xCompStatusBar.is() ) 846 xCompStatusBar->dispose(); 847 848 implts_destroyProgressBar(); 849 } 850 851 void LayoutManager::implts_createStatusBar( const rtl::OUString& aStatusBarName ) 852 { 853 WriteGuard aWriteLock( m_aLock ); 854 if ( !m_aStatusBarElement.m_xUIElement.is() ) 855 { 856 implts_readStatusBarState( aStatusBarName ); 857 m_aStatusBarElement.m_aName = aStatusBarName; 858 m_aStatusBarElement.m_xUIElement = implts_createElement( aStatusBarName ); 859 } 860 aWriteLock.unlock(); 861 862 implts_createProgressBar(); 863 } 864 865 void LayoutManager::implts_readStatusBarState( const rtl::OUString& rStatusBarName ) 866 { 867 WriteGuard aWriteLock( m_aLock ); 868 if ( !m_aStatusBarElement.m_bStateRead ) 869 { 870 // Read persistent data for status bar if not yet read! 871 if ( implts_readWindowStateData( rStatusBarName, m_aStatusBarElement )) 872 m_aStatusBarElement.m_bStateRead = sal_True; 873 } 874 } 875 876 void LayoutManager::implts_createProgressBar() 877 { 878 Reference< XUIElement > xStatusBar; 879 Reference< XUIElement > xProgressBar; 880 Reference< XUIElement > xProgressBarBackup; 881 Reference< awt::XWindow > xContainerWindow; 882 883 WriteGuard aWriteLock( m_aLock ); 884 xStatusBar = Reference< XUIElement >( m_aStatusBarElement.m_xUIElement, UNO_QUERY ); 885 xProgressBar = Reference< XUIElement >( m_aProgressBarElement.m_xUIElement, UNO_QUERY ); 886 xProgressBarBackup = m_xProgressBarBackup; 887 m_xProgressBarBackup.clear(); 888 xContainerWindow = m_xContainerWindow; 889 aWriteLock.unlock(); 890 891 sal_Bool bRecycled = xProgressBarBackup.is(); 892 ProgressBarWrapper* pWrapper = 0; 893 if ( bRecycled ) 894 pWrapper = (ProgressBarWrapper*)xProgressBarBackup.get(); 895 else if ( xProgressBar.is() ) 896 pWrapper = (ProgressBarWrapper*)xProgressBar.get(); 897 else 898 pWrapper = new ProgressBarWrapper(); 899 900 if ( xStatusBar.is() ) 901 { 902 Reference< awt::XWindow > xWindow( xStatusBar->getRealInterface(), UNO_QUERY ); 903 pWrapper->setStatusBar( xWindow ); 904 } 905 else 906 { 907 Reference< awt::XWindow > xStatusBarWindow = pWrapper->getStatusBar(); 908 909 vos::OGuard aGuard( Application::GetSolarMutex() ); 910 Window* pStatusBarWnd = VCLUnoHelper::GetWindow( xStatusBarWindow ); 911 if ( !pStatusBarWnd ) 912 { 913 Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow ); 914 if ( pWindow ) 915 { 916 StatusBar* pStatusBar = new StatusBar( pWindow, WinBits( WB_LEFT | WB_3DLOOK ) ); 917 Reference< awt::XWindow > xStatusBarWindow2( VCLUnoHelper::GetInterface( pStatusBar )); 918 pWrapper->setStatusBar( xStatusBarWindow2, sal_True ); 919 } 920 } 921 } 922 923 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 924 aWriteLock.lock(); 925 m_aProgressBarElement.m_xUIElement = Reference< XUIElement >( 926 static_cast< cppu::OWeakObject* >( pWrapper ), UNO_QUERY ); 927 aWriteLock.unlock(); 928 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 929 930 if ( bRecycled ) 931 implts_showProgressBar(); 932 } 933 934 void LayoutManager::implts_backupProgressBarWrapper() 935 { 936 // SAFE -> ---------------------------------- 937 WriteGuard aWriteLock(m_aLock); 938 939 if (m_xProgressBarBackup.is()) 940 return; 941 942 // safe a backup copy of the current progress! 943 // This copy will be used automatically inside createProgressBar() which is called 944 // implictly from implts_doLayout() .-) 945 m_xProgressBarBackup = m_aProgressBarElement.m_xUIElement; 946 947 // remove the relation between this old progress bar and our old status bar. 948 // Otherwise we work on disposed items ... 949 // The internal used ProgressBarWrapper can handle a NULL reference. 950 if ( m_xProgressBarBackup.is() ) 951 { 952 ProgressBarWrapper* pWrapper = (ProgressBarWrapper*)m_xProgressBarBackup.get(); 953 if ( pWrapper ) 954 pWrapper->setStatusBar( Reference< awt::XWindow >(), sal_False ); 955 } 956 957 // prevent us from dispose() the m_aProgressBarElement.m_xUIElement inside implts_reset() 958 m_aProgressBarElement.m_xUIElement.clear(); 959 960 aWriteLock.unlock(); 961 // <- SAFE ---------------------------------- 962 } 963 964 void LayoutManager::implts_destroyProgressBar() 965 { 966 // dont remove the progressbar in general 967 // We must reuse it if a new status bar is created later. 968 // Of course there exists one backup only. 969 // And further this backup will be released inside our dtor. 970 implts_backupProgressBarWrapper(); 971 } 972 973 void LayoutManager::implts_setStatusBarPosSize( const ::Point& rPos, const ::Size& rSize ) 974 { 975 Reference< XUIElement > xStatusBar; 976 Reference< XUIElement > xProgressBar; 977 Reference< awt::XWindow > xContainerWindow; 978 979 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 980 ReadGuard aReadLock( m_aLock ); 981 xStatusBar = Reference< XUIElement >( m_aStatusBarElement.m_xUIElement, UNO_QUERY ); 982 xProgressBar = Reference< XUIElement >( m_aProgressBarElement.m_xUIElement, UNO_QUERY ); 983 xContainerWindow = m_xContainerWindow; 984 985 Reference< awt::XWindow > xWindow; 986 if ( xStatusBar.is() ) 987 xWindow = Reference< awt::XWindow >( xStatusBar->getRealInterface(), UNO_QUERY ); 988 else if ( xProgressBar.is() ) 989 { 990 ProgressBarWrapper* pWrapper = (ProgressBarWrapper*)xProgressBar.get(); 991 if ( pWrapper ) 992 xWindow = pWrapper->getStatusBar(); 993 } 994 aReadLock.unlock(); 995 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 996 997 if ( xWindow.is() ) 998 { 999 vos::OGuard aGuard( Application::GetSolarMutex() ); 1000 Window* pParentWindow = VCLUnoHelper::GetWindow( xContainerWindow ); 1001 Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); 1002 if ( pParentWindow && ( pWindow && pWindow->GetType() == WINDOW_STATUSBAR )) 1003 { 1004 Window* pOldParentWindow = pWindow->GetParent(); 1005 if ( pParentWindow != pOldParentWindow ) 1006 pWindow->SetParent( pParentWindow ); 1007 ((StatusBar *)pWindow)->SetPosSizePixel( rPos, rSize ); 1008 } 1009 } 1010 } 1011 1012 sal_Bool LayoutManager::implts_showProgressBar() 1013 { 1014 Reference< XUIElement > xStatusBar; 1015 Reference< XUIElement > xProgressBar; 1016 Reference< awt::XWindow > xWindow; 1017 1018 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1019 WriteGuard aWriteLock( m_aLock ); 1020 xStatusBar = Reference< XUIElement >( m_aStatusBarElement.m_xUIElement, UNO_QUERY ); 1021 xProgressBar = Reference< XUIElement >( m_aProgressBarElement.m_xUIElement, UNO_QUERY ); 1022 sal_Bool bVisible( m_bVisible ); 1023 1024 m_aProgressBarElement.m_bVisible = sal_True; 1025 if ( bVisible ) 1026 { 1027 if ( xStatusBar.is() && !m_aStatusBarElement.m_bMasterHide ) 1028 { 1029 xWindow = Reference< awt::XWindow >( xStatusBar->getRealInterface(), UNO_QUERY ); 1030 } 1031 else if ( xProgressBar.is() ) 1032 { 1033 ProgressBarWrapper* pWrapper = (ProgressBarWrapper*)xProgressBar.get(); 1034 if ( pWrapper ) 1035 xWindow = pWrapper->getStatusBar(); 1036 } 1037 } 1038 aWriteLock.unlock(); 1039 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1040 1041 vos::OGuard aGuard( Application::GetSolarMutex() ); 1042 Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); 1043 if ( pWindow ) 1044 { 1045 if ( !pWindow->IsVisible() ) 1046 { 1047 implts_setOffset( pWindow->GetSizePixel().Height() ); 1048 pWindow->Show(); 1049 implts_doLayout_notify( sal_False ); 1050 } 1051 return sal_True; 1052 } 1053 1054 return sal_False; 1055 } 1056 1057 sal_Bool LayoutManager::implts_hideProgressBar() 1058 { 1059 Reference< XUIElement > xProgressBar; 1060 Reference< awt::XWindow > xWindow; 1061 sal_Bool bHideStatusBar( sal_False ); 1062 1063 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1064 WriteGuard aWriteLock( m_aLock ); 1065 xProgressBar = Reference< XUIElement >( m_aProgressBarElement.m_xUIElement, UNO_QUERY ); 1066 1067 sal_Bool bInternalStatusBar( sal_False ); 1068 if ( xProgressBar.is() ) 1069 { 1070 Reference< awt::XWindow > xStatusBar; 1071 ProgressBarWrapper* pWrapper = (ProgressBarWrapper*)xProgressBar.get(); 1072 if ( pWrapper ) 1073 xWindow = pWrapper->getStatusBar(); 1074 Reference< ui::XUIElement > xStatusBarElement = m_aStatusBarElement.m_xUIElement; 1075 if ( xStatusBarElement.is() ) 1076 xStatusBar = Reference< awt::XWindow >( xStatusBarElement->getRealInterface(), UNO_QUERY ); 1077 bInternalStatusBar = xStatusBar != xWindow; 1078 } 1079 m_aProgressBarElement.m_bVisible = sal_False; 1080 implts_readStatusBarState( m_aStatusBarAlias ); 1081 bHideStatusBar = !m_aStatusBarElement.m_bVisible; 1082 aWriteLock.unlock(); 1083 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1084 1085 vos::OGuard aGuard( Application::GetSolarMutex() ); 1086 Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); 1087 if ( pWindow && pWindow->IsVisible() && ( bHideStatusBar || bInternalStatusBar )) 1088 { 1089 implts_setOffset( 0 ); 1090 pWindow->Hide(); 1091 implts_doLayout_notify( sal_False ); 1092 return sal_True; 1093 } 1094 1095 return sal_False; 1096 } 1097 1098 sal_Bool LayoutManager::implts_showStatusBar( sal_Bool bStoreState ) 1099 { 1100 WriteGuard aWriteLock( m_aLock ); 1101 Reference< ui::XUIElement > xStatusBar = m_aStatusBarElement.m_xUIElement; 1102 if ( bStoreState ) 1103 m_aStatusBarElement.m_bVisible = sal_True; 1104 aWriteLock.unlock(); 1105 1106 if ( xStatusBar.is() ) 1107 { 1108 Reference< awt::XWindow > xWindow( xStatusBar->getRealInterface(), UNO_QUERY ); 1109 1110 vos::OGuard aGuard( Application::GetSolarMutex() ); 1111 Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); 1112 if ( pWindow && !pWindow->IsVisible() ) 1113 { 1114 implts_setOffset( pWindow->GetSizePixel().Height() ); 1115 pWindow->Show(); 1116 implts_doLayout_notify( sal_False ); 1117 return sal_True; 1118 } 1119 } 1120 1121 return sal_False; 1122 } 1123 1124 sal_Bool LayoutManager::implts_hideStatusBar( sal_Bool bStoreState ) 1125 { 1126 WriteGuard aWriteLock( m_aLock ); 1127 Reference< ui::XUIElement > xStatusBar = m_aStatusBarElement.m_xUIElement; 1128 if ( bStoreState ) 1129 m_aStatusBarElement.m_bVisible = sal_False; 1130 aWriteLock.unlock(); 1131 1132 if ( xStatusBar.is() ) 1133 { 1134 Reference< awt::XWindow > xWindow( xStatusBar->getRealInterface(), UNO_QUERY ); 1135 1136 vos::OGuard aGuard( Application::GetSolarMutex() ); 1137 Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); 1138 if ( pWindow && pWindow->IsVisible() ) 1139 { 1140 implts_setOffset( 0 ); 1141 pWindow->Hide(); 1142 implts_doLayout_notify( sal_False ); 1143 return sal_True; 1144 } 1145 } 1146 1147 return sal_False; 1148 } 1149 1150 void LayoutManager::implts_setOffset( const sal_Int32 nBottomOffset ) 1151 { 1152 ::Rectangle aOffsetRect; 1153 setZeroRectangle( aOffsetRect ); 1154 aOffsetRect.setHeight( nBottomOffset ); 1155 1156 // make sure that the toolbar manager refernence/pointer is valid 1157 uno::Reference< ui::XUIConfigurationListener > xThis( m_xToolbarManager ); 1158 if ( xThis.is() ) 1159 m_pToolbarManager->setDockingAreaOffsets( aOffsetRect ); 1160 } 1161 1162 void LayoutManager::implts_setInplaceMenuBar( const Reference< XIndexAccess >& xMergedMenuBar ) 1163 { 1164 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1165 WriteGuard aWriteLock( m_aLock ); 1166 1167 if ( !m_bInplaceMenuSet ) 1168 { 1169 vos::OGuard aGuard( Application::GetSolarMutex() ); 1170 1171 // Reset old inplace menubar! 1172 m_pInplaceMenuBar = 0; 1173 if ( m_xInplaceMenuBar.is() ) 1174 m_xInplaceMenuBar->dispose(); 1175 m_xInplaceMenuBar.clear(); 1176 m_bInplaceMenuSet = sal_False; 1177 1178 if ( m_xFrame.is() && m_xContainerWindow.is() ) 1179 { 1180 rtl::OUString aModuleIdentifier; 1181 Reference< XDispatchProvider > xDispatchProvider; 1182 1183 MenuBar* pMenuBar = new MenuBar; 1184 m_pInplaceMenuBar = new MenuBarManager( m_xSMGR, m_xFrame, m_xURLTransformer,xDispatchProvider, aModuleIdentifier, pMenuBar, sal_True, sal_True ); 1185 m_pInplaceMenuBar->SetItemContainer( xMergedMenuBar ); 1186 1187 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow ); 1188 if ( pSysWindow ) 1189 pSysWindow->SetMenuBar( pMenuBar ); 1190 1191 m_bInplaceMenuSet = sal_True; 1192 m_xInplaceMenuBar = Reference< XComponent >( (OWeakObject *)m_pInplaceMenuBar, UNO_QUERY ); 1193 } 1194 1195 aWriteLock.unlock(); 1196 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1197 1198 implts_updateMenuBarClose(); 1199 } 1200 } 1201 1202 void LayoutManager::implts_resetInplaceMenuBar() 1203 { 1204 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1205 WriteGuard aWriteLock( m_aLock ); 1206 m_bInplaceMenuSet = sal_False; 1207 1208 // if ( m_xMenuBar.is() && 1209 if ( m_xContainerWindow.is() ) 1210 { 1211 vos::OGuard aGuard( Application::GetSolarMutex() ); 1212 MenuBarWrapper* pMenuBarWrapper = SAL_STATIC_CAST( MenuBarWrapper*, m_xMenuBar.get() ); 1213 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow ); 1214 if ( pSysWindow ) 1215 { 1216 if ( pMenuBarWrapper ) 1217 pSysWindow->SetMenuBar( (MenuBar *)pMenuBarWrapper->GetMenuBarManager()->GetMenuBar() ); 1218 else 1219 pSysWindow->SetMenuBar( 0 ); 1220 } 1221 } 1222 1223 // Remove inplace menu bar 1224 m_pInplaceMenuBar = 0; 1225 if ( m_xInplaceMenuBar.is() ) 1226 m_xInplaceMenuBar->dispose(); 1227 m_xInplaceMenuBar.clear(); 1228 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1229 } 1230 1231 void SAL_CALL LayoutManager::attachFrame( const Reference< XFrame >& xFrame ) 1232 { 1233 WriteGuard aWriteLock( m_aLock ); 1234 m_xFrame = xFrame; 1235 } 1236 1237 void SAL_CALL LayoutManager::reset() 1238 { 1239 sal_Bool bComponentAttached( sal_False ); 1240 1241 ReadGuard aReadLock( m_aLock ); 1242 bComponentAttached = m_bComponentAttached; 1243 aReadLock.unlock(); 1244 1245 implts_reset( sal_True ); 1246 } 1247 1248 void SAL_CALL LayoutManager::setInplaceMenuBar( sal_Int64 ) 1249 { 1250 OSL_ENSURE( sal_False, "This method is obsolete and should not be used!\n" ); 1251 } 1252 1253 void SAL_CALL LayoutManager::resetInplaceMenuBar() 1254 { 1255 OSL_ENSURE( sal_False, "This method is obsolete and should not be used!\n" ); 1256 } 1257 1258 //--------------------------------------------------------------------------------------------------------- 1259 // XMenuBarMergingAcceptor 1260 //--------------------------------------------------------------------------------------------------------- 1261 sal_Bool SAL_CALL LayoutManager::setMergedMenuBar( 1262 const Reference< XIndexAccess >& xMergedMenuBar ) 1263 { 1264 implts_setInplaceMenuBar( xMergedMenuBar ); 1265 1266 uno::Any a; 1267 implts_notifyListeners( frame::LayoutManagerEvents::MERGEDMENUBAR, a ); 1268 return sal_True; 1269 } 1270 1271 void SAL_CALL LayoutManager::removeMergedMenuBar() 1272 { 1273 implts_resetInplaceMenuBar(); 1274 } 1275 1276 awt::Rectangle SAL_CALL LayoutManager::getCurrentDockingArea() 1277 { 1278 ReadGuard aReadLock( m_aLock ); 1279 return m_aDockingArea; 1280 } 1281 1282 Reference< XDockingAreaAcceptor > SAL_CALL LayoutManager::getDockingAreaAcceptor() 1283 { 1284 ReadGuard aReadLock( m_aLock ); 1285 return m_xDockingAreaAcceptor; 1286 } 1287 1288 void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDockingAreaAcceptor >& xDockingAreaAcceptor ) 1289 { 1290 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1291 WriteGuard aWriteLock( m_aLock ); 1292 1293 if (( m_xDockingAreaAcceptor == xDockingAreaAcceptor ) || !m_xFrame.is() ) 1294 return; 1295 1296 // IMPORTANT: Be sure to stop layout timer if don't have a docking area acceptor! 1297 if ( !xDockingAreaAcceptor.is() ) 1298 m_aAsyncLayoutTimer.Stop(); 1299 1300 sal_Bool bAutomaticToolbars( m_bAutomaticToolbars ); 1301 std::vector< Reference< awt::XWindow > > oldDockingAreaWindows; 1302 1303 uno::Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); 1304 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 1305 1306 if ( !xDockingAreaAcceptor.is() ) 1307 m_aAsyncLayoutTimer.Stop(); 1308 1309 // Remove listener from old docking area acceptor 1310 if ( m_xDockingAreaAcceptor.is() ) 1311 { 1312 Reference< awt::XWindow > xWindow( m_xDockingAreaAcceptor->getContainerWindow() ); 1313 if ( xWindow.is() && ( m_xFrame->getContainerWindow() != m_xContainerWindow || !xDockingAreaAcceptor.is() ) ) 1314 xWindow->removeWindowListener( Reference< awt::XWindowListener >( static_cast< OWeakObject * >( this ), UNO_QUERY )); 1315 1316 m_aDockingArea = awt::Rectangle(); 1317 if ( pToolbarManager ) 1318 pToolbarManager->resetDockingArea(); 1319 1320 Window* pContainerWindow = VCLUnoHelper::GetWindow( xWindow ); 1321 if ( pContainerWindow ) 1322 pContainerWindow->RemoveChildEventListener( LINK( this, LayoutManager, WindowEventListener ) ); 1323 } 1324 1325 Reference< ui::XDockingAreaAcceptor > xOldDockingAreaAcceptor( m_xDockingAreaAcceptor ); 1326 m_xDockingAreaAcceptor = xDockingAreaAcceptor; 1327 if ( m_xDockingAreaAcceptor.is() ) 1328 { 1329 m_aDockingArea = awt::Rectangle(); 1330 m_xContainerWindow = m_xDockingAreaAcceptor->getContainerWindow(); 1331 m_xContainerTopWindow.set( m_xContainerWindow, UNO_QUERY ); 1332 m_xContainerWindow->addWindowListener( Reference< awt::XWindowListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 1333 1334 // we always must keep a connection to the window of our frame for resize events 1335 if ( m_xContainerWindow != m_xFrame->getContainerWindow() ) 1336 m_xFrame->getContainerWindow()->addWindowListener( Reference< awt::XWindowListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 1337 1338 // #i37884# set initial visibility state - in the plugin case the container window is already shown 1339 // and we get no notification anymore 1340 { 1341 vos::OGuard aGuard( Application::GetSolarMutex() ); 1342 Window* pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow ); 1343 if( pContainerWindow ) 1344 m_bParentWindowVisible = pContainerWindow->IsVisible(); 1345 } 1346 1347 uno::Reference< awt::XWindowPeer > xParent( m_xContainerWindow, UNO_QUERY ); 1348 } 1349 1350 aWriteLock.unlock(); 1351 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1352 1353 if ( xDockingAreaAcceptor.is() ) 1354 { 1355 vos::OGuard aGuard( Application::GetSolarMutex() ); 1356 1357 // Add layout manager as listener to get notifications about toolbar button activities 1358 Window* pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow ); 1359 if ( pContainerWindow ) 1360 pContainerWindow->AddChildEventListener( LINK( this, LayoutManager, WindowEventListener ) ); 1361 1362 // We have now a new container window, reparent all child windows! 1363 implts_reparentChildWindows(); 1364 } 1365 else 1366 implts_destroyElements(); // remove all elements 1367 1368 if ( !oldDockingAreaWindows.empty() ) 1369 { 1370 // Reset docking area size for our old docking area acceptor 1371 awt::Rectangle aEmptyRect; 1372 xOldDockingAreaAcceptor->setDockingAreaSpace( aEmptyRect ); 1373 } 1374 1375 if ( xDockingAreaAcceptor.is() ) 1376 { 1377 if ( bAutomaticToolbars ) 1378 { 1379 lock(); 1380 pToolbarManager->createStaticToolbars(); 1381 unlock(); 1382 } 1383 implts_doLayout( sal_True, sal_False ); 1384 } 1385 } 1386 1387 void LayoutManager::implts_reparentChildWindows() 1388 { 1389 WriteGuard aWriteLock( m_aLock ); 1390 UIElement aStatusBarElement = m_aStatusBarElement; 1391 uno::Reference< awt::XWindow > xContainerWindow = m_xContainerWindow; 1392 aWriteLock.unlock(); 1393 1394 uno::Reference< awt::XWindow > xStatusBarWindow; 1395 if ( aStatusBarElement.m_xUIElement.is() ) 1396 { 1397 try 1398 { 1399 xStatusBarWindow = Reference< awt::XWindow >( aStatusBarElement.m_xUIElement->getRealInterface(), UNO_QUERY ); 1400 } 1401 catch ( RuntimeException& ) { throw; } 1402 catch ( Exception& ) {} 1403 } 1404 1405 if ( xStatusBarWindow.is() ) 1406 { 1407 vos::OGuard aGuard( Application::GetSolarMutex() ); 1408 Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); 1409 Window* pWindow = VCLUnoHelper::GetWindow( xStatusBarWindow ); 1410 if ( pWindow && pContainerWindow ) 1411 pWindow->SetParent( pContainerWindow ); 1412 } 1413 1414 implts_resetMenuBar(); 1415 1416 aWriteLock.lock(); 1417 uno::Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); 1418 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 1419 if ( pToolbarManager ) 1420 pToolbarManager->setParentWindow( uno::Reference< awt::XWindowPeer >( xContainerWindow, uno::UNO_QUERY )); 1421 aWriteLock.unlock(); 1422 } 1423 1424 uno::Reference< ui::XUIElement > LayoutManager::implts_createDockingWindow( const ::rtl::OUString& aElementName ) 1425 { 1426 Reference< XUIElement > xUIElement = implts_createElement( aElementName ); 1427 return xUIElement; 1428 } 1429 1430 IMPL_LINK( LayoutManager, WindowEventListener, VclSimpleEvent*, pEvent ) 1431 { 1432 long nResult( 1 ); 1433 1434 if ( pEvent && pEvent->ISA( VclWindowEvent )) 1435 { 1436 Window* pWindow = static_cast< VclWindowEvent* >(pEvent)->GetWindow(); 1437 if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX ) 1438 { 1439 ReadGuard aReadLock( m_aLock ); 1440 uno::Reference< ui::XUIConfigurationListener > xThis( m_xToolbarManager ); 1441 ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); 1442 aReadLock.unlock(); 1443 1444 if ( pToolbarManager ) 1445 nResult = pToolbarManager->childWindowEvent( pEvent ); 1446 } 1447 } 1448 1449 return nResult; 1450 } 1451 1452 void SAL_CALL LayoutManager::createElement( const ::rtl::OUString& aName ) 1453 { 1454 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::createElement" ); 1455 1456 ReadGuard aReadLock( m_aLock ); 1457 Reference< XFrame > xFrame = m_xFrame; 1458 Reference< XURLTransformer > xURLTransformer = m_xURLTransformer; 1459 sal_Bool bInPlaceMenu = m_bInplaceMenuSet; 1460 aReadLock.unlock(); 1461 1462 if ( !xFrame.is() ) 1463 return; 1464 1465 Reference< XModel > xModel( impl_getModelFromFrame( xFrame ) ); 1466 1467 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1468 WriteGuard aWriteLock( m_aLock ); 1469 1470 bool bMustBeLayouted( false ); 1471 bool bNotify( false ); 1472 1473 if ( m_xContainerWindow.is() && !implts_isPreviewModel( xModel ) ) // no UI elements on preview frames 1474 { 1475 ::rtl::OUString aElementType; 1476 ::rtl::OUString aElementName; 1477 1478 parseResourceURL( aName, aElementType, aElementName ); 1479 1480 if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR ) && m_pToolbarManager != NULL ) 1481 { 1482 bNotify = m_pToolbarManager->createToolbar( aName ); 1483 bMustBeLayouted = m_pToolbarManager->isLayoutDirty(); 1484 } 1485 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "menubar" )) 1486 { 1487 // PB 2004-12-15 #i38743# don't create a menubar if frame isn't top 1488 if ( !bInPlaceMenu && !m_xMenuBar.is() && implts_isFrameOrWindowTop( xFrame )) 1489 { 1490 m_xMenuBar = implts_createElement( aName ); 1491 if ( m_xMenuBar.is() ) 1492 { 1493 vos::OGuard aGuard( Application::GetSolarMutex() ); 1494 1495 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow ); 1496 if ( pSysWindow ) 1497 { 1498 Reference< awt::XMenuBar > xMenuBar; 1499 1500 Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY ); 1501 if ( xPropSet.is() ) 1502 { 1503 try 1504 { 1505 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMenuBar" ))) >>= xMenuBar; 1506 } 1507 catch ( beans::UnknownPropertyException ) {} 1508 catch ( lang::WrappedTargetException ) {} 1509 } 1510 1511 if ( xMenuBar.is() ) 1512 { 1513 VCLXMenu* pAwtMenuBar = VCLXMenu::GetImplementation( xMenuBar ); 1514 if ( pAwtMenuBar ) 1515 { 1516 MenuBar* pMenuBar = (MenuBar*)pAwtMenuBar->GetMenu(); 1517 if ( pMenuBar ) 1518 { 1519 pSysWindow->SetMenuBar( pMenuBar ); 1520 pMenuBar->SetDisplayable( m_bMenuVisible ); 1521 if ( m_bMenuVisible ) 1522 bNotify = sal_True; 1523 implts_updateMenuBarClose(); 1524 } 1525 } 1526 } 1527 } 1528 } 1529 } 1530 aWriteLock.unlock(); 1531 } 1532 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) && ( implts_isFrameOrWindowTop(xFrame) || implts_isEmbeddedLayoutManager() )) 1533 { 1534 implts_createStatusBar( aName ); 1535 bNotify = sal_True; 1536 } 1537 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" ) && implts_isFrameOrWindowTop(xFrame) ) 1538 { 1539 implts_createProgressBar(); 1540 bNotify = sal_True; 1541 } 1542 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) 1543 { 1544 // Add layout manager as listener for docking and other window events 1545 uno::Reference< uno::XInterface > xThis( static_cast< OWeakObject* >(this), uno::UNO_QUERY ); 1546 uno::Reference< ui::XUIElement > xUIElement( implts_createDockingWindow( aName )); 1547 1548 if ( xUIElement.is() ) 1549 { 1550 impl_addWindowListeners( xThis, xUIElement ); 1551 m_pPanelManager->addDockingWindow( aName, xUIElement ); 1552 } 1553 1554 // The docking window is created by a factory method located in the sfx2 library. 1555 // CreateDockingWindow( xFrame, aElementName ); 1556 } 1557 } 1558 1559 if ( bMustBeLayouted ) 1560 implts_doLayout_notify( sal_True ); 1561 1562 if ( bNotify ) 1563 { 1564 // UI element is invisible - provide information to listeners 1565 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( aName ) ); 1566 } 1567 } 1568 1569 void SAL_CALL LayoutManager::destroyElement( const ::rtl::OUString& aName ) 1570 { 1571 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::destroyElement" ); 1572 1573 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1574 WriteGuard aWriteLock( m_aLock ); 1575 1576 bool bMustBeLayouted( sal_False ); 1577 bool bMustBeDestroyed( sal_False ); 1578 bool bNotify( sal_False ); 1579 ::rtl::OUString aElementType; 1580 ::rtl::OUString aElementName; 1581 1582 Reference< XComponent > xComponent; 1583 parseResourceURL( aName, aElementType, aElementName ); 1584 1585 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "menubar" )) 1586 { 1587 if ( !m_bInplaceMenuSet ) 1588 { 1589 impl_clearUpMenuBar(); 1590 m_xMenuBar.clear(); 1591 bNotify = true; 1592 } 1593 } 1594 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) || 1595 ( m_aStatusBarElement.m_aName == aName )) 1596 { 1597 aWriteLock.unlock(); 1598 implts_destroyStatusBar(); 1599 bMustBeLayouted = true; 1600 bNotify = true; 1601 } 1602 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" )) 1603 { 1604 aWriteLock.unlock(); 1605 implts_createProgressBar(); 1606 bMustBeLayouted = true; 1607 bNotify = sal_True; 1608 } 1609 else if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR ) && m_pToolbarManager != NULL ) 1610 { 1611 aWriteLock.unlock(); 1612 bNotify = m_pToolbarManager->destroyToolbar( aName ); 1613 bMustBeLayouted = m_pToolbarManager->isLayoutDirty(); 1614 } 1615 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) 1616 { 1617 uno::Reference< frame::XFrame > xFrame( m_xFrame ); 1618 uno::Reference< lang::XMultiServiceFactory > xSMGR( m_xSMGR ); 1619 aWriteLock.unlock(); 1620 1621 impl_setDockingWindowVisibility( xSMGR, xFrame, aElementName, false ); 1622 bMustBeLayouted = false; 1623 bNotify = false; 1624 } 1625 aWriteLock.unlock(); 1626 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 1627 1628 if ( bMustBeDestroyed ) 1629 { 1630 if ( xComponent.is() ) 1631 xComponent->dispose(); 1632 bNotify = true; 1633 } 1634 1635 if ( bMustBeLayouted ) 1636 doLayout(); 1637 1638 if ( bNotify ) 1639 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_INVISIBLE, uno::makeAny( aName ) ); 1640 } 1641 1642 ::sal_Bool SAL_CALL LayoutManager::requestElement( const ::rtl::OUString& rResourceURL ) 1643 { 1644 bool bResult( false ); 1645 bool bNotify( false ); 1646 bool bDoLayout( false ); 1647 ::rtl::OUString aElementType; 1648 ::rtl::OUString aElementName; 1649 1650 parseResourceURL( rResourceURL, aElementType, aElementName ); 1651 1652 WriteGuard aWriteLock( m_aLock ); 1653 1654 ::rtl::OString aResName = rtl::OUStringToOString( aElementName, RTL_TEXTENCODING_ASCII_US ); 1655 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "framework (cd100003) Element %s requested.", aResName.getStr() ); 1656 1657 if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) || ( m_aStatusBarElement.m_aName == rResourceURL )) 1658 { 1659 implts_readStatusBarState( rResourceURL ); 1660 if ( m_aStatusBarElement.m_bVisible && !m_aStatusBarElement.m_bMasterHide ) 1661 { 1662 aWriteLock.unlock(); 1663 createElement( rResourceURL ); 1664 1665 // There are some situation where we are not able to create an element. 1666 // Therefore we have to check the reference before further action. 1667 // See #i70019# 1668 uno::Reference< ui::XUIElement > xUIElement( m_aStatusBarElement.m_xUIElement ); 1669 if ( xUIElement.is() ) 1670 { 1671 // we need VCL here to pass special flags to Show() 1672 vos::OGuard aGuard( Application::GetSolarMutex() ); 1673 Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), UNO_QUERY ); 1674 Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); 1675 if ( pWindow ) 1676 { 1677 pWindow->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE ); 1678 bResult = true; 1679 bNotify = true; 1680 bDoLayout = true; 1681 } 1682 } 1683 } 1684 } 1685 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" ) ) 1686 { 1687 aWriteLock.unlock(); 1688 implts_showProgressBar(); 1689 bResult = true; 1690 bNotify = true; 1691 bDoLayout = true; 1692 } 1693 else if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR ) && m_bVisible ) 1694 { 1695 bool bComponentAttached( m_aModuleIdentifier.getLength() > 0 ); 1696 uno::Reference< uno::XInterface > xThis( m_xToolbarManager, uno::UNO_QUERY ); 1697 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 1698 aWriteLock.unlock(); 1699 1700 if ( pToolbarManager && bComponentAttached ) 1701 { 1702 bNotify = pToolbarManager->requestToolbar( rResourceURL ); 1703 bDoLayout = true; 1704 } 1705 } 1706 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) 1707 { 1708 uno::Reference< frame::XFrame > xFrame( m_xFrame ); 1709 aWriteLock.unlock(); 1710 1711 CreateDockingWindow( xFrame, aElementName ); 1712 } 1713 1714 if ( bNotify ) 1715 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( rResourceURL ) ); 1716 1717 return bResult; 1718 } 1719 1720 Reference< XUIElement > SAL_CALL LayoutManager::getElement( const ::rtl::OUString& aName ) 1721 { 1722 Reference< XUIElement > xUIElement = implts_findElement( aName ); 1723 if ( !xUIElement.is() ) 1724 { 1725 ReadGuard aReadLock( m_aLock ); 1726 uno::Reference< uno::XInterface > xThis( m_xToolbarManager ); 1727 ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); 1728 aReadLock.unlock(); 1729 1730 if ( pToolbarManager ) 1731 xUIElement = pToolbarManager->getToolbar( aName ); 1732 } 1733 1734 return xUIElement; 1735 } 1736 1737 Sequence< Reference< ui::XUIElement > > SAL_CALL LayoutManager::getElements() 1738 { 1739 ReadGuard aReadLock( m_aLock ); 1740 uno::Reference< ui::XUIElement > xMenuBar( m_xMenuBar ); 1741 uno::Reference< ui::XUIElement > xStatusBar( m_aStatusBarElement.m_xUIElement ); 1742 uno::Reference< uno::XInterface > xThis( m_xToolbarManager ); 1743 ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); 1744 aReadLock.unlock(); 1745 1746 Sequence< Reference< ui::XUIElement > > aSeq; 1747 if ( pToolbarManager ) 1748 aSeq = pToolbarManager->getToolbars(); 1749 1750 sal_Int32 nSize = aSeq.getLength(); 1751 sal_Int32 nMenuBarIndex(-1); 1752 sal_Int32 nStatusBarIndex(-1); 1753 if ( xMenuBar.is() ) 1754 { 1755 nMenuBarIndex = nSize; 1756 ++nSize; 1757 } 1758 if ( xStatusBar.is() ) 1759 { 1760 nStatusBarIndex = nSize; 1761 ++nSize; 1762 } 1763 1764 aSeq.realloc(nSize); 1765 if ( nMenuBarIndex >= 0 ) 1766 aSeq[nMenuBarIndex] = xMenuBar; 1767 if ( nStatusBarIndex >= 0 ) 1768 aSeq[nStatusBarIndex] = xStatusBar; 1769 1770 return aSeq; 1771 } 1772 1773 sal_Bool SAL_CALL LayoutManager::showElement( const ::rtl::OUString& aName ) 1774 { 1775 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::showElement" ); 1776 1777 bool bResult( false ); 1778 bool bNotify( false ); 1779 bool bMustLayout( false ); 1780 ::rtl::OUString aElementType; 1781 ::rtl::OUString aElementName; 1782 1783 parseResourceURL( aName, aElementType, aElementName ); 1784 1785 ::rtl::OString aResName = rtl::OUStringToOString( aElementName, RTL_TEXTENCODING_ASCII_US ); 1786 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "framework (cd100003) Element %s", aResName.getStr() ); 1787 1788 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "menubar" )) 1789 { 1790 WriteGuard aWriteLock( m_aLock ); 1791 m_bMenuVisible = sal_True; 1792 aWriteLock.unlock(); 1793 1794 bResult = implts_resetMenuBar(); 1795 bNotify = bResult; 1796 } 1797 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) || ( m_aStatusBarElement.m_aName == aName )) 1798 { 1799 WriteGuard aWriteLock( m_aLock ); 1800 if ( m_aStatusBarElement.m_xUIElement.is() && !m_aStatusBarElement.m_bMasterHide && 1801 implts_showStatusBar( sal_True )) 1802 { 1803 aWriteLock.unlock(); 1804 1805 implts_writeWindowStateData( m_aStatusBarAlias, m_aStatusBarElement ); 1806 bMustLayout = true; 1807 bResult = true; 1808 bNotify = true; 1809 } 1810 } 1811 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" )) 1812 { 1813 bNotify = bResult = implts_showProgressBar(); 1814 } 1815 else if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 1816 { 1817 ReadGuard aReadLock( m_aLock ); 1818 uno::Reference< awt::XWindowListener > xToolbarManager( m_xToolbarManager, uno::UNO_QUERY ); 1819 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 1820 aReadLock.unlock(); 1821 1822 if ( pToolbarManager ) 1823 { 1824 bNotify = pToolbarManager->showToolbar( aName ); 1825 bMustLayout = pToolbarManager->isLayoutDirty(); 1826 } 1827 } 1828 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) 1829 { 1830 ReadGuard aReadGuard( m_aLock ); 1831 uno::Reference< frame::XFrame > xFrame( m_xFrame ); 1832 uno::Reference< lang::XMultiServiceFactory > xSMGR( m_xSMGR ); 1833 aReadGuard.unlock(); 1834 1835 impl_setDockingWindowVisibility( xSMGR, xFrame, aElementName, true ); 1836 } 1837 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolpanel" )) 1838 { 1839 ReadGuard aReadGuard( m_aLock ); 1840 uno::Reference< frame::XFrame > xFrame( m_xFrame ); 1841 aReadGuard.unlock(); 1842 ActivateToolPanel( m_xFrame, aName ); 1843 } 1844 1845 if ( bMustLayout ) 1846 doLayout(); 1847 1848 if ( bNotify ) 1849 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( aName ) ); 1850 1851 return bResult; 1852 } 1853 1854 sal_Bool SAL_CALL LayoutManager::hideElement( const ::rtl::OUString& aName ) 1855 { 1856 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::hideElement" ); 1857 1858 bool bResult( false ); 1859 bool bNotify( false ); 1860 bool bMustLayout( false ); 1861 ::rtl::OUString aElementType; 1862 ::rtl::OUString aElementName; 1863 1864 parseResourceURL( aName, aElementType, aElementName ); 1865 ::rtl::OString aResName = rtl::OUStringToOString( aElementName, RTL_TEXTENCODING_ASCII_US ); 1866 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "framework (cd100003) Element %s", aResName.getStr() ); 1867 1868 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "menubar" )) 1869 { 1870 WriteGuard aWriteLock( m_aLock ); 1871 1872 if ( m_xContainerWindow.is() ) 1873 { 1874 m_bMenuVisible = sal_False; 1875 1876 vos::OGuard aGuard( Application::GetSolarMutex() ); 1877 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow ); 1878 if ( pSysWindow ) 1879 { 1880 MenuBar* pMenuBar = pSysWindow->GetMenuBar(); 1881 if ( pMenuBar ) 1882 { 1883 pMenuBar->SetDisplayable( sal_False ); 1884 bResult = true; 1885 bNotify = true; 1886 } 1887 } 1888 } 1889 } 1890 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) || ( m_aStatusBarElement.m_aName == aName )) 1891 { 1892 WriteGuard aWriteLock( m_aLock ); 1893 if ( m_aStatusBarElement.m_xUIElement.is() && !m_aStatusBarElement.m_bMasterHide && 1894 implts_hideStatusBar( sal_True )) 1895 { 1896 implts_writeWindowStateData( m_aStatusBarAlias, m_aStatusBarElement ); 1897 bMustLayout = sal_True; 1898 bNotify = sal_True; 1899 bResult = sal_True; 1900 } 1901 } 1902 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" )) 1903 { 1904 bResult = bNotify = implts_hideProgressBar(); 1905 } 1906 else if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 1907 { 1908 ReadGuard aReadLock( m_aLock ); 1909 uno::Reference< uno::XInterface > xToolbarManager( m_xToolbarManager, uno::UNO_QUERY ); 1910 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 1911 aReadLock.unlock(); 1912 1913 bNotify = pToolbarManager->hideToolbar( aName ); 1914 bMustLayout = pToolbarManager->isLayoutDirty(); 1915 } 1916 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) 1917 { 1918 ReadGuard aReadGuard( m_aLock ); 1919 uno::Reference< frame::XFrame > xFrame( m_xFrame ); 1920 uno::Reference< lang::XMultiServiceFactory > xSMGR( m_xSMGR ); 1921 aReadGuard.unlock(); 1922 1923 impl_setDockingWindowVisibility( xSMGR, xFrame, aElementName, false ); 1924 } 1925 1926 if ( bMustLayout ) 1927 doLayout(); 1928 1929 if ( bNotify ) 1930 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_INVISIBLE, uno::makeAny( aName ) ); 1931 1932 return sal_False; 1933 } 1934 1935 sal_Bool SAL_CALL LayoutManager::dockWindow( const ::rtl::OUString& aName, DockingArea DockingArea, const awt::Point& Pos ) 1936 { 1937 ::rtl::OUString aElementType; 1938 ::rtl::OUString aElementName; 1939 1940 parseResourceURL( aName, aElementType, aElementName ); 1941 if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 1942 { 1943 ReadGuard aReadLock( m_aLock ); 1944 uno::Reference< uno::XInterface > xThis( m_xToolbarManager ); 1945 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 1946 aReadLock.unlock(); 1947 1948 if ( pToolbarManager ) 1949 { 1950 pToolbarManager->dockToolbar( aName, DockingArea, Pos ); 1951 if ( pToolbarManager->isLayoutDirty() ) 1952 doLayout(); 1953 } 1954 } 1955 return sal_False; 1956 } 1957 1958 ::sal_Bool SAL_CALL LayoutManager::dockAllWindows( ::sal_Int16 /*nElementType*/ ) 1959 { 1960 ReadGuard aReadLock( m_aLock ); 1961 bool bResult( false ); 1962 uno::Reference< uno::XInterface > xThis( m_xToolbarManager ); 1963 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 1964 aReadLock.unlock(); 1965 1966 if ( pToolbarManager ) 1967 { 1968 bResult = pToolbarManager->dockAllToolbars(); 1969 if ( pToolbarManager->isLayoutDirty() ) 1970 doLayout(); 1971 } 1972 return bResult; 1973 } 1974 1975 sal_Bool SAL_CALL LayoutManager::floatWindow( const ::rtl::OUString& aName ) 1976 { 1977 bool bResult( false ); 1978 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 1979 { 1980 ReadGuard aReadLock( m_aLock ); 1981 uno::Reference< uno::XInterface > xThis( m_xToolbarManager ); 1982 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 1983 aReadLock.unlock(); 1984 1985 if ( pToolbarManager ) 1986 { 1987 bResult = pToolbarManager->floatToolbar( aName ); 1988 if ( pToolbarManager->isLayoutDirty() ) 1989 doLayout(); 1990 } 1991 } 1992 return bResult; 1993 } 1994 1995 ::sal_Bool SAL_CALL LayoutManager::lockWindow( const ::rtl::OUString& aName ) 1996 { 1997 bool bResult( false ); 1998 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 1999 { 2000 ReadGuard aReadLock( m_aLock ); 2001 uno::Reference< uno::XInterface > xThis( m_xToolbarManager ); 2002 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 2003 aReadLock.unlock(); 2004 2005 if ( pToolbarManager ) 2006 { 2007 bResult = pToolbarManager->lockToolbar( aName ); 2008 if ( pToolbarManager->isLayoutDirty() ) 2009 doLayout(); 2010 } 2011 } 2012 return bResult; 2013 } 2014 2015 ::sal_Bool SAL_CALL LayoutManager::unlockWindow( const ::rtl::OUString& aName ) 2016 { 2017 bool bResult( false ); 2018 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 2019 { 2020 ReadGuard aReadLock( m_aLock ); 2021 uno::Reference< uno::XInterface > xThis( m_xToolbarManager ); 2022 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 2023 aReadLock.unlock(); 2024 2025 if ( pToolbarManager ) 2026 { 2027 bResult = pToolbarManager->unlockToolbar( aName ); 2028 if ( pToolbarManager->isLayoutDirty() ) 2029 doLayout(); 2030 } 2031 } 2032 return bResult; 2033 } 2034 2035 void SAL_CALL LayoutManager::setElementSize( const ::rtl::OUString& aName, const awt::Size& aSize ) 2036 { 2037 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 2038 { 2039 ReadGuard aReadLock( m_aLock ); 2040 uno::Reference< uno::XInterface > xThis( m_xToolbarManager ); 2041 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 2042 aReadLock.unlock(); 2043 2044 if ( pToolbarManager ) 2045 { 2046 pToolbarManager->setToolbarSize( aName, aSize ); 2047 if ( pToolbarManager->isLayoutDirty() ) 2048 doLayout(); 2049 } 2050 } 2051 } 2052 2053 void SAL_CALL LayoutManager::setElementPos( const ::rtl::OUString& aName, const awt::Point& aPos ) 2054 { 2055 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 2056 { 2057 ReadGuard aReadLock( m_aLock ); 2058 uno::Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); 2059 ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); 2060 aReadLock.unlock(); 2061 2062 if ( pToolbarManager ) 2063 { 2064 pToolbarManager->setToolbarPos( aName, aPos ); 2065 if ( pToolbarManager->isLayoutDirty() ) 2066 doLayout(); 2067 } 2068 } 2069 } 2070 2071 void SAL_CALL LayoutManager::setElementPosSize( const ::rtl::OUString& aName, const awt::Point& aPos, const awt::Size& aSize ) 2072 { 2073 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 2074 { 2075 ReadGuard aReadLock( m_aLock ); 2076 uno::Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); 2077 ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); 2078 aReadLock.unlock(); 2079 2080 if ( pToolbarManager ) 2081 { 2082 pToolbarManager->setToolbarPosSize( aName, aPos, aSize ); 2083 if ( pToolbarManager->isLayoutDirty() ) 2084 doLayout(); 2085 } 2086 } 2087 } 2088 2089 sal_Bool SAL_CALL LayoutManager::isElementVisible( const ::rtl::OUString& aName ) 2090 { 2091 ::rtl::OUString aElementType; 2092 ::rtl::OUString aElementName; 2093 2094 parseResourceURL( aName, aElementType, aElementName ); 2095 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "menubar" )) 2096 { 2097 ReadGuard aReadLock( m_aLock ); 2098 if ( m_xContainerWindow.is() ) 2099 { 2100 aReadLock.unlock(); 2101 2102 vos::OGuard aGuard( Application::GetSolarMutex() ); 2103 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow ); 2104 if ( pSysWindow ) 2105 { 2106 MenuBar* pMenuBar = pSysWindow->GetMenuBar(); 2107 if ( pMenuBar && pMenuBar->IsDisplayable() ) 2108 return sal_True; 2109 } 2110 else 2111 { 2112 aReadLock.lock(); 2113 return m_bMenuVisible; 2114 } 2115 } 2116 } 2117 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) || ( m_aStatusBarElement.m_aName == aName )) 2118 { 2119 if ( m_aStatusBarElement.m_xUIElement.is() ) 2120 { 2121 Reference< awt::XWindow > xWindow( m_aStatusBarElement.m_xUIElement->getRealInterface(), UNO_QUERY ); 2122 if ( xWindow.is() ) 2123 { 2124 Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); 2125 if ( pWindow && pWindow->IsVisible() ) 2126 return sal_True; 2127 else 2128 return sal_False; 2129 } 2130 } 2131 } 2132 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" ))) 2133 { 2134 if ( m_aProgressBarElement.m_xUIElement.is() ) 2135 return m_aProgressBarElement.m_bVisible; 2136 } 2137 else if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 2138 { 2139 ReadGuard aReadLock( m_aLock ); 2140 uno::Reference< frame::XLayoutManager > xToolbarManager( m_xToolbarManager, uno::UNO_QUERY ); 2141 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 2142 aReadLock.unlock(); 2143 2144 if ( pToolbarManager ) 2145 return pToolbarManager->isToolbarVisible( aName ); 2146 } 2147 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" )) 2148 { 2149 ReadGuard aReadGuard( m_aLock ); 2150 uno::Reference< frame::XFrame > xFrame( m_xFrame ); 2151 aReadGuard.unlock(); 2152 2153 return IsDockingWindowVisible( xFrame, aElementName ); 2154 } 2155 2156 return sal_False; 2157 } 2158 2159 sal_Bool SAL_CALL LayoutManager::isElementFloating( const ::rtl::OUString& aName ) 2160 { 2161 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 2162 { 2163 ReadGuard aReadLock( m_aLock ); 2164 uno::Reference< uno::XInterface > xToolbarManager( m_xToolbarManager, uno::UNO_QUERY ); 2165 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 2166 aReadLock.unlock(); 2167 2168 if ( pToolbarManager ) 2169 return pToolbarManager->isToolbarFloating( aName ); 2170 } 2171 2172 return sal_False; 2173 } 2174 2175 sal_Bool SAL_CALL LayoutManager::isElementDocked( const ::rtl::OUString& aName ) 2176 { 2177 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 2178 { 2179 ReadGuard aReadLock( m_aLock ); 2180 uno::Reference< uno::XInterface > xToolbarManager( m_xToolbarManager, uno::UNO_QUERY ); 2181 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 2182 aReadLock.unlock(); 2183 2184 if ( pToolbarManager ) 2185 return pToolbarManager->isToolbarDocked( aName ); 2186 } 2187 2188 return sal_False; 2189 } 2190 2191 ::sal_Bool SAL_CALL LayoutManager::isElementLocked( const ::rtl::OUString& aName ) 2192 { 2193 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 2194 { 2195 ReadGuard aReadLock( m_aLock ); 2196 uno::Reference< uno::XInterface > xToolbarManager( m_xToolbarManager, uno::UNO_QUERY ); 2197 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 2198 aReadLock.unlock(); 2199 2200 if ( pToolbarManager ) 2201 return pToolbarManager->isToolbarLocked( aName ); 2202 } 2203 2204 return sal_False; 2205 } 2206 2207 awt::Size SAL_CALL LayoutManager::getElementSize( const ::rtl::OUString& aName ) 2208 { 2209 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 2210 { 2211 ReadGuard aReadLock( m_aLock ); 2212 uno::Reference< uno::XInterface > xToolbarManager( m_xToolbarManager, uno::UNO_QUERY ); 2213 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 2214 aReadLock.unlock(); 2215 2216 if ( pToolbarManager ) 2217 return pToolbarManager->getToolbarSize( aName ); 2218 } 2219 2220 return awt::Size(); 2221 } 2222 2223 awt::Point SAL_CALL LayoutManager::getElementPos( const ::rtl::OUString& aName ) 2224 { 2225 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 2226 { 2227 ReadGuard aReadLock( m_aLock ); 2228 uno::Reference< uno::XInterface > xToolbarManager( m_xToolbarManager, uno::UNO_QUERY ); 2229 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 2230 aReadLock.unlock(); 2231 2232 if ( pToolbarManager ) 2233 return pToolbarManager->getToolbarPos( aName ); 2234 } 2235 2236 return awt::Point(); 2237 } 2238 2239 void SAL_CALL LayoutManager::lock() 2240 { 2241 implts_lock(); 2242 2243 ReadGuard aReadLock( m_aLock ); 2244 sal_Int32 nLockCount( m_nLockCount ); 2245 aReadLock.unlock(); 2246 2247 RTL_LOGFILE_TRACE1( "framework (cd100003) ::LayoutManager::lock lockCount=%d", nLockCount ); 2248 #ifdef DBG_UTIL 2249 ByteString aStr("LayoutManager::lock "); 2250 aStr += ByteString::CreateFromInt32((long)this); 2251 aStr += " - "; 2252 aStr += ByteString::CreateFromInt32(nLockCount); 2253 DBG_TRACE( aStr.GetBuffer() ); 2254 #endif 2255 2256 Any a( nLockCount ); 2257 implts_notifyListeners( frame::LayoutManagerEvents::LOCK, a ); 2258 } 2259 2260 void SAL_CALL LayoutManager::unlock() 2261 { 2262 sal_Bool bDoLayout( implts_unlock() ); 2263 2264 ReadGuard aReadLock( m_aLock ); 2265 sal_Int32 nLockCount( m_nLockCount ); 2266 aReadLock.unlock(); 2267 2268 RTL_LOGFILE_TRACE1( "framework (cd100003) ::LayoutManager::unlock lockCount=%d", nLockCount ); 2269 #ifdef DBG_UTIL 2270 ByteString aStr("LayoutManager::unlock "); 2271 aStr += ByteString::CreateFromInt32((long)this); 2272 aStr += " - "; 2273 aStr += ByteString::CreateFromInt32(nLockCount); 2274 DBG_TRACE( aStr.GetBuffer() ); 2275 #endif 2276 // conform to documentation: unlock with lock count == 0 means force a layout 2277 2278 WriteGuard aWriteLock( m_aLock ); 2279 if ( bDoLayout ) 2280 m_aAsyncLayoutTimer.Stop(); 2281 aWriteLock.unlock(); 2282 2283 Any a( nLockCount ); 2284 implts_notifyListeners( frame::LayoutManagerEvents::UNLOCK, a ); 2285 2286 if ( bDoLayout ) 2287 implts_doLayout_notify( sal_True ); 2288 } 2289 2290 void SAL_CALL LayoutManager::doLayout() 2291 { 2292 implts_doLayout_notify( sal_True ); 2293 } 2294 2295 //--------------------------------------------------------------------------------------------------------- 2296 // ILayoutNotifications 2297 //--------------------------------------------------------------------------------------------------------- 2298 void LayoutManager::requestLayout( Hint eHint ) 2299 { 2300 if ( eHint == HINT_TOOLBARSPACE_HAS_CHANGED ) 2301 doLayout(); 2302 } 2303 2304 void LayoutManager::implts_doLayout_notify( sal_Bool bOuterResize ) 2305 { 2306 bool bLayouted = implts_doLayout( false, bOuterResize ); 2307 if ( bLayouted ) 2308 implts_notifyListeners( frame::LayoutManagerEvents::LAYOUT, Any() ); 2309 } 2310 2311 sal_Bool LayoutManager::implts_doLayout( sal_Bool bForceRequestBorderSpace, sal_Bool bOuterResize ) 2312 { 2313 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::implts_doLayout" ); 2314 2315 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 2316 ReadGuard aReadLock( m_aLock ); 2317 2318 if ( !m_xFrame.is() || !m_bParentWindowVisible ) 2319 return sal_False; 2320 2321 bool bPreserveContentSize( m_bPreserveContentSize ); 2322 bool bMustDoLayout( m_bMustDoLayout ); 2323 bool bNoLock = ( m_nLockCount == 0 ); 2324 awt::Rectangle aCurrBorderSpace( m_aDockingArea ); 2325 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 2326 Reference< awt::XTopWindow2 > xContainerTopWindow( m_xContainerTopWindow ); 2327 Reference< awt::XWindow > xComponentWindow( m_xFrame->getComponentWindow() ); 2328 Reference< XDockingAreaAcceptor > xDockingAreaAcceptor( m_xDockingAreaAcceptor ); 2329 aReadLock.unlock(); 2330 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 2331 2332 sal_Bool bLayouted( sal_False ); 2333 2334 if ( bNoLock && xDockingAreaAcceptor.is() && xContainerWindow.is() && xComponentWindow.is() ) 2335 { 2336 bLayouted = sal_True; 2337 2338 WriteGuard aWriteGuard( m_aLock ); 2339 m_bDoLayout = sal_True; 2340 aWriteGuard.unlock(); 2341 2342 awt::Rectangle aDockSpace( implts_calcDockingAreaSizes() ); 2343 awt::Rectangle aBorderSpace( aDockSpace ); 2344 sal_Bool bGotRequestedBorderSpace( sal_True ); 2345 2346 // We have to add the height of a possible status bar 2347 aBorderSpace.Height += implts_getStatusBarSize().Height(); 2348 2349 if ( !equalRectangles( aBorderSpace, aCurrBorderSpace ) || bForceRequestBorderSpace || bMustDoLayout ) 2350 { 2351 // we always resize the content window (instead of the complete container window) if we're not set up 2352 // to (attempt to) preserve the content window's size 2353 if ( bOuterResize && !bPreserveContentSize ) 2354 bOuterResize = sal_False; 2355 2356 // maximized windows can resized their content window only, not their container window 2357 if ( bOuterResize && xContainerTopWindow.is() && xContainerTopWindow->getIsMaximized() ) 2358 bOuterResize = sal_False; 2359 2360 // if the component window does not have a size (yet), then we can't use it to calc the container 2361 // window size 2362 awt::Rectangle aComponentRect = xComponentWindow->getPosSize(); 2363 if ( bOuterResize && ( aComponentRect.Width == 0 ) && ( aComponentRect.Height == 0 ) ) 2364 bOuterResize = sal_False; 2365 2366 bGotRequestedBorderSpace = sal_False; 2367 if ( bOuterResize ) 2368 { 2369 Reference< awt::XDevice > xDevice( xContainerWindow, uno::UNO_QUERY ); 2370 awt::DeviceInfo aContainerInfo = xDevice->getInfo(); 2371 2372 awt::Size aRequestedSize( aComponentRect.Width + aContainerInfo.LeftInset + aContainerInfo.RightInset + aBorderSpace.X + aBorderSpace.Width, 2373 aComponentRect.Height + aContainerInfo.TopInset + aContainerInfo.BottomInset + aBorderSpace.Y + aBorderSpace.Height ); 2374 awt::Point aComponentPos( aBorderSpace.X, aBorderSpace.Y ); 2375 2376 bGotRequestedBorderSpace = implts_resizeContainerWindow( aRequestedSize, aComponentPos ); 2377 } 2378 2379 // if we did not do an container window resize, or it failed, then use the DockingAcceptor as usual 2380 if ( !bGotRequestedBorderSpace ) 2381 bGotRequestedBorderSpace = xDockingAreaAcceptor->requestDockingAreaSpace( aBorderSpace ); 2382 2383 if ( bGotRequestedBorderSpace ) 2384 { 2385 aWriteGuard.lock(); 2386 m_aDockingArea = aBorderSpace; 2387 m_bMustDoLayout = sal_False; 2388 aWriteGuard.unlock(); 2389 } 2390 } 2391 2392 if ( bGotRequestedBorderSpace ) 2393 { 2394 ::Size aContainerSize; 2395 ::Size aStatusBarSize; 2396 2397 // Interim solution to let the layout method within the 2398 // toolbar layout manager. 2399 implts_setOffset( implts_getStatusBarSize().Height() ); 2400 m_pToolbarManager->setDockingArea( aDockSpace ); 2401 2402 // Subtract status bar size from our container output size. Docking area windows 2403 // don't contain the status bar! 2404 aStatusBarSize = implts_getStatusBarSize(); 2405 aContainerSize = implts_getContainerWindowOutputSize(); 2406 aContainerSize.Height() -= aStatusBarSize.Height(); 2407 2408 m_pToolbarManager->doLayout(aContainerSize); 2409 2410 // Position the status bar 2411 if ( aStatusBarSize.Height() > 0 ) 2412 { 2413 implts_setStatusBarPosSize( ::Point( 0, std::max(( aContainerSize.Height() ), long( 0 ))), 2414 ::Size( aContainerSize.Width(),aStatusBarSize.Height() )); 2415 } 2416 2417 xDockingAreaAcceptor->setDockingAreaSpace( aBorderSpace ); 2418 2419 aWriteGuard.lock(); 2420 m_bDoLayout = sal_False; 2421 aWriteGuard.unlock(); 2422 } 2423 } 2424 2425 return bLayouted; 2426 } 2427 2428 sal_Bool LayoutManager::implts_resizeContainerWindow( const awt::Size& rContainerSize, 2429 const awt::Point& rComponentPos ) 2430 { 2431 ReadGuard aReadLock( m_aLock ); 2432 Reference< awt::XWindow > xContainerWindow = m_xContainerWindow; 2433 Reference< awt::XTopWindow2 > xContainerTopWindow = m_xContainerTopWindow; 2434 Reference< awt::XWindow > xComponentWindow = m_xFrame->getComponentWindow(); 2435 Reference< container::XIndexAccess > xDisplayAccess = m_xDisplayAccess; 2436 aReadLock.unlock(); 2437 2438 // calculate the maximum size we have for the container window 2439 awt::Rectangle aWorkArea; 2440 try 2441 { 2442 sal_Int32 nDisplay = xContainerTopWindow->getDisplay(); 2443 Reference< beans::XPropertySet > xDisplayInfo( xDisplayAccess->getByIndex( nDisplay ), UNO_QUERY_THROW ); 2444 OSL_VERIFY( xDisplayInfo->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WorkArea" ) ) ) >>= aWorkArea ); 2445 } 2446 catch( const Exception& ) 2447 { 2448 DBG_UNHANDLED_EXCEPTION(); 2449 } 2450 2451 if (( aWorkArea.Width > 0 ) && ( aWorkArea.Height > 0 )) 2452 { 2453 if (( rContainerSize.Width > aWorkArea.Width ) || ( rContainerSize.Height > aWorkArea.Height )) 2454 return sal_False; 2455 // Strictly, this is not correct. If we have a multi-screen display (css.awt.DisplayAccess.MultiDisplay == true), 2456 // the "effective work area" would be much larger than the work area of a single display, since we could in theory 2457 // position the container window across multiple screens. 2458 // However, this should suffice as a heuristics here ... (nobody really wants to check whether the different screens are 2459 // stacked horizontally or vertically, whether their work areas can really be combined, or are separated by non-work-areas, 2460 // and the like ... right?) 2461 } 2462 2463 // resize our container window 2464 xContainerWindow->setPosSize( 0, 0, rContainerSize.Width, rContainerSize.Height, awt::PosSize::SIZE ); 2465 // position the component window 2466 xComponentWindow->setPosSize( rComponentPos.X, rComponentPos.Y, 0, 0, awt::PosSize::POS ); 2467 return sal_True; 2468 } 2469 2470 void SAL_CALL LayoutManager::setVisible( sal_Bool bVisible ) 2471 { 2472 WriteGuard aWriteLock( m_aLock ); 2473 sal_Bool bWasVisible( m_bVisible ); 2474 m_bVisible = bVisible; 2475 aWriteLock.unlock(); 2476 2477 if ( bWasVisible != bVisible ) 2478 implts_setVisibleState( bVisible ); 2479 } 2480 2481 sal_Bool SAL_CALL LayoutManager::isVisible() 2482 { 2483 ReadGuard aReadLock( m_aLock ); 2484 return m_bVisible; 2485 } 2486 2487 ::Size LayoutManager::implts_getStatusBarSize() 2488 { 2489 ReadGuard aReadLock( m_aLock ); 2490 bool bStatusBarVisible( isElementVisible( m_aStatusBarAlias )); 2491 bool bProgressBarVisible( isElementVisible( m_aProgressBarAlias )); 2492 bool bVisible( m_bVisible ); 2493 Reference< XUIElement > xStatusBar( m_aStatusBarElement.m_xUIElement ); 2494 Reference< XUIElement > xProgressBar( m_aProgressBarElement.m_xUIElement ); 2495 2496 Reference< awt::XWindow > xWindow; 2497 if ( bStatusBarVisible && bVisible && xStatusBar.is() ) 2498 xWindow = Reference< awt::XWindow >( xStatusBar->getRealInterface(), UNO_QUERY ); 2499 else if ( xProgressBar.is() && !xStatusBar.is() && bProgressBarVisible ) 2500 { 2501 ProgressBarWrapper* pWrapper = (ProgressBarWrapper*)xProgressBar.get(); 2502 if ( pWrapper ) 2503 xWindow = pWrapper->getStatusBar(); 2504 } 2505 aReadLock.unlock(); 2506 2507 if ( xWindow.is() ) 2508 { 2509 awt::Rectangle aPosSize = xWindow->getPosSize(); 2510 return ::Size( aPosSize.Width, aPosSize.Height ); 2511 } 2512 else 2513 return ::Size(); 2514 } 2515 2516 awt::Rectangle LayoutManager::implts_calcDockingAreaSizes() 2517 { 2518 ReadGuard aReadLock( m_aLock ); 2519 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 2520 Reference< XDockingAreaAcceptor > xDockingAreaAcceptor( m_xDockingAreaAcceptor ); 2521 aReadLock.unlock(); 2522 2523 awt::Rectangle aBorderSpace; 2524 if ( xDockingAreaAcceptor.is() && xContainerWindow.is() ) 2525 aBorderSpace = m_pToolbarManager->getDockingArea(); 2526 2527 return aBorderSpace; 2528 } 2529 2530 void LayoutManager::implts_setDockingAreaWindowSizes( const awt::Rectangle& /*rBorderSpace*/ ) 2531 { 2532 ReadGuard aReadLock( m_aLock ); 2533 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 2534 aReadLock.unlock(); 2535 2536 uno::Reference< awt::XDevice > xDevice( xContainerWindow, uno::UNO_QUERY ); 2537 // Convert relativ size to output size. 2538 awt::Rectangle aRectangle = xContainerWindow->getPosSize(); 2539 awt::DeviceInfo aInfo = xDevice->getInfo(); 2540 awt::Size aContainerClientSize = awt::Size( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset, 2541 aRectangle.Height - aInfo.TopInset - aInfo.BottomInset ); 2542 ::Size aStatusBarSize = implts_getStatusBarSize(); 2543 2544 // Position the status bar 2545 if ( aStatusBarSize.Height() > 0 ) 2546 { 2547 implts_setStatusBarPosSize( ::Point( 0, std::max(( aContainerClientSize.Height - aStatusBarSize.Height() ), long( 0 ))), 2548 ::Size( aContainerClientSize.Width, aStatusBarSize.Height() )); 2549 } 2550 } 2551 2552 //--------------------------------------------------------------------------------------------------------- 2553 // XMenuCloser 2554 //--------------------------------------------------------------------------------------------------------- 2555 void LayoutManager::implts_updateMenuBarClose() 2556 { 2557 WriteGuard aWriteLock( m_aLock ); 2558 bool bShowCloser( m_bMenuBarCloser ); 2559 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 2560 aWriteLock.unlock(); 2561 2562 if ( xContainerWindow.is() ) 2563 { 2564 vos::OGuard aGuard( Application::GetSolarMutex() ); 2565 2566 SystemWindow* pSysWindow = getTopSystemWindow( xContainerWindow ); 2567 if ( pSysWindow ) 2568 { 2569 MenuBar* pMenuBar = pSysWindow->GetMenuBar(); 2570 if ( pMenuBar ) 2571 { 2572 // TODO remove link on sal_False ?! 2573 pMenuBar->ShowCloser( bShowCloser ); 2574 pMenuBar->SetCloserHdl( LINK( this, LayoutManager, MenuBarClose )); 2575 } 2576 } 2577 } 2578 } 2579 2580 sal_Bool LayoutManager::implts_resetMenuBar() 2581 { 2582 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 2583 WriteGuard aWriteLock( m_aLock ); 2584 sal_Bool bMenuVisible( m_bMenuVisible ); 2585 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 2586 2587 MenuBar* pSetMenuBar = 0; 2588 if ( m_xInplaceMenuBar.is() ) 2589 pSetMenuBar = (MenuBar *)m_pInplaceMenuBar->GetMenuBar(); 2590 else 2591 { 2592 MenuBarWrapper* pMenuBarWrapper = static_cast< MenuBarWrapper* >( m_xMenuBar.get() ); 2593 if ( pMenuBarWrapper ) 2594 pSetMenuBar = (MenuBar *)pMenuBarWrapper->GetMenuBarManager()->GetMenuBar(); 2595 } 2596 aWriteLock.unlock(); 2597 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 2598 2599 vos::OGuard aGuard( Application::GetSolarMutex() ); 2600 SystemWindow* pSysWindow = getTopSystemWindow( xContainerWindow ); 2601 if ( pSysWindow && bMenuVisible && pSetMenuBar ) 2602 { 2603 pSysWindow->SetMenuBar( pSetMenuBar ); 2604 pSetMenuBar->SetDisplayable( sal_True ); 2605 return sal_True; 2606 } 2607 2608 return sal_False; 2609 } 2610 2611 void LayoutManager::implts_setMenuBarCloser(sal_Bool bCloserState) 2612 { 2613 WriteGuard aWriteLock( m_aLock ); 2614 m_bMenuBarCloser = bCloserState; 2615 aWriteLock.unlock(); 2616 2617 implts_updateMenuBarClose(); 2618 } 2619 2620 IMPL_LINK( LayoutManager, MenuBarClose, MenuBar *, EMPTYARG ) 2621 { 2622 ReadGuard aReadLock( m_aLock ); 2623 uno::Reference< frame::XDispatchProvider > xProvider(m_xFrame, uno::UNO_QUERY); 2624 uno::Reference< lang::XMultiServiceFactory > xSMGR = m_xSMGR; 2625 aReadLock.unlock(); 2626 2627 if ( !xProvider.is()) 2628 return 0; 2629 2630 uno::Reference< frame::XDispatchHelper > xDispatcher( 2631 xSMGR->createInstance(SERVICENAME_DISPATCHHELPER), uno::UNO_QUERY_THROW); 2632 2633 xDispatcher->executeDispatch( 2634 xProvider, 2635 ::rtl::OUString::createFromAscii(".uno:CloseWin"), 2636 ::rtl::OUString::createFromAscii("_self"), 2637 0, 2638 uno::Sequence< beans::PropertyValue >()); 2639 2640 return 0; 2641 } 2642 2643 IMPL_LINK( LayoutManager, SettingsChanged, void*, EMPTYARG ) 2644 { 2645 return 1; 2646 } 2647 2648 //--------------------------------------------------------------------------------------------------------- 2649 // XLayoutManagerEventBroadcaster 2650 //--------------------------------------------------------------------------------------------------------- 2651 void SAL_CALL LayoutManager::addLayoutManagerEventListener( const uno::Reference< frame::XLayoutManagerListener >& xListener ) 2652 { 2653 m_aListenerContainer.addInterface( ::getCppuType( (const uno::Reference< frame::XLayoutManagerListener >*)NULL ), xListener ); 2654 } 2655 2656 void SAL_CALL LayoutManager::removeLayoutManagerEventListener( const uno::Reference< frame::XLayoutManagerListener >& xListener ) 2657 { 2658 m_aListenerContainer.removeInterface( ::getCppuType( (const uno::Reference< frame::XLayoutManagerListener >*)NULL ), xListener ); 2659 } 2660 2661 void LayoutManager::implts_notifyListeners( short nEvent, uno::Any aInfoParam ) 2662 { 2663 lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>(this) ); 2664 ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const uno::Reference< frame::XLayoutManagerListener >*) NULL ) ); 2665 if (pContainer!=NULL) 2666 { 2667 ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); 2668 while (pIterator.hasMoreElements()) 2669 { 2670 try 2671 { 2672 ((frame::XLayoutManagerListener*)pIterator.next())->layoutEvent( aSource, nEvent, aInfoParam ); 2673 } 2674 catch( uno::RuntimeException& ) 2675 { 2676 pIterator.remove(); 2677 } 2678 } 2679 } 2680 } 2681 2682 //--------------------------------------------------------------------------------------------------------- 2683 // XWindowListener 2684 //--------------------------------------------------------------------------------------------------------- 2685 void SAL_CALL LayoutManager::windowResized( const awt::WindowEvent& aEvent ) 2686 { 2687 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 2688 WriteGuard aWriteLock( m_aLock ); 2689 2690 if ( !m_xDockingAreaAcceptor.is() ) 2691 return; 2692 2693 // Request to set docking area space again. 2694 awt::Rectangle aDockingArea( m_aDockingArea ); 2695 Reference< XDockingAreaAcceptor > xDockingAreaAcceptor( m_xDockingAreaAcceptor ); 2696 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 2697 2698 Reference< XInterface > xIfac( xContainerWindow, UNO_QUERY ); 2699 if ( xIfac == aEvent.Source && m_bVisible ) 2700 { 2701 // We have to call our resize handler at least once synchronously, as some 2702 // application modules need this. So we have to check if this is the first 2703 // call after the async layout time expired. 2704 m_bMustDoLayout = sal_True; 2705 if ( !m_aAsyncLayoutTimer.IsActive() ) 2706 { 2707 const Link& aLink = m_aAsyncLayoutTimer.GetTimeoutHdl(); 2708 if ( aLink.IsSet() ) 2709 aLink.Call( &m_aAsyncLayoutTimer ); 2710 } 2711 if ( m_nLockCount == 0 ) 2712 m_aAsyncLayoutTimer.Start(); 2713 } 2714 else if ( m_xFrame.is() && aEvent.Source == m_xFrame->getContainerWindow() ) 2715 { 2716 // the container window of my DockingAreaAcceptor is not the same as of my frame 2717 // I still have to resize my frames' window as nobody else will do it 2718 Reference< awt::XWindow > xComponentWindow( m_xFrame->getComponentWindow() ); 2719 if( xComponentWindow.is() == sal_True ) 2720 { 2721 uno::Reference< awt::XDevice > xDevice( m_xFrame->getContainerWindow(), uno::UNO_QUERY ); 2722 2723 // Convert relativ size to output size. 2724 awt::Rectangle aRectangle = m_xFrame->getContainerWindow()->getPosSize(); 2725 awt::DeviceInfo aInfo = xDevice->getInfo(); 2726 awt::Size aSize( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset , 2727 aRectangle.Height - aInfo.TopInset - aInfo.BottomInset ); 2728 2729 // Resize our component window. 2730 xComponentWindow->setPosSize( 0, 0, aSize.Width, aSize.Height, awt::PosSize::POSSIZE ); 2731 } 2732 } 2733 } 2734 2735 void SAL_CALL LayoutManager::windowMoved( const awt::WindowEvent& ) 2736 { 2737 } 2738 2739 void SAL_CALL LayoutManager::windowShown( const lang::EventObject& aEvent ) 2740 { 2741 ReadGuard aReadLock( m_aLock ); 2742 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 2743 bool bParentWindowVisible( m_bParentWindowVisible ); 2744 aReadLock.unlock(); 2745 2746 Reference< XInterface > xIfac( xContainerWindow, UNO_QUERY ); 2747 if ( xIfac == aEvent.Source ) 2748 { 2749 bool bSetVisible = false; 2750 2751 WriteGuard aWriteLock( m_aLock ); 2752 m_bParentWindowVisible = true; 2753 bSetVisible = ( m_bParentWindowVisible != bParentWindowVisible ); 2754 aWriteLock.unlock(); 2755 2756 if ( bSetVisible ) 2757 implts_updateUIElementsVisibleState( sal_True ); 2758 } 2759 } 2760 2761 void SAL_CALL LayoutManager::windowHidden( const lang::EventObject& aEvent ) 2762 { 2763 ReadGuard aReadLock( m_aLock ); 2764 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 2765 bool bParentWindowVisible( m_bParentWindowVisible ); 2766 aReadLock.unlock(); 2767 2768 Reference< XInterface > xIfac( xContainerWindow, UNO_QUERY ); 2769 if ( xIfac == aEvent.Source ) 2770 { 2771 bool bSetInvisible = false; 2772 2773 WriteGuard aWriteLock( m_aLock ); 2774 m_bParentWindowVisible = false; 2775 bSetInvisible = ( m_bParentWindowVisible != bParentWindowVisible ); 2776 aWriteLock.unlock(); 2777 2778 if ( bSetInvisible ) 2779 implts_updateUIElementsVisibleState( sal_False ); 2780 } 2781 } 2782 2783 IMPL_LINK( LayoutManager, AsyncLayoutHdl, Timer *, EMPTYARG ) 2784 { 2785 ReadGuard aReadLock( m_aLock ); 2786 m_aAsyncLayoutTimer.Stop(); 2787 2788 if( !m_xContainerWindow.is() ) 2789 return 0; 2790 2791 awt::Rectangle aDockingArea( m_aDockingArea ); 2792 ::Size aStatusBarSize( implts_getStatusBarSize() ); 2793 2794 // Subtract status bar height 2795 aDockingArea.Height -= aStatusBarSize.Height(); 2796 aReadLock.unlock(); 2797 2798 implts_setDockingAreaWindowSizes( aDockingArea ); 2799 implts_doLayout( sal_True, sal_False ); 2800 2801 return 0; 2802 } 2803 2804 //--------------------------------------------------------------------------------------------------------- 2805 // XFrameActionListener 2806 //--------------------------------------------------------------------------------------------------------- 2807 void SAL_CALL LayoutManager::frameAction( const FrameActionEvent& aEvent ) 2808 { 2809 if (( aEvent.Action == FrameAction_COMPONENT_ATTACHED ) || ( aEvent.Action == FrameAction_COMPONENT_REATTACHED )) 2810 { 2811 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)" ); 2812 2813 WriteGuard aWriteLock( m_aLock ); 2814 m_bComponentAttached = sal_True; 2815 m_bMustDoLayout = sal_True; 2816 aWriteLock.unlock(); 2817 2818 implts_reset( sal_True ); 2819 implts_doLayout( sal_True, sal_False ); 2820 implts_doLayout( sal_True, sal_True ); 2821 } 2822 else if (( aEvent.Action == FrameAction_FRAME_UI_ACTIVATED ) || ( aEvent.Action == FrameAction_FRAME_UI_DEACTIVATING )) 2823 { 2824 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::frameAction (FRAME_UI_ACTIVATED|DEACTIVATING)" ); 2825 2826 WriteGuard aWriteLock( m_aLock ); 2827 m_bActive = ( aEvent.Action == FrameAction_FRAME_UI_ACTIVATED ); 2828 aWriteLock.unlock(); 2829 2830 implts_toggleFloatingUIElementsVisibility( aEvent.Action == FrameAction_FRAME_UI_ACTIVATED ); 2831 } 2832 else if ( aEvent.Action == FrameAction_COMPONENT_DETACHING ) 2833 { 2834 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_DETACHING)" ); 2835 2836 WriteGuard aWriteLock( m_aLock ); 2837 m_bComponentAttached = sal_False; 2838 aWriteLock.unlock(); 2839 2840 implts_reset( sal_False ); 2841 } 2842 } 2843 2844 // ______________________________________________ 2845 2846 void SAL_CALL LayoutManager::disposing( const lang::EventObject& rEvent ) 2847 { 2848 sal_Bool bDisposeAndClear( sal_False ); 2849 2850 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 2851 WriteGuard aWriteLock( m_aLock ); 2852 2853 if ( rEvent.Source == Reference< XInterface >( m_xFrame, UNO_QUERY )) 2854 { 2855 // Our frame gets disposed, release all our references that depends on a working frame reference. 2856 Application::RemoveEventListener( LINK( this, LayoutManager, SettingsChanged ) ); 2857 2858 setDockingAreaAcceptor( Reference< ui::XDockingAreaAcceptor >() ); 2859 2860 // destroy all elements, it's possible that dettaching is NOT called! 2861 implts_destroyElements(); 2862 impl_clearUpMenuBar(); 2863 m_xMenuBar.clear(); 2864 if ( m_xInplaceMenuBar.is() ) 2865 { 2866 m_pInplaceMenuBar = 0; 2867 m_xInplaceMenuBar->dispose(); 2868 } 2869 m_xInplaceMenuBar.clear(); 2870 m_xContainerWindow.clear(); 2871 m_xContainerTopWindow.clear(); 2872 2873 // forward disposing call to toolbar manager 2874 if ( m_pToolbarManager != NULL ) 2875 m_pToolbarManager->disposing(rEvent); 2876 2877 if ( m_xModuleCfgMgr.is() ) 2878 { 2879 try 2880 { 2881 Reference< XUIConfiguration > xModuleCfgMgr( m_xModuleCfgMgr, UNO_QUERY ); 2882 xModuleCfgMgr->removeConfigurationListener( 2883 Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 2884 } 2885 catch ( Exception& ) {} 2886 } 2887 2888 if ( m_xDocCfgMgr.is() ) 2889 { 2890 try 2891 { 2892 Reference< XUIConfiguration > xDocCfgMgr( m_xDocCfgMgr, UNO_QUERY ); 2893 xDocCfgMgr->removeConfigurationListener( 2894 Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); 2895 } 2896 catch ( Exception& ) {} 2897 } 2898 2899 m_xDocCfgMgr.clear(); 2900 m_xModuleCfgMgr.clear(); 2901 m_xFrame.clear(); 2902 delete m_pGlobalSettings; 2903 m_pGlobalSettings = 0; 2904 2905 bDisposeAndClear = sal_True; 2906 } 2907 else if ( rEvent.Source == Reference< XInterface >( m_xContainerWindow, UNO_QUERY )) 2908 { 2909 // Our container window gets disposed. Remove all user interface elements. 2910 uno::Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); 2911 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 2912 if ( pToolbarManager ) 2913 { 2914 uno::Reference< awt::XWindowPeer > aEmptyWindowPeer; 2915 pToolbarManager->setParentWindow( aEmptyWindowPeer ); 2916 } 2917 impl_clearUpMenuBar(); 2918 m_xMenuBar.clear(); 2919 if ( m_xInplaceMenuBar.is() ) 2920 { 2921 m_pInplaceMenuBar = 0; 2922 m_xInplaceMenuBar->dispose(); 2923 } 2924 m_xInplaceMenuBar.clear(); 2925 m_xContainerWindow.clear(); 2926 m_xContainerTopWindow.clear(); 2927 } 2928 else if ( rEvent.Source == Reference< XInterface >( m_xDocCfgMgr, UNO_QUERY )) 2929 m_xDocCfgMgr.clear(); 2930 else if ( rEvent.Source == Reference< XInterface >( m_xModuleCfgMgr , UNO_QUERY )) 2931 m_xModuleCfgMgr.clear(); 2932 2933 aWriteLock.unlock(); 2934 /* SAFE AREA ----------------------------------------------------------------------------------------------- */ 2935 2936 // Send disposing to our listener when we have lost our frame. 2937 if ( bDisposeAndClear ) 2938 { 2939 // Send message to all listener and forget her references. 2940 uno::Reference< frame::XLayoutManager > xThis( static_cast< ::cppu::OWeakObject* >(this), uno::UNO_QUERY ); 2941 lang::EventObject aEvent( xThis ); 2942 m_aListenerContainer.disposeAndClear( aEvent ); 2943 } 2944 } 2945 2946 void SAL_CALL LayoutManager::elementInserted( const ui::ConfigurationEvent& Event ) 2947 { 2948 ReadGuard aReadLock( m_aLock ); 2949 Reference< XFrame > xFrame( m_xFrame ); 2950 Reference< ui::XUIConfigurationListener > xUICfgListener( m_xToolbarManager ); 2951 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 2952 aReadLock.unlock(); 2953 2954 if ( xFrame.is() ) 2955 { 2956 ::rtl::OUString aElementType; 2957 ::rtl::OUString aElementName; 2958 bool bRefreshLayout(false); 2959 2960 parseResourceURL( Event.ResourceURL, aElementType, aElementName ); 2961 if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 2962 { 2963 if ( xUICfgListener.is() ) 2964 { 2965 xUICfgListener->elementInserted( Event ); 2966 bRefreshLayout = pToolbarManager->isLayoutDirty(); 2967 } 2968 } 2969 else if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_MENUBAR )) 2970 { 2971 Reference< XUIElement > xUIElement = implts_findElement( Event.ResourceURL ); 2972 Reference< XUIElementSettings > xElementSettings( xUIElement, UNO_QUERY ); 2973 if ( xElementSettings.is() ) 2974 { 2975 ::rtl::OUString aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" )); 2976 uno::Reference< XPropertySet > xPropSet( xElementSettings, uno::UNO_QUERY ); 2977 if ( xPropSet.is() ) 2978 { 2979 if ( Event.Source == uno::Reference< uno::XInterface >( m_xDocCfgMgr, uno::UNO_QUERY )) 2980 xPropSet->setPropertyValue( aConfigSourcePropName, makeAny( m_xDocCfgMgr )); 2981 } 2982 xElementSettings->updateSettings(); 2983 } 2984 } 2985 2986 if ( bRefreshLayout ) 2987 doLayout(); 2988 } 2989 } 2990 2991 void SAL_CALL LayoutManager::elementRemoved( const ui::ConfigurationEvent& Event ) 2992 { 2993 ReadGuard aReadLock( m_aLock ); 2994 Reference< frame::XFrame > xFrame( m_xFrame ); 2995 Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); 2996 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); 2997 Reference< ui::XUIElement > xMenuBar( m_xMenuBar ); 2998 Reference< ui::XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr ); 2999 Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr ); 3000 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 3001 aReadLock.unlock(); 3002 3003 if ( xFrame.is() ) 3004 { 3005 ::rtl::OUString aElementType; 3006 ::rtl::OUString aElementName; 3007 bool bRefreshLayout(false); 3008 3009 parseResourceURL( Event.ResourceURL, aElementType, aElementName ); 3010 if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 3011 { 3012 if ( xToolbarManager.is() ) 3013 { 3014 xToolbarManager->elementRemoved( Event ); 3015 bRefreshLayout = pToolbarManager->isLayoutDirty(); 3016 } 3017 } 3018 else 3019 { 3020 Reference< XUIElement > xUIElement = implts_findElement( Event.ResourceURL ); 3021 Reference< XUIElementSettings > xElementSettings( xUIElement, UNO_QUERY ); 3022 if ( xElementSettings.is() ) 3023 { 3024 bool bNoSettings( false ); 3025 ::rtl::OUString aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" )); 3026 Reference< XInterface > xElementCfgMgr; 3027 Reference< XPropertySet > xPropSet( xElementSettings, UNO_QUERY ); 3028 3029 if ( xPropSet.is() ) 3030 xPropSet->getPropertyValue( aConfigSourcePropName ) >>= xElementCfgMgr; 3031 3032 if ( !xElementCfgMgr.is() ) 3033 return; 3034 3035 // Check if the same UI configuration manager has changed => check further 3036 if ( Event.Source == xElementCfgMgr ) 3037 { 3038 // Same UI configuration manager where our element has its settings 3039 if ( Event.Source == Reference< XInterface >( xDocCfgMgr, UNO_QUERY )) 3040 { 3041 // document settings removed 3042 if ( xModuleCfgMgr->hasSettings( Event.ResourceURL )) 3043 { 3044 xPropSet->setPropertyValue( aConfigSourcePropName, makeAny( m_xModuleCfgMgr )); 3045 xElementSettings->updateSettings(); 3046 return; 3047 } 3048 } 3049 3050 bNoSettings = true; 3051 } 3052 3053 // No settings anymore, element must be destroyed 3054 if ( xContainerWindow.is() && bNoSettings ) 3055 { 3056 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) && aElementName.equalsIgnoreAsciiCaseAscii( "menubar" )) 3057 { 3058 SystemWindow* pSysWindow = getTopSystemWindow( xContainerWindow ); 3059 if ( pSysWindow && !m_bInplaceMenuSet ) 3060 pSysWindow->SetMenuBar( 0 ); 3061 3062 Reference< XComponent > xComp( xMenuBar, UNO_QUERY ); 3063 if ( xComp.is() ) 3064 xComp->dispose(); 3065 3066 WriteGuard aWriteLock( m_aLock ); 3067 m_xMenuBar.clear(); 3068 } 3069 } 3070 } 3071 } 3072 3073 if ( bRefreshLayout ) 3074 doLayout(); 3075 } 3076 } 3077 3078 void SAL_CALL LayoutManager::elementReplaced( const ui::ConfigurationEvent& Event ) 3079 { 3080 ReadGuard aReadLock( m_aLock ); 3081 Reference< XFrame > xFrame( m_xFrame ); 3082 Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); 3083 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 3084 aReadLock.unlock(); 3085 3086 if ( xFrame.is() ) 3087 { 3088 ::rtl::OUString aElementType; 3089 ::rtl::OUString aElementName; 3090 bool bRefreshLayout(false); 3091 3092 parseResourceURL( Event.ResourceURL, aElementType, aElementName ); 3093 if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) 3094 { 3095 if ( xToolbarManager.is() ) 3096 { 3097 xToolbarManager->elementReplaced( Event ); 3098 bRefreshLayout = pToolbarManager->isLayoutDirty(); 3099 } 3100 } 3101 else 3102 { 3103 Reference< XUIElement > xUIElement = implts_findElement( Event.ResourceURL ); 3104 Reference< XUIElementSettings > xElementSettings( xUIElement, UNO_QUERY ); 3105 if ( xElementSettings.is() ) 3106 { 3107 ::rtl::OUString aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" )); 3108 Reference< XInterface > xElementCfgMgr; 3109 Reference< XPropertySet > xPropSet( xElementSettings, UNO_QUERY ); 3110 3111 if ( xPropSet.is() ) 3112 xPropSet->getPropertyValue( aConfigSourcePropName ) >>= xElementCfgMgr; 3113 3114 if ( !xElementCfgMgr.is() ) 3115 return; 3116 3117 // Check if the same UI configuration manager has changed => update settings 3118 if ( Event.Source == xElementCfgMgr ) 3119 xElementSettings->updateSettings(); 3120 } 3121 } 3122 3123 if ( bRefreshLayout ) 3124 doLayout(); 3125 } 3126 } 3127 3128 //--------------------------------------------------------------------------------------------------------- 3129 // OPropertySetHelper 3130 //--------------------------------------------------------------------------------------------------------- 3131 sal_Bool SAL_CALL LayoutManager::convertFastPropertyValue( Any& aConvertedValue, 3132 Any& aOldValue, 3133 sal_Int32 nHandle, 3134 const Any& aValue ) 3135 { 3136 return LayoutManager_PBase::convertFastPropertyValue( aConvertedValue, aOldValue, nHandle, aValue ); 3137 } 3138 3139 void SAL_CALL LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, 3140 const uno::Any& aValue ) 3141 { 3142 if ( nHandle != LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY ) 3143 LayoutManager_PBase::setFastPropertyValue_NoBroadcast( nHandle, aValue ); 3144 3145 switch( nHandle ) 3146 { 3147 case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER: 3148 implts_updateMenuBarClose(); 3149 break; 3150 3151 case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY: 3152 { 3153 sal_Bool bValue(sal_False); 3154 if (( aValue >>= bValue ) && bValue ) 3155 { 3156 ReadGuard aReadLock( m_aLock ); 3157 Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); 3158 ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; 3159 bool bAutomaticToolbars( m_bAutomaticToolbars ); 3160 aReadLock.unlock(); 3161 3162 if ( pToolbarManager ) 3163 pToolbarManager->refreshToolbarsVisibility( bAutomaticToolbars ); 3164 } 3165 break; 3166 } 3167 3168 case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI: 3169 implts_setCurrentUIVisibility( !m_bHideCurrentUI ); 3170 break; 3171 default: break; 3172 } 3173 } 3174 3175 void SAL_CALL LayoutManager::getFastPropertyValue( uno::Any& aValue, sal_Int32 nHandle ) const 3176 { 3177 LayoutManager_PBase::getFastPropertyValue( aValue, nHandle ); 3178 } 3179 3180 ::cppu::IPropertyArrayHelper& SAL_CALL LayoutManager::getInfoHelper() 3181 { 3182 static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL; 3183 3184 if( pInfoHelper == NULL ) 3185 { 3186 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 3187 3188 if( pInfoHelper == NULL ) 3189 { 3190 uno::Sequence< beans::Property > aProperties; 3191 describeProperties( aProperties ); 3192 static ::cppu::OPropertyArrayHelper aInfoHelper( aProperties, sal_True ); 3193 pInfoHelper = &aInfoHelper; 3194 } 3195 } 3196 3197 return(*pInfoHelper); 3198 } 3199 3200 uno::Reference< beans::XPropertySetInfo > SAL_CALL LayoutManager::getPropertySetInfo() 3201 { 3202 static uno::Reference< beans::XPropertySetInfo >* pInfo = NULL; 3203 3204 if( pInfo == NULL ) 3205 { 3206 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 3207 3208 if( pInfo == NULL ) 3209 { 3210 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 3211 pInfo = &xInfo; 3212 } 3213 } 3214 3215 return (*pInfo); 3216 } 3217 3218 } // namespace framework 3219