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