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