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