LCOV - code coverage report
Current view: top level - libreoffice/framework/source/layoutmanager - layoutmanager.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1001 1790 55.9 %
Date: 2012-12-27 Functions: 76 117 65.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10