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

Generated by: LCOV version 1.10