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