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