1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
22 #include <services/layoutmanager.hxx>
23 #include "helpers.hxx"
25 #include <framework/sfxhelperfunctions.hxx>
26 #include <uielement/menubarwrapper.hxx>
27 #include <framework/addonsoptions.hxx>
28 #include <classes/fwkresid.hxx>
29 #include <classes/resource.hrc>
30 #include <toolkit/helper/convert.hxx>
31 #include <uielement/progressbarwrapper.hxx>
32 #include <uiconfiguration/globalsettings.hxx>
33 #include <uiconfiguration/windowstateproperties.hxx>
34 #include "toolbarlayoutmanager.hxx"
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/lang/XMultiComponentFactory.hpp>
42 #include <com/sun/star/awt/XTopWindow.hpp>
43 #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
44 #include <com/sun/star/lang/SystemDependent.hpp>
45 #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
46 #include <com/sun/star/awt/PosSize.hpp>
47 #include <com/sun/star/awt/XDevice.hpp>
48 #include <com/sun/star/awt/XSystemDependentWindowPeer.hpp>
49 #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
50 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
51 #include <com/sun/star/ui/UIElementType.hpp>
52 #include <com/sun/star/ui/theWindowStateConfiguration.hpp>
53 #include <com/sun/star/ui/theUIElementFactoryManager.hpp>
54 #include <com/sun/star/container/XNameReplace.hpp>
55 #include <com/sun/star/container/XNameContainer.hpp>
56 #include <com/sun/star/frame/LayoutManagerEvents.hpp>
57 #include <com/sun/star/frame/XDispatchProvider.hpp>
58 #include <com/sun/star/frame/DispatchHelper.hpp>
59 #include <com/sun/star/lang/DisposedException.hpp>
60 #include <com/sun/star/util/URLTransformer.hpp>
62 #include <comphelper/processfactory.hxx>
63 #include <comphelper/lok.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/helper/vclunohelper.hxx>
73 #include <toolkit/awt/vclxwindow.hxx>
74 #include <toolkit/awt/vclxmenu.hxx>
75 #include <comphelper/uno3.hxx>
76 #include <rtl/instance.hxx>
77 #include <unotools/cmdoptions.hxx>
79 #include <rtl/ref.hxx>
80 #include <rtl/strbuf.hxx>
83 #include <boost/utility.hpp>
86 using namespace ::com::sun::star
;
87 using namespace ::com::sun::star::uno
;
88 using namespace ::com::sun::star::beans
;
89 using namespace ::com::sun::star::util
;
90 using namespace ::com::sun::star::lang
;
91 using namespace ::com::sun::star::container
;
92 using namespace ::com::sun::star::ui
;
93 using namespace ::com::sun::star::frame
;
95 static const char STATUS_BAR_ALIAS
[] = "private:resource/statusbar/statusbar";
96 static const char PROGRESS_BAR_ALIAS
[] = "private:resource/progressbar/progressbar";
101 IMPLEMENT_FORWARD_XTYPEPROVIDER2( LayoutManager
, LayoutManager_Base
, LayoutManager_PBase
)
102 IMPLEMENT_FORWARD_XINTERFACE2( LayoutManager
, LayoutManager_Base
, LayoutManager_PBase
)
104 LayoutManager::LayoutManager( const Reference
< XComponentContext
>& xContext
) : LayoutManager_Base()
105 , ::cppu::OBroadcastHelperVar
< ::cppu::OMultiTypeInterfaceContainerHelper
, ::cppu::OMultiTypeInterfaceContainerHelper::keyType
>(m_aMutex
)
106 , LayoutManager_PBase( *(static_cast< ::cppu::OBroadcastHelper
* >(this)) )
107 , m_xContext( xContext
)
108 , m_xURLTransformer( URLTransformer::create(xContext
) )
111 , m_bInplaceMenuSet( false )
112 , m_bDockingInProgress( false )
113 , m_bMenuVisible( true )
114 , m_bComponentAttached( false )
115 , m_bDoLayout( false )
117 , m_bParentWindowVisible( false )
118 , m_bMustDoLayout( true )
119 #if HAVE_FEATURE_DESKTOP
120 , m_bAutomaticToolbars( true )
122 , m_bAutomaticToolbars( false )
124 , m_bStoreWindowState( false )
125 , m_bHideCurrentUI( false )
126 , m_bGlobalSettings( false )
127 , m_bPreserveContentSize( false )
128 , m_bMenuBarCloseButton( false )
129 , m_pInplaceMenuBar( NULL
)
130 , m_xModuleManager( ModuleManager::create( xContext
))
131 , m_xUIElementFactoryManager( ui::theUIElementFactoryManager::get(xContext
) )
132 , m_xPersistentWindowStateSupplier( ui::theWindowStateConfiguration::get( xContext
) )
133 , m_pGlobalSettings( 0 )
134 , m_aListenerContainer( m_aMutex
)
135 , m_pToolbarManager( 0 )
136 , m_xToolbarManager( 0 )
138 // Initialize statusbar member
139 const sal_Bool bRefreshVisibility
= sal_False
;
140 m_aStatusBarElement
.m_aType
= "statusbar";
141 m_aStatusBarElement
.m_aName
= STATUS_BAR_ALIAS
;
143 if (!comphelper::LibreOfficeKit::isActive())
145 m_pToolbarManager
= new ToolbarLayoutManager( xContext
, Reference
<XUIElementFactory
>(m_xUIElementFactoryManager
, UNO_QUERY_THROW
), this );
146 m_xToolbarManager
= uno::Reference
< ui::XUIConfigurationListener
>( static_cast< OWeakObject
* >( m_pToolbarManager
), uno::UNO_QUERY
);
149 Application::AddEventListener( LINK( this, LayoutManager
, SettingsChanged
) );
151 m_aAsyncLayoutTimer
.SetTimeout( 50 );
152 m_aAsyncLayoutTimer
.SetTimeoutHdl( LINK( this, LayoutManager
, AsyncLayoutHdl
) );
154 registerProperty( LAYOUTMANAGER_PROPNAME_AUTOMATICTOOLBARS
, LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS
, css::beans::PropertyAttribute::TRANSIENT
, &m_bAutomaticToolbars
, cppu::UnoType
<decltype(m_bAutomaticToolbars
)>::get() );
155 registerProperty( LAYOUTMANAGER_PROPNAME_HIDECURRENTUI
, LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI
, beans::PropertyAttribute::TRANSIENT
, &m_bHideCurrentUI
, cppu::UnoType
<decltype(m_bHideCurrentUI
)>::get() );
156 registerProperty( LAYOUTMANAGER_PROPNAME_LOCKCOUNT
, LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT
, beans::PropertyAttribute::TRANSIENT
| beans::PropertyAttribute::READONLY
, &m_nLockCount
, cppu::UnoType
<decltype(m_nLockCount
)>::get() );
157 registerProperty( LAYOUTMANAGER_PROPNAME_MENUBARCLOSER
, LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER
, beans::PropertyAttribute::TRANSIENT
, &m_bMenuBarCloseButton
, cppu::UnoType
<decltype(m_bMenuBarCloseButton
)>::get() );
158 registerPropertyNoMember( LAYOUTMANAGER_PROPNAME_REFRESHVISIBILITY
, LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY
, beans::PropertyAttribute::TRANSIENT
, cppu::UnoType
<decltype(bRefreshVisibility
)>::get(), &bRefreshVisibility
);
159 registerProperty( LAYOUTMANAGER_PROPNAME_PRESERVE_CONTENT_SIZE
, LAYOUTMANAGER_PROPHANDLE_PRESERVE_CONTENT_SIZE
, beans::PropertyAttribute::TRANSIENT
, &m_bPreserveContentSize
, cppu::UnoType
<decltype(m_bPreserveContentSize
)>::get() );
162 LayoutManager::~LayoutManager()
164 Application::RemoveEventListener( LINK( this, LayoutManager
, SettingsChanged
) );
165 m_aAsyncLayoutTimer
.Stop();
166 setDockingAreaAcceptor(NULL
);
167 delete m_pGlobalSettings
;
170 // Internal helper function
171 void LayoutManager::impl_clearUpMenuBar()
175 // Clear up VCL menu bar to prepare shutdown
176 if ( m_xContainerWindow
.is() )
178 SolarMutexGuard aGuard
;
180 SystemWindow
* pSysWindow
= getTopSystemWindow( m_xContainerWindow
);
183 MenuBar
* pSetMenuBar
= 0;
184 if ( m_xInplaceMenuBar
.is() )
185 pSetMenuBar
= static_cast<MenuBar
*>(m_pInplaceMenuBar
->GetMenuBar());
188 Reference
< awt::XMenuBar
> xMenuBar
;
190 Reference
< XPropertySet
> xPropSet( m_xMenuBar
, UNO_QUERY
);
195 xPropSet
->getPropertyValue("XMenuBar") >>= xMenuBar
;
197 catch (const beans::UnknownPropertyException
&)
200 catch (const lang::WrappedTargetException
&)
205 VCLXMenu
* pAwtMenuBar
= VCLXMenu::GetImplementation( xMenuBar
);
207 pSetMenuBar
= static_cast<MenuBar
*>(pAwtMenuBar
->GetMenu());
210 MenuBar
* pTopMenuBar
= pSysWindow
->GetMenuBar();
211 if ( pSetMenuBar
== pTopMenuBar
)
212 pSysWindow
->SetMenuBar( 0 );
216 // reset inplace menubar manager
217 m_pInplaceMenuBar
= 0;
218 if ( m_xInplaceMenuBar
.is() )
220 m_xInplaceMenuBar
->dispose();
221 m_xInplaceMenuBar
.clear();
224 Reference
< XComponent
> xComp( m_xMenuBar
, UNO_QUERY
);
231 void LayoutManager::implts_lock()
237 bool LayoutManager::implts_unlock()
240 m_nLockCount
= std::max( m_nLockCount
-1, static_cast<sal_Int32
>(0) );
241 return ( m_nLockCount
== 0 );
244 void LayoutManager::implts_reset( bool bAttached
)
246 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
247 SolarMutexClearableGuard aReadLock
;
248 Reference
< XFrame
> xFrame
= m_xFrame
;
249 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
250 Reference
< XUIConfiguration
> xModuleCfgMgr( m_xModuleCfgMgr
, UNO_QUERY
);
251 Reference
< XUIConfiguration
> xDocCfgMgr( m_xDocCfgMgr
, UNO_QUERY
);
252 Reference
< XNameAccess
> xPersistentWindowState( m_xPersistentWindowState
);
253 Reference
< XComponentContext
> xContext( m_xContext
);
254 Reference
< XNameAccess
> xPersistentWindowStateSupplier( m_xPersistentWindowStateSupplier
);
255 ToolbarLayoutManager
* pToolbarManager( m_pToolbarManager
);
256 OUString
aModuleIdentifier( m_aModuleIdentifier
);
257 bool bAutomaticToolbars( m_bAutomaticToolbars
);
259 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
263 Reference
< XModel
> xModel
;
268 OUString
aOldModuleIdentifier( aModuleIdentifier
);
271 aModuleIdentifier
= m_xModuleManager
->identify( xFrame
);
273 catch( const Exception
& ) {}
275 if ( !aModuleIdentifier
.isEmpty() && aOldModuleIdentifier
!= aModuleIdentifier
)
277 Reference
< XModuleUIConfigurationManagerSupplier
> xModuleCfgSupplier
;
279 xModuleCfgSupplier
= theModuleUIConfigurationManagerSupplier::get( xContext
);
281 if ( xModuleCfgMgr
.is() )
285 // Remove listener to old module ui configuration manager
286 xModuleCfgMgr
->removeConfigurationListener( Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
288 catch (const Exception
&)
295 // Add listener to new module ui configuration manager
296 xModuleCfgMgr
= Reference
< XUIConfiguration
>( xModuleCfgSupplier
->getUIConfigurationManager( aModuleIdentifier
), UNO_QUERY
);
297 if ( xModuleCfgMgr
.is() )
298 xModuleCfgMgr
->addConfigurationListener( Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
300 catch (const Exception
&)
306 // Retrieve persistent window state reference for our new module
307 if ( xPersistentWindowStateSupplier
.is() )
308 xPersistentWindowStateSupplier
->getByName( aModuleIdentifier
) >>= xPersistentWindowState
;
310 catch (const NoSuchElementException
&)
313 catch (const WrappedTargetException
&)
318 xModel
= impl_getModelFromFrame( xFrame
);
321 Reference
< XUIConfigurationManagerSupplier
> xUIConfigurationManagerSupplier( xModel
, UNO_QUERY
);
322 if ( xUIConfigurationManagerSupplier
.is() )
324 if ( xDocCfgMgr
.is() )
328 // Remove listener to old ui configuration manager
329 xDocCfgMgr
->removeConfigurationListener( Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
331 catch (const Exception
&)
338 xDocCfgMgr
= Reference
< XUIConfiguration
>( xUIConfigurationManagerSupplier
->getUIConfigurationManager(), UNO_QUERY
);
339 if ( xDocCfgMgr
.is() )
340 xDocCfgMgr
->addConfigurationListener( Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
342 catch (const Exception
&)
350 // Remove configuration listeners before we can release our references
351 if ( xModuleCfgMgr
.is() )
355 xModuleCfgMgr
->removeConfigurationListener(
356 Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
358 catch (const Exception
&)
363 if ( xDocCfgMgr
.is() )
367 xDocCfgMgr
->removeConfigurationListener(
368 Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
370 catch (const Exception
&)
375 // Release references to our configuration managers as we currently don't have
376 // an attached module.
377 xModuleCfgMgr
.clear();
379 xPersistentWindowState
.clear();
380 aModuleIdentifier
.clear();
383 Reference
< XUIConfigurationManager
> xModCfgMgr( xModuleCfgMgr
, UNO_QUERY
);
384 Reference
< XUIConfigurationManager
> xDokCfgMgr( xDocCfgMgr
, UNO_QUERY
);
386 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
387 SolarMutexClearableGuard aWriteLock
;
389 m_aDockingArea
= awt::Rectangle();
390 m_bComponentAttached
= bAttached
;
391 m_aModuleIdentifier
= aModuleIdentifier
;
392 m_xModuleCfgMgr
= xModCfgMgr
;
393 m_xDocCfgMgr
= xDokCfgMgr
;
394 m_xPersistentWindowState
= xPersistentWindowState
;
395 m_aStatusBarElement
.m_bStateRead
= false; // reset state to read data again!
397 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
399 // reset/notify toolbar layout manager
400 if ( pToolbarManager
)
404 pToolbarManager
->attach( xFrame
, xModCfgMgr
, xDokCfgMgr
, xPersistentWindowState
);
405 uno::Reference
< awt::XWindowPeer
> xParent( xContainerWindow
, UNO_QUERY
);
406 pToolbarManager
->setParentWindow( xParent
);
407 if ( bAutomaticToolbars
)
408 pToolbarManager
->createStaticToolbars();
412 pToolbarManager
->reset();
413 implts_destroyElements();
421 bool LayoutManager::implts_isEmbeddedLayoutManager() const
423 SolarMutexClearableGuard aReadLock
;
424 Reference
< XFrame
> xFrame
= m_xFrame
;
425 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
428 Reference
< awt::XWindow
> xFrameContainerWindow
= xFrame
->getContainerWindow();
429 if ( xFrameContainerWindow
== xContainerWindow
)
435 void LayoutManager::implts_destroyElements()
437 SolarMutexResettableGuard aWriteLock
;
438 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
441 if ( pToolbarManager
)
442 pToolbarManager
->destroyToolbars();
444 implts_destroyStatusBar();
447 impl_clearUpMenuBar();
451 void LayoutManager::implts_toggleFloatingUIElementsVisibility( bool bActive
)
453 SolarMutexClearableGuard aReadLock
;
454 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
457 if ( pToolbarManager
)
458 pToolbarManager
->setFloatingToolbarsVisibility( bActive
);
461 uno::Reference
< ui::XUIElement
> LayoutManager::implts_findElement( const OUString
& aName
)
463 OUString aElementType
;
464 OUString aElementName
;
466 parseResourceURL( aName
, aElementType
, aElementName
);
467 if ( aElementType
.equalsIgnoreAsciiCase("menubar") &&
468 aElementName
.equalsIgnoreAsciiCase("menubar") )
470 else if (( aElementType
.equalsIgnoreAsciiCase("statusbar") &&
471 aElementName
.equalsIgnoreAsciiCase("statusbar") ) ||
472 ( m_aStatusBarElement
.m_aName
== aName
))
473 return m_aStatusBarElement
.m_xUIElement
;
474 else if ( aElementType
.equalsIgnoreAsciiCase("progressbar") &&
475 aElementName
.equalsIgnoreAsciiCase("progressbar") )
476 return m_aProgressBarElement
.m_xUIElement
;
478 return uno::Reference
< ui::XUIElement
>();
481 bool LayoutManager::implts_readWindowStateData( const OUString
& aName
, UIElement
& rElementData
)
483 return readWindowStateData( aName
, rElementData
, m_xPersistentWindowState
,
484 m_pGlobalSettings
, m_bGlobalSettings
, m_xContext
);
487 bool LayoutManager::readWindowStateData( const OUString
& aName
, UIElement
& rElementData
,
488 const Reference
< XNameAccess
> &rPersistentWindowState
,
489 GlobalSettings
* &rGlobalSettings
, bool &bInGlobalSettings
,
490 const Reference
< XComponentContext
> &rComponentContext
)
492 bool bGetSettingsState( false );
494 SolarMutexResettableGuard aWriteLock
;
495 Reference
< XNameAccess
> xPersistentWindowState( rPersistentWindowState
);
498 if ( xPersistentWindowState
.is() )
501 bool bGlobalSettings( bInGlobalSettings
);
502 GlobalSettings
* pGlobalSettings( 0 );
503 if ( rGlobalSettings
== 0 )
505 rGlobalSettings
= new GlobalSettings( rComponentContext
);
506 bGetSettingsState
= true;
508 pGlobalSettings
= rGlobalSettings
;
513 Sequence
< PropertyValue
> aWindowState
;
514 if ( xPersistentWindowState
->hasByName( aName
) && (xPersistentWindowState
->getByName( aName
) >>= aWindowState
) )
516 bool bValue( false );
517 for ( sal_Int32 n
= 0; n
< aWindowState
.getLength(); n
++ )
519 if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_DOCKED
)
521 if ( aWindowState
[n
].Value
>>= bValue
)
522 rElementData
.m_bFloating
= !bValue
;
524 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_VISIBLE
)
526 if ( aWindowState
[n
].Value
>>= bValue
)
527 rElementData
.m_bVisible
= bValue
;
529 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_DOCKINGAREA
)
531 ui::DockingArea eDockingArea
;
532 if ( aWindowState
[n
].Value
>>= eDockingArea
)
533 rElementData
.m_aDockedData
.m_nDockedArea
= sal_Int16( eDockingArea
);
535 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_DOCKPOS
)
538 if (aWindowState
[n
].Value
>>= aPoint
)
540 //tdf#90256 repair these broken Docking positions
542 aPoint
.X
= SAL_MAX_INT32
;
544 aPoint
.Y
= SAL_MAX_INT32
;
545 rElementData
.m_aDockedData
.m_aPos
= aPoint
;
548 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_POS
)
551 if ( aWindowState
[n
].Value
>>= aPoint
)
552 rElementData
.m_aFloatingData
.m_aPos
= aPoint
;
554 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_SIZE
)
557 if ( aWindowState
[n
].Value
>>= aSize
)
558 rElementData
.m_aFloatingData
.m_aSize
= aSize
;
560 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_UINAME
)
561 aWindowState
[n
].Value
>>= rElementData
.m_aUIName
;
562 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_STYLE
)
564 sal_Int32 nStyle
= 0;
565 if ( aWindowState
[n
].Value
>>= nStyle
)
566 rElementData
.m_nStyle
= static_cast<ButtonType
>( nStyle
);
568 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_LOCKED
)
570 if ( aWindowState
[n
].Value
>>= bValue
)
571 rElementData
.m_aDockedData
.m_bLocked
= bValue
;
573 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_CONTEXT
)
575 if ( aWindowState
[n
].Value
>>= bValue
)
576 rElementData
.m_bContextSensitive
= bValue
;
578 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_NOCLOSE
)
580 if ( aWindowState
[n
].Value
>>= bValue
)
581 rElementData
.m_bNoClose
= bValue
;
583 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_CONTEXTACTIVE
)
585 if ( aWindowState
[n
].Value
>>= bValue
)
586 rElementData
.m_bContextActive
= bValue
;
588 else if ( aWindowState
[n
].Name
== WINDOWSTATE_PROPERTY_SOFTCLOSE
)
590 if ( aWindowState
[n
].Value
>>= bValue
)
591 rElementData
.m_bSoftClose
= bValue
;
596 // oversteer values with global settings
597 if ( pGlobalSettings
&& ( bGetSettingsState
|| bGlobalSettings
))
599 if ( pGlobalSettings
->HasStatesInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR
))
601 SolarMutexClearableGuard aWriteLock2
;
602 bInGlobalSettings
= true;
606 if ( pGlobalSettings
->GetStateInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR
,
607 GlobalSettings::STATEINFO_LOCKED
,
609 aValue
>>= rElementData
.m_aDockedData
.m_bLocked
;
610 if ( pGlobalSettings
->GetStateInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR
,
611 GlobalSettings::STATEINFO_DOCKED
,
615 if ( aValue
>>= bValue
)
616 rElementData
.m_bFloating
= !bValue
;
623 catch (const NoSuchElementException
&)
631 void LayoutManager::implts_writeWindowStateData( const OUString
& aName
, const UIElement
& rElementData
)
633 SolarMutexResettableGuard aWriteLock
;
634 Reference
< XNameAccess
> xPersistentWindowState( m_xPersistentWindowState
);
636 // set flag to determine that we triggered the notification
637 m_bStoreWindowState
= true;
640 bool bPersistent( false );
641 Reference
< XPropertySet
> xPropSet( rElementData
.m_xUIElement
, UNO_QUERY
);
646 // Check persistent flag of the user interface element
647 xPropSet
->getPropertyValue("Persistent") >>= bPersistent
;
649 catch (const beans::UnknownPropertyException
&)
651 // Non-configurable elements should at least store their dimension/position
654 catch (const lang::WrappedTargetException
&)
659 if ( bPersistent
&& xPersistentWindowState
.is() )
663 Sequence
< PropertyValue
> aWindowState( 8 );
665 aWindowState
[0].Name
= WINDOWSTATE_PROPERTY_DOCKED
;
666 aWindowState
[0].Value
= makeAny( !rElementData
.m_bFloating
);
667 aWindowState
[1].Name
= WINDOWSTATE_PROPERTY_VISIBLE
;
668 aWindowState
[1].Value
= makeAny( rElementData
.m_bVisible
);
670 aWindowState
[2].Name
= WINDOWSTATE_PROPERTY_DOCKINGAREA
;
671 aWindowState
[2].Value
= makeAny( static_cast< DockingArea
>( rElementData
.m_aDockedData
.m_nDockedArea
) );
673 aWindowState
[3].Name
= WINDOWSTATE_PROPERTY_DOCKPOS
;
674 aWindowState
[3].Value
<<= rElementData
.m_aDockedData
.m_aPos
;
676 aWindowState
[4].Name
= WINDOWSTATE_PROPERTY_POS
;
677 aWindowState
[4].Value
<<= rElementData
.m_aFloatingData
.m_aPos
;
679 aWindowState
[5].Name
= WINDOWSTATE_PROPERTY_SIZE
;
680 aWindowState
[5].Value
<<= rElementData
.m_aFloatingData
.m_aSize
;
681 aWindowState
[6].Name
= WINDOWSTATE_PROPERTY_UINAME
;
682 aWindowState
[6].Value
= makeAny( rElementData
.m_aUIName
);
683 aWindowState
[7].Name
= WINDOWSTATE_PROPERTY_LOCKED
;
684 aWindowState
[7].Value
= makeAny( rElementData
.m_aDockedData
.m_bLocked
);
686 if ( xPersistentWindowState
->hasByName( aName
))
688 Reference
< XNameReplace
> xReplace( xPersistentWindowState
, uno::UNO_QUERY
);
689 xReplace
->replaceByName( aName
, makeAny( aWindowState
));
693 Reference
< XNameContainer
> xInsert( xPersistentWindowState
, uno::UNO_QUERY
);
694 xInsert
->insertByName( aName
, makeAny( aWindowState
));
697 catch (const Exception
&)
704 m_bStoreWindowState
= false;
708 ::Size
LayoutManager::implts_getContainerWindowOutputSize()
710 ::Size aContainerWinSize
;
711 vcl::Window
* pContainerWindow( 0 );
713 // Retrieve output size from container Window
714 SolarMutexGuard aGuard
;
715 pContainerWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
716 if ( pContainerWindow
)
717 aContainerWinSize
= pContainerWindow
->GetOutputSizePixel();
719 return aContainerWinSize
;
722 Reference
< XUIElement
> LayoutManager::implts_createElement( const OUString
& aName
)
724 Reference
< ui::XUIElement
> xUIElement
;
727 Sequence
< PropertyValue
> aPropSeq( 2 );
728 aPropSeq
[0].Name
= "Frame";
729 aPropSeq
[0].Value
<<= m_xFrame
;
730 aPropSeq
[1].Name
= "Persistent";
731 aPropSeq
[1].Value
<<= sal_True
;
735 xUIElement
= m_xUIElementFactoryManager
->createUIElement( aName
, aPropSeq
);
737 catch (const NoSuchElementException
&)
740 catch (const IllegalArgumentException
&)
747 void LayoutManager::implts_setVisibleState( bool bShow
)
749 SolarMutexClearableGuard aWriteLock
;
750 m_aStatusBarElement
.m_bMasterHide
= !bShow
;
753 implts_updateUIElementsVisibleState( bShow
);
756 void LayoutManager::implts_updateUIElementsVisibleState( bool bSetVisible
)
761 implts_notifyListeners( frame::LayoutManagerEvents::VISIBLE
, a
);
763 implts_notifyListeners( frame::LayoutManagerEvents::INVISIBLE
, a
);
765 SolarMutexResettableGuard aWriteLock
;
766 Reference
< XUIElement
> xMenuBar( m_xMenuBar
, UNO_QUERY
);
767 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
768 Reference
< XComponent
> xInplaceMenuBar( m_xInplaceMenuBar
);
769 MenuBarManager
* pInplaceMenuBar( m_pInplaceMenuBar
);
772 if (( xMenuBar
.is() || xInplaceMenuBar
.is() ) && xContainerWindow
.is() )
774 SolarMutexGuard aGuard
;
776 MenuBar
* pMenuBar( 0 );
777 if ( xInplaceMenuBar
.is() )
778 pMenuBar
= static_cast<MenuBar
*>(pInplaceMenuBar
->GetMenuBar());
781 MenuBarWrapper
* pMenuBarWrapper
= (static_cast< MenuBarWrapper
* >(xMenuBar
.get()) );
782 pMenuBar
= static_cast<MenuBar
*>(pMenuBarWrapper
->GetMenuBarManager()->GetMenuBar());
785 SystemWindow
* pSysWindow
= getTopSystemWindow( xContainerWindow
);
789 pSysWindow
->SetMenuBar(pMenuBar
, m_xFrame
);
791 pSysWindow
->SetMenuBar( 0 );
796 // Hide/show the statusbar according to bSetVisible
798 bMustDoLayout
= !implts_showStatusBar();
800 bMustDoLayout
= !implts_hideStatusBar();
803 ToolbarLayoutManager
* pToolbarManager( m_pToolbarManager
);
806 if ( pToolbarManager
)
808 pToolbarManager
->setVisible( bSetVisible
);
809 bMustDoLayout
= pToolbarManager
->isLayoutDirty();
813 implts_doLayout_notify( false );
816 void LayoutManager::implts_setCurrentUIVisibility( bool bShow
)
818 SolarMutexClearableGuard aWriteLock
;
819 if ( !bShow
&& m_aStatusBarElement
.m_bVisible
&& m_aStatusBarElement
.m_xUIElement
.is() )
820 m_aStatusBarElement
.m_bMasterHide
= true;
821 else if ( bShow
&& m_aStatusBarElement
.m_bVisible
)
822 m_aStatusBarElement
.m_bMasterHide
= false;
825 implts_updateUIElementsVisibleState( bShow
);
828 void LayoutManager::implts_destroyStatusBar()
830 Reference
< XComponent
> xCompStatusBar
;
832 SolarMutexClearableGuard aWriteLock
;
833 m_aStatusBarElement
.m_aName
.clear();
834 xCompStatusBar
= Reference
< XComponent
>( m_aStatusBarElement
.m_xUIElement
, UNO_QUERY
);
835 m_aStatusBarElement
.m_xUIElement
.clear();
838 if ( xCompStatusBar
.is() )
839 xCompStatusBar
->dispose();
841 implts_destroyProgressBar();
844 void LayoutManager::implts_createStatusBar( const OUString
& aStatusBarName
)
846 SolarMutexClearableGuard aWriteLock
;
847 if ( !m_aStatusBarElement
.m_xUIElement
.is() )
849 implts_readStatusBarState( aStatusBarName
);
850 m_aStatusBarElement
.m_aName
= aStatusBarName
;
851 m_aStatusBarElement
.m_xUIElement
= implts_createElement( aStatusBarName
);
855 implts_createProgressBar();
858 void LayoutManager::implts_readStatusBarState( const OUString
& rStatusBarName
)
861 if ( !m_aStatusBarElement
.m_bStateRead
)
863 // Read persistent data for status bar if not yet read!
864 if ( implts_readWindowStateData( rStatusBarName
, m_aStatusBarElement
))
865 m_aStatusBarElement
.m_bStateRead
= true;
869 void LayoutManager::implts_createProgressBar()
871 Reference
< XUIElement
> xStatusBar
;
872 Reference
< XUIElement
> xProgressBar
;
873 Reference
< XUIElement
> xProgressBarBackup
;
874 Reference
< awt::XWindow
> xContainerWindow
;
876 SolarMutexResettableGuard aWriteLock
;
877 xStatusBar
= Reference
< XUIElement
>( m_aStatusBarElement
.m_xUIElement
, UNO_QUERY
);
878 xProgressBar
= Reference
< XUIElement
>( m_aProgressBarElement
.m_xUIElement
, UNO_QUERY
);
879 xProgressBarBackup
= m_xProgressBarBackup
;
880 m_xProgressBarBackup
.clear();
881 xContainerWindow
= m_xContainerWindow
;
884 bool bRecycled
= xProgressBarBackup
.is();
885 ProgressBarWrapper
* pWrapper
= 0;
887 pWrapper
= static_cast<ProgressBarWrapper
*>(xProgressBarBackup
.get());
888 else if ( xProgressBar
.is() )
889 pWrapper
= static_cast<ProgressBarWrapper
*>(xProgressBar
.get());
891 pWrapper
= new ProgressBarWrapper();
893 if ( xStatusBar
.is() )
895 Reference
< awt::XWindow
> xWindow( xStatusBar
->getRealInterface(), UNO_QUERY
);
896 pWrapper
->setStatusBar( xWindow
);
900 Reference
< awt::XWindow
> xStatusBarWindow
= pWrapper
->getStatusBar();
902 SolarMutexGuard aGuard
;
903 vcl::Window
* pStatusBarWnd
= VCLUnoHelper::GetWindow( xStatusBarWindow
);
904 if ( !pStatusBarWnd
)
906 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow( xContainerWindow
);
909 VclPtrInstance
<StatusBar
> pStatusBar( pWindow
, WinBits( WB_LEFT
| WB_3DLOOK
) );
910 Reference
< awt::XWindow
> xStatusBarWindow2( VCLUnoHelper::GetInterface( pStatusBar
));
911 pWrapper
->setStatusBar( xStatusBarWindow2
, true );
916 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
918 m_aProgressBarElement
.m_xUIElement
= Reference
< XUIElement
>(
919 static_cast< cppu::OWeakObject
* >( pWrapper
), UNO_QUERY
);
921 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
924 implts_showProgressBar();
927 void LayoutManager::implts_backupProgressBarWrapper()
931 if (m_xProgressBarBackup
.is())
934 // safe a backup copy of the current progress!
935 // This copy will be used automatically inside createProgressBar() which is called
936 // implictly from implts_doLayout() .-)
937 m_xProgressBarBackup
= m_aProgressBarElement
.m_xUIElement
;
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 if ( m_xProgressBarBackup
.is() )
944 ProgressBarWrapper
* pWrapper
= static_cast<ProgressBarWrapper
*>(m_xProgressBarBackup
.get());
946 pWrapper
->setStatusBar( Reference
< awt::XWindow
>(), false );
949 // prevent us from dispose() the m_aProgressBarElement.m_xUIElement inside implts_reset()
950 m_aProgressBarElement
.m_xUIElement
.clear();
953 void LayoutManager::implts_destroyProgressBar()
955 // dont remove the progressbar in general
956 // We must reuse it if a new status bar is created later.
957 // Of course there exists one backup only.
958 // And further this backup will be released inside our dtor.
959 implts_backupProgressBarWrapper();
962 void LayoutManager::implts_setStatusBarPosSize( const ::Point
& rPos
, const ::Size
& rSize
)
964 Reference
< XUIElement
> xStatusBar
;
965 Reference
< XUIElement
> xProgressBar
;
966 Reference
< awt::XWindow
> xContainerWindow
;
968 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
969 SolarMutexClearableGuard aReadLock
;
970 xStatusBar
= Reference
< XUIElement
>( m_aStatusBarElement
.m_xUIElement
, UNO_QUERY
);
971 xProgressBar
= Reference
< XUIElement
>( m_aProgressBarElement
.m_xUIElement
, UNO_QUERY
);
972 xContainerWindow
= m_xContainerWindow
;
974 Reference
< awt::XWindow
> xWindow
;
975 if ( xStatusBar
.is() )
976 xWindow
= Reference
< awt::XWindow
>( xStatusBar
->getRealInterface(), UNO_QUERY
);
977 else if ( xProgressBar
.is() )
979 ProgressBarWrapper
* pWrapper
= static_cast<ProgressBarWrapper
*>(xProgressBar
.get());
981 xWindow
= pWrapper
->getStatusBar();
984 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
988 SolarMutexGuard aGuard
;
989 vcl::Window
* pParentWindow
= VCLUnoHelper::GetWindow( xContainerWindow
);
990 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
991 if ( pParentWindow
&& ( pWindow
&& pWindow
->GetType() == WINDOW_STATUSBAR
))
993 vcl::Window
* pOldParentWindow
= pWindow
->GetParent();
994 if ( pParentWindow
!= pOldParentWindow
)
995 pWindow
->SetParent( pParentWindow
);
996 static_cast<StatusBar
*>(pWindow
)->SetPosSizePixel( rPos
, rSize
);
1001 bool LayoutManager::implts_showProgressBar()
1003 Reference
< XUIElement
> xStatusBar
;
1004 Reference
< XUIElement
> xProgressBar
;
1005 Reference
< awt::XWindow
> xWindow
;
1007 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1008 SolarMutexClearableGuard aWriteLock
;
1009 xStatusBar
= Reference
< XUIElement
>( m_aStatusBarElement
.m_xUIElement
, UNO_QUERY
);
1010 xProgressBar
= Reference
< XUIElement
>( m_aProgressBarElement
.m_xUIElement
, UNO_QUERY
);
1011 bool bVisible( m_bVisible
);
1013 m_aProgressBarElement
.m_bVisible
= true;
1016 if ( xStatusBar
.is() && !m_aStatusBarElement
.m_bMasterHide
)
1018 xWindow
= Reference
< awt::XWindow
>( xStatusBar
->getRealInterface(), UNO_QUERY
);
1020 else if ( xProgressBar
.is() )
1022 ProgressBarWrapper
* pWrapper
= static_cast<ProgressBarWrapper
*>(xProgressBar
.get());
1024 xWindow
= pWrapper
->getStatusBar();
1028 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1030 SolarMutexGuard aGuard
;
1031 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
1034 if ( !pWindow
->IsVisible() )
1036 implts_setOffset( pWindow
->GetSizePixel().Height() );
1038 implts_doLayout_notify( false );
1046 bool LayoutManager::implts_hideProgressBar()
1048 Reference
< XUIElement
> xProgressBar
;
1049 Reference
< awt::XWindow
> xWindow
;
1050 bool bHideStatusBar( false );
1053 xProgressBar
= Reference
< XUIElement
>( m_aProgressBarElement
.m_xUIElement
, UNO_QUERY
);
1055 bool bInternalStatusBar( false );
1056 if ( xProgressBar
.is() )
1058 Reference
< awt::XWindow
> xStatusBar
;
1059 ProgressBarWrapper
* pWrapper
= static_cast<ProgressBarWrapper
*>(xProgressBar
.get());
1061 xWindow
= pWrapper
->getStatusBar();
1062 Reference
< ui::XUIElement
> xStatusBarElement
= m_aStatusBarElement
.m_xUIElement
;
1063 if ( xStatusBarElement
.is() )
1064 xStatusBar
= Reference
< awt::XWindow
>( xStatusBarElement
->getRealInterface(), UNO_QUERY
);
1065 bInternalStatusBar
= xStatusBar
!= xWindow
;
1067 m_aProgressBarElement
.m_bVisible
= false;
1068 implts_readStatusBarState( STATUS_BAR_ALIAS
);
1069 bHideStatusBar
= !m_aStatusBarElement
.m_bVisible
;
1071 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
1072 if ( pWindow
&& pWindow
->IsVisible() && ( bHideStatusBar
|| bInternalStatusBar
))
1074 implts_setOffset( 0 );
1076 implts_doLayout_notify( false );
1083 bool LayoutManager::implts_showStatusBar( bool bStoreState
)
1085 SolarMutexClearableGuard aWriteLock
;
1086 Reference
< ui::XUIElement
> xStatusBar
= m_aStatusBarElement
.m_xUIElement
;
1088 m_aStatusBarElement
.m_bVisible
= true;
1091 if ( xStatusBar
.is() )
1093 Reference
< awt::XWindow
> xWindow( xStatusBar
->getRealInterface(), UNO_QUERY
);
1095 SolarMutexGuard aGuard
;
1096 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
1097 if ( pWindow
&& !pWindow
->IsVisible() )
1099 implts_setOffset( pWindow
->GetSizePixel().Height() );
1101 implts_doLayout_notify( false );
1109 bool LayoutManager::implts_hideStatusBar( bool bStoreState
)
1111 SolarMutexClearableGuard aWriteLock
;
1112 Reference
< ui::XUIElement
> xStatusBar
= m_aStatusBarElement
.m_xUIElement
;
1114 m_aStatusBarElement
.m_bVisible
= false;
1117 if ( xStatusBar
.is() )
1119 Reference
< awt::XWindow
> xWindow( xStatusBar
->getRealInterface(), UNO_QUERY
);
1121 SolarMutexGuard aGuard
;
1122 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
1123 if ( pWindow
&& pWindow
->IsVisible() )
1125 implts_setOffset( 0 );
1127 implts_doLayout_notify( false );
1135 void LayoutManager::implts_setOffset( const sal_Int32 nBottomOffset
)
1137 ::Rectangle aOffsetRect
;
1138 setZeroRectangle( aOffsetRect
);
1139 aOffsetRect
.setHeight( nBottomOffset
);
1141 if ( m_pToolbarManager
)
1142 m_pToolbarManager
->setDockingAreaOffsets( aOffsetRect
);
1145 void LayoutManager::implts_setInplaceMenuBar( const Reference
< XIndexAccess
>& xMergedMenuBar
)
1146 throw (uno::RuntimeException
)
1148 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1149 SolarMutexClearableGuard aWriteLock
;
1151 if ( !m_bInplaceMenuSet
)
1153 SolarMutexGuard aGuard
;
1155 // Reset old inplace menubar!
1156 m_pInplaceMenuBar
= 0;
1157 if ( m_xInplaceMenuBar
.is() )
1158 m_xInplaceMenuBar
->dispose();
1159 m_xInplaceMenuBar
.clear();
1160 m_bInplaceMenuSet
= false;
1162 if ( m_xFrame
.is() && m_xContainerWindow
.is() )
1164 OUString aModuleIdentifier
;
1165 Reference
< XDispatchProvider
> xDispatchProvider
;
1167 MenuBar
* pMenuBar
= new MenuBar
;
1168 m_pInplaceMenuBar
= new MenuBarManager( m_xContext
, m_xFrame
, m_xURLTransformer
, xDispatchProvider
, aModuleIdentifier
, pMenuBar
, true, true );
1169 m_pInplaceMenuBar
->SetItemContainer( xMergedMenuBar
);
1171 SystemWindow
* pSysWindow
= getTopSystemWindow( m_xContainerWindow
);
1173 pSysWindow
->SetMenuBar(pMenuBar
, m_xFrame
);
1175 m_bInplaceMenuSet
= true;
1176 m_xInplaceMenuBar
= Reference
< XComponent
>( (OWeakObject
*)m_pInplaceMenuBar
, UNO_QUERY
);
1180 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1182 implts_updateMenuBarClose();
1186 void LayoutManager::implts_resetInplaceMenuBar()
1187 throw (uno::RuntimeException
)
1190 m_bInplaceMenuSet
= false;
1192 if ( m_xContainerWindow
.is() )
1194 SolarMutexGuard aGuard
;
1195 MenuBarWrapper
* pMenuBarWrapper
= (static_cast< MenuBarWrapper
* >(m_xMenuBar
.get()) );
1196 SystemWindow
* pSysWindow
= getTopSystemWindow( m_xContainerWindow
);
1199 if ( pMenuBarWrapper
)
1200 pSysWindow
->SetMenuBar(static_cast<MenuBar
*>(pMenuBarWrapper
->GetMenuBarManager()->GetMenuBar()), m_xFrame
);
1202 pSysWindow
->SetMenuBar(0);
1206 // Remove inplace menu bar
1207 m_pInplaceMenuBar
= 0;
1208 if ( m_xInplaceMenuBar
.is() )
1209 m_xInplaceMenuBar
->dispose();
1210 m_xInplaceMenuBar
.clear();
1213 void SAL_CALL
LayoutManager::attachFrame( const Reference
< XFrame
>& xFrame
)
1214 throw (uno::RuntimeException
, std::exception
)
1220 void SAL_CALL
LayoutManager::reset()
1221 throw (RuntimeException
, std::exception
)
1223 implts_reset( true );
1226 // XMenuBarMergingAcceptor
1228 sal_Bool SAL_CALL
LayoutManager::setMergedMenuBar(
1229 const Reference
< XIndexAccess
>& xMergedMenuBar
)
1230 throw (uno::RuntimeException
, std::exception
)
1232 implts_setInplaceMenuBar( xMergedMenuBar
);
1235 implts_notifyListeners( frame::LayoutManagerEvents::MERGEDMENUBAR
, a
);
1239 void SAL_CALL
LayoutManager::removeMergedMenuBar()
1240 throw (uno::RuntimeException
, std::exception
)
1242 implts_resetInplaceMenuBar();
1245 awt::Rectangle SAL_CALL
LayoutManager::getCurrentDockingArea()
1246 throw ( RuntimeException
, std::exception
)
1249 return m_aDockingArea
;
1252 Reference
< XDockingAreaAcceptor
> SAL_CALL
LayoutManager::getDockingAreaAcceptor()
1253 throw (uno::RuntimeException
, std::exception
)
1256 return m_xDockingAreaAcceptor
;
1259 void SAL_CALL
LayoutManager::setDockingAreaAcceptor( const Reference
< ui::XDockingAreaAcceptor
>& xDockingAreaAcceptor
)
1260 throw ( RuntimeException
, std::exception
)
1262 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1263 SolarMutexClearableGuard aWriteLock
;
1265 if (( m_xDockingAreaAcceptor
== xDockingAreaAcceptor
) || !m_xFrame
.is() )
1268 // IMPORTANT: Be sure to stop layout timer if don't have a docking area acceptor!
1269 if ( !xDockingAreaAcceptor
.is() )
1270 m_aAsyncLayoutTimer
.Stop();
1272 bool bAutomaticToolbars( m_bAutomaticToolbars
);
1273 std::vector
< Reference
< awt::XWindow
> > oldDockingAreaWindows
;
1275 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
1277 if ( !xDockingAreaAcceptor
.is() )
1278 m_aAsyncLayoutTimer
.Stop();
1280 // Remove listener from old docking area acceptor
1281 if ( m_xDockingAreaAcceptor
.is() )
1283 Reference
< awt::XWindow
> xWindow( m_xDockingAreaAcceptor
->getContainerWindow() );
1284 if ( xWindow
.is() && ( m_xFrame
->getContainerWindow() != m_xContainerWindow
|| !xDockingAreaAcceptor
.is() ) )
1285 xWindow
->removeWindowListener( Reference
< awt::XWindowListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
1287 m_aDockingArea
= awt::Rectangle();
1288 if ( pToolbarManager
)
1289 pToolbarManager
->resetDockingArea();
1291 vcl::Window
* pContainerWindow
= VCLUnoHelper::GetWindow( xWindow
);
1292 if ( pContainerWindow
)
1293 pContainerWindow
->RemoveChildEventListener( LINK( this, LayoutManager
, WindowEventListener
) );
1296 Reference
< ui::XDockingAreaAcceptor
> xOldDockingAreaAcceptor( m_xDockingAreaAcceptor
);
1297 m_xDockingAreaAcceptor
= xDockingAreaAcceptor
;
1298 if ( m_xDockingAreaAcceptor
.is() )
1300 m_aDockingArea
= awt::Rectangle();
1301 m_xContainerWindow
= m_xDockingAreaAcceptor
->getContainerWindow();
1302 m_xContainerTopWindow
.set( m_xContainerWindow
, UNO_QUERY
);
1303 m_xContainerWindow
->addWindowListener( Reference
< awt::XWindowListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
1305 // we always must keep a connection to the window of our frame for resize events
1306 if ( m_xContainerWindow
!= m_xFrame
->getContainerWindow() )
1307 m_xFrame
->getContainerWindow()->addWindowListener( Reference
< awt::XWindowListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
1309 // #i37884# set initial visibility state - in the plugin case the container window is already shown
1310 // and we get no notification anymore
1312 SolarMutexGuard aGuard
;
1313 vcl::Window
* pContainerWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
1314 if( pContainerWindow
)
1315 m_bParentWindowVisible
= pContainerWindow
->IsVisible();
1318 uno::Reference
< awt::XWindowPeer
> xParent( m_xContainerWindow
, UNO_QUERY
);
1322 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1324 if ( xDockingAreaAcceptor
.is() )
1326 SolarMutexGuard aGuard
;
1328 // Add layout manager as listener to get notifications about toolbar button activties
1329 vcl::Window
* pContainerWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
1330 if ( pContainerWindow
)
1331 pContainerWindow
->AddChildEventListener( LINK( this, LayoutManager
, WindowEventListener
) );
1333 // We have now a new container window, reparent all child windows!
1334 implts_reparentChildWindows();
1337 implts_destroyElements(); // remove all elements
1339 if ( !oldDockingAreaWindows
.empty() )
1341 // Reset docking area size for our old docking area acceptor
1342 awt::Rectangle aEmptyRect
;
1343 xOldDockingAreaAcceptor
->setDockingAreaSpace( aEmptyRect
);
1346 if ( pToolbarManager
&& xDockingAreaAcceptor
.is() )
1348 if ( bAutomaticToolbars
)
1351 pToolbarManager
->createStaticToolbars();
1354 implts_doLayout( true, false );
1358 void LayoutManager::implts_reparentChildWindows()
1360 SolarMutexResettableGuard aWriteLock
;
1361 UIElement aStatusBarElement
= m_aStatusBarElement
;
1362 uno::Reference
< awt::XWindow
> xContainerWindow
= m_xContainerWindow
;
1365 uno::Reference
< awt::XWindow
> xStatusBarWindow
;
1366 if ( aStatusBarElement
.m_xUIElement
.is() )
1370 xStatusBarWindow
= Reference
< awt::XWindow
>( aStatusBarElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
1372 catch (const RuntimeException
&)
1376 catch (const Exception
&)
1381 if ( xStatusBarWindow
.is() )
1383 SolarMutexGuard aGuard
;
1384 vcl::Window
* pContainerWindow
= VCLUnoHelper::GetWindow( xContainerWindow
);
1385 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow( xStatusBarWindow
);
1386 if ( pWindow
&& pContainerWindow
)
1387 pWindow
->SetParent( pContainerWindow
);
1390 implts_resetMenuBar();
1393 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
1394 if ( pToolbarManager
)
1395 pToolbarManager
->setParentWindow( uno::Reference
< awt::XWindowPeer
>( xContainerWindow
, uno::UNO_QUERY
));
1399 uno::Reference
< ui::XUIElement
> LayoutManager::implts_createDockingWindow( const OUString
& aElementName
)
1401 Reference
< XUIElement
> xUIElement
= implts_createElement( aElementName
);
1405 IMPL_LINK( LayoutManager
, WindowEventListener
, VclSimpleEvent
*, pEvent
)
1409 if ( pEvent
&& pEvent
->ISA( VclWindowEvent
))
1411 vcl::Window
* pWindow
= static_cast< VclWindowEvent
* >(pEvent
)->GetWindow();
1412 if ( pWindow
&& pWindow
->GetType() == WINDOW_TOOLBOX
)
1414 SolarMutexClearableGuard aReadLock
;
1415 ToolbarLayoutManager
* pToolbarManager( m_pToolbarManager
);
1418 if ( pToolbarManager
)
1419 nResult
= pToolbarManager
->childWindowEvent( pEvent
);
1426 void SAL_CALL
LayoutManager::createElement( const OUString
& aName
)
1427 throw (RuntimeException
, std::exception
)
1429 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::createElement" );
1431 SolarMutexClearableGuard aReadLock
;
1432 Reference
< XFrame
> xFrame
= m_xFrame
;
1433 Reference
< XURLTransformer
> xURLTransformer
= m_xURLTransformer
;
1434 bool bInPlaceMenu
= m_bInplaceMenuSet
;
1440 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1441 SolarMutexClearableGuard aWriteLock
;
1443 bool bMustBeLayouted( false );
1444 bool bNotify( false );
1447 if (m_pToolbarManager
)
1448 // Assumes that we created the ToolbarLayoutManager with our frame, if
1449 // not then we're somewhat fouled up ...
1450 bPreviewFrame
= m_pToolbarManager
->isPreviewFrame();
1453 Reference
< XModel
> xModel( impl_getModelFromFrame( xFrame
) );
1454 bPreviewFrame
= implts_isPreviewModel( xModel
);
1457 if ( m_xContainerWindow
.is() && !bPreviewFrame
) // no UI elements on preview frames
1459 OUString aElementType
;
1460 OUString aElementName
;
1462 parseResourceURL( aName
, aElementType
, aElementName
);
1464 if ( aElementType
.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
) && m_pToolbarManager
!= NULL
)
1466 bNotify
= m_pToolbarManager
->createToolbar( aName
);
1467 bMustBeLayouted
= m_pToolbarManager
->isLayoutDirty();
1469 else if ( aElementType
.equalsIgnoreAsciiCase("menubar") &&
1470 aElementName
.equalsIgnoreAsciiCase("menubar") )
1472 // #i38743# don't create a menubar if frame isn't top
1473 if ( !bInPlaceMenu
&& !m_xMenuBar
.is() && implts_isFrameOrWindowTop( xFrame
))
1475 m_xMenuBar
= implts_createElement( aName
);
1476 if ( m_xMenuBar
.is() )
1478 SolarMutexGuard aGuard
;
1480 SystemWindow
* pSysWindow
= getTopSystemWindow( m_xContainerWindow
);
1483 Reference
< awt::XMenuBar
> xMenuBar
;
1485 Reference
< XPropertySet
> xPropSet( m_xMenuBar
, UNO_QUERY
);
1486 if ( xPropSet
.is() )
1490 xPropSet
->getPropertyValue("XMenuBar") >>= xMenuBar
;
1492 catch (const beans::UnknownPropertyException
&)
1495 catch (const lang::WrappedTargetException
&)
1500 if ( xMenuBar
.is() )
1502 VCLXMenu
* pAwtMenuBar
= VCLXMenu::GetImplementation( xMenuBar
);
1505 MenuBar
* pMenuBar
= static_cast<MenuBar
*>(pAwtMenuBar
->GetMenu());
1508 pSysWindow
->SetMenuBar(pMenuBar
, m_xFrame
);
1509 pMenuBar
->SetDisplayable( m_bMenuVisible
);
1510 if ( m_bMenuVisible
)
1512 implts_updateMenuBarClose();
1521 else if ( aElementType
.equalsIgnoreAsciiCase("statusbar") &&
1522 ( implts_isFrameOrWindowTop(xFrame
) || implts_isEmbeddedLayoutManager() ))
1524 implts_createStatusBar( aName
);
1527 else if ( aElementType
.equalsIgnoreAsciiCase("progressbar") &&
1528 aElementName
.equalsIgnoreAsciiCase("progressbar") &&
1529 implts_isFrameOrWindowTop(xFrame
) )
1531 implts_createProgressBar();
1534 else if ( aElementType
.equalsIgnoreAsciiCase("dockingwindow"))
1536 // Add layout manager as listener for docking and other window events
1537 uno::Reference
< uno::XInterface
> xThis( static_cast< OWeakObject
* >(this), uno::UNO_QUERY
);
1538 uno::Reference
< ui::XUIElement
> xUIElement( implts_createDockingWindow( aName
));
1540 if ( xUIElement
.is() )
1542 impl_addWindowListeners( xThis
, xUIElement
);
1545 // The docking window is created by a factory method located in the sfx2 library.
1546 // CreateDockingWindow( xFrame, aElementName );
1550 if ( bMustBeLayouted
)
1551 implts_doLayout_notify( true );
1555 // UI element is invisible - provide information to listeners
1556 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE
, uno::makeAny( aName
) );
1560 void SAL_CALL
LayoutManager::destroyElement( const OUString
& aName
)
1561 throw (RuntimeException
, std::exception
)
1563 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::destroyElement" );
1565 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1566 SolarMutexClearableGuard aWriteLock
;
1568 bool bMustBeLayouted( false );
1569 bool bNotify( false );
1570 OUString aElementType
;
1571 OUString aElementName
;
1573 Reference
< XComponent
> xComponent
;
1574 parseResourceURL( aName
, aElementType
, aElementName
);
1576 if ( aElementType
.equalsIgnoreAsciiCase("menubar") &&
1577 aElementName
.equalsIgnoreAsciiCase("menubar") )
1579 if ( !m_bInplaceMenuSet
)
1581 impl_clearUpMenuBar();
1586 else if (( aElementType
.equalsIgnoreAsciiCase("statusbar") &&
1587 aElementName
.equalsIgnoreAsciiCase("statusbar") ) ||
1588 ( m_aStatusBarElement
.m_aName
== aName
))
1591 implts_destroyStatusBar();
1592 bMustBeLayouted
= true;
1595 else if ( aElementType
.equalsIgnoreAsciiCase("progressbar") &&
1596 aElementName
.equalsIgnoreAsciiCase("progressbar") )
1599 implts_createProgressBar();
1600 bMustBeLayouted
= true;
1603 else if ( aElementType
.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
) && m_pToolbarManager
!= NULL
)
1606 bNotify
= m_pToolbarManager
->destroyToolbar( aName
);
1607 bMustBeLayouted
= m_pToolbarManager
->isLayoutDirty();
1609 else if ( aElementType
.equalsIgnoreAsciiCase("dockingwindow"))
1611 uno::Reference
< frame::XFrame
> xFrame( m_xFrame
);
1612 uno::Reference
< XComponentContext
> xContext( m_xContext
);
1615 impl_setDockingWindowVisibility( xContext
, xFrame
, aElementName
, false );
1616 bMustBeLayouted
= false;
1620 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1622 if ( bMustBeLayouted
)
1626 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_INVISIBLE
, uno::makeAny( aName
) );
1629 sal_Bool SAL_CALL
LayoutManager::requestElement( const OUString
& rResourceURL
)
1630 throw (uno::RuntimeException
, std::exception
)
1632 bool bResult( false );
1633 bool bNotify( false );
1634 OUString aElementType
;
1635 OUString aElementName
;
1637 parseResourceURL( rResourceURL
, aElementType
, aElementName
);
1639 SolarMutexClearableGuard aWriteLock
;
1641 OString aResName
= OUStringToOString( aElementName
, RTL_TEXTENCODING_ASCII_US
);
1642 SAL_INFO( "fwk", "framework (cd100003) Element " << aResName
.getStr() << " requested." );
1644 if (( aElementType
.equalsIgnoreAsciiCase("statusbar") &&
1645 aElementName
.equalsIgnoreAsciiCase("statusbar") ) ||
1646 ( m_aStatusBarElement
.m_aName
== rResourceURL
))
1648 implts_readStatusBarState( rResourceURL
);
1649 if ( m_aStatusBarElement
.m_bVisible
&& !m_aStatusBarElement
.m_bMasterHide
)
1652 createElement( rResourceURL
);
1654 // There are some situation where we are not able to create an element.
1655 // Therefore we have to check the reference before further action.
1657 uno::Reference
< ui::XUIElement
> xUIElement( m_aStatusBarElement
.m_xUIElement
);
1658 if ( xUIElement
.is() )
1660 // we need VCL here to pass special flags to Show()
1661 SolarMutexGuard aGuard
;
1662 Reference
< awt::XWindow
> xWindow( xUIElement
->getRealInterface(), UNO_QUERY
);
1663 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
1666 pWindow
->Show( true, SHOW_NOFOCUSCHANGE
| SHOW_NOACTIVATE
);
1673 else if ( aElementType
.equalsIgnoreAsciiCase("progressbar") &&
1674 aElementName
.equalsIgnoreAsciiCase("progressbar") )
1677 implts_showProgressBar();
1681 else if ( aElementType
.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
) && m_bVisible
)
1683 bool bComponentAttached( !m_aModuleIdentifier
.isEmpty() );
1684 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
1687 if ( pToolbarManager
&& bComponentAttached
)
1689 bNotify
= pToolbarManager
->requestToolbar( rResourceURL
);
1692 else if ( aElementType
.equalsIgnoreAsciiCase("dockingwindow"))
1694 uno::Reference
< frame::XFrame
> xFrame( m_xFrame
);
1697 CreateDockingWindow( xFrame
, aElementName
);
1701 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE
, uno::makeAny( rResourceURL
) );
1706 Reference
< XUIElement
> SAL_CALL
LayoutManager::getElement( const OUString
& aName
)
1707 throw (RuntimeException
, std::exception
)
1709 Reference
< XUIElement
> xUIElement
= implts_findElement( aName
);
1710 if ( !xUIElement
.is() )
1712 SolarMutexClearableGuard aReadLock
;
1713 ToolbarLayoutManager
* pToolbarManager( m_pToolbarManager
);
1716 if ( pToolbarManager
)
1717 xUIElement
= pToolbarManager
->getToolbar( aName
);
1723 Sequence
< Reference
< ui::XUIElement
> > SAL_CALL
LayoutManager::getElements()
1724 throw (uno::RuntimeException
, std::exception
)
1726 SolarMutexClearableGuard aReadLock
;
1727 uno::Reference
< ui::XUIElement
> xMenuBar( m_xMenuBar
);
1728 uno::Reference
< ui::XUIElement
> xStatusBar( m_aStatusBarElement
.m_xUIElement
);
1729 ToolbarLayoutManager
* pToolbarManager( m_pToolbarManager
);
1732 Sequence
< Reference
< ui::XUIElement
> > aSeq
;
1733 if ( pToolbarManager
)
1734 aSeq
= pToolbarManager
->getToolbars();
1736 sal_Int32 nSize
= aSeq
.getLength();
1737 sal_Int32
nMenuBarIndex(-1);
1738 sal_Int32
nStatusBarIndex(-1);
1739 if ( xMenuBar
.is() )
1741 nMenuBarIndex
= nSize
;
1744 if ( xStatusBar
.is() )
1746 nStatusBarIndex
= nSize
;
1750 aSeq
.realloc(nSize
);
1751 if ( nMenuBarIndex
>= 0 )
1752 aSeq
[nMenuBarIndex
] = xMenuBar
;
1753 if ( nStatusBarIndex
>= 0 )
1754 aSeq
[nStatusBarIndex
] = xStatusBar
;
1759 sal_Bool SAL_CALL
LayoutManager::showElement( const OUString
& aName
)
1760 throw (RuntimeException
, std::exception
)
1762 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::showElement" );
1764 bool bResult( false );
1765 bool bNotify( false );
1766 bool bMustLayout( false );
1767 OUString aElementType
;
1768 OUString aElementName
;
1770 parseResourceURL( aName
, aElementType
, aElementName
);
1772 OString aResName
= OUStringToOString( aElementName
, RTL_TEXTENCODING_ASCII_US
);
1773 SAL_INFO( "fwk", "framework (cd100003) Element " << aResName
.getStr() );
1775 if ( aElementType
.equalsIgnoreAsciiCase("menubar") &&
1776 aElementName
.equalsIgnoreAsciiCase("menubar") )
1778 SolarMutexClearableGuard aWriteLock
;
1779 m_bMenuVisible
= true;
1782 bResult
= implts_resetMenuBar();
1785 else if (( aElementType
.equalsIgnoreAsciiCase("statusbar") &&
1786 aElementName
.equalsIgnoreAsciiCase("statusbar") ) ||
1787 ( m_aStatusBarElement
.m_aName
== aName
))
1789 SolarMutexClearableGuard aWriteLock
;
1790 if ( m_aStatusBarElement
.m_xUIElement
.is() && !m_aStatusBarElement
.m_bMasterHide
&&
1791 implts_showStatusBar( true ))
1795 implts_writeWindowStateData( STATUS_BAR_ALIAS
, m_aStatusBarElement
);
1801 else if ( aElementType
.equalsIgnoreAsciiCase("progressbar") &&
1802 aElementName
.equalsIgnoreAsciiCase("progressbar") )
1804 bNotify
= bResult
= implts_showProgressBar();
1806 else if ( aElementType
.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
1808 SolarMutexClearableGuard aReadLock
;
1809 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
1812 if ( pToolbarManager
)
1814 bNotify
= pToolbarManager
->showToolbar( aName
);
1815 bMustLayout
= pToolbarManager
->isLayoutDirty();
1818 else if ( aElementType
.equalsIgnoreAsciiCase("dockingwindow"))
1820 SolarMutexClearableGuard aReadGuard
;
1821 uno::Reference
< frame::XFrame
> xFrame( m_xFrame
);
1822 uno::Reference
< XComponentContext
> xContext( m_xContext
);
1825 impl_setDockingWindowVisibility( xContext
, xFrame
, aElementName
, true );
1827 else if ( aElementType
.equalsIgnoreAsciiCase("toolpanel"))
1829 SolarMutexClearableGuard aReadGuard
;
1830 uno::Reference
< frame::XFrame
> xFrame( m_xFrame
);
1832 ActivateToolPanel( m_xFrame
, aName
);
1839 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE
, uno::makeAny( aName
) );
1844 sal_Bool SAL_CALL
LayoutManager::hideElement( const OUString
& aName
)
1845 throw (RuntimeException
, std::exception
)
1847 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::hideElement" );
1849 bool bNotify( false );
1850 bool bMustLayout( false );
1851 OUString aElementType
;
1852 OUString aElementName
;
1854 parseResourceURL( aName
, aElementType
, aElementName
);
1855 OString aResName
= OUStringToOString( aElementName
, RTL_TEXTENCODING_ASCII_US
);
1856 SAL_INFO( "fwk", "framework (cd100003) Element " << aResName
.getStr() );
1858 if ( aElementType
.equalsIgnoreAsciiCase("menubar") &&
1859 aElementName
.equalsIgnoreAsciiCase("menubar") )
1863 if ( m_xContainerWindow
.is() )
1865 m_bMenuVisible
= false;
1867 SolarMutexGuard aGuard
;
1868 SystemWindow
* pSysWindow
= getTopSystemWindow( m_xContainerWindow
);
1871 MenuBar
* pMenuBar
= pSysWindow
->GetMenuBar();
1874 pMenuBar
->SetDisplayable( false );
1880 else if (( aElementType
.equalsIgnoreAsciiCase("statusbar") &&
1881 aElementName
.equalsIgnoreAsciiCase("statusbar") ) ||
1882 ( m_aStatusBarElement
.m_aName
== aName
))
1885 if ( m_aStatusBarElement
.m_xUIElement
.is() && !m_aStatusBarElement
.m_bMasterHide
&&
1886 implts_hideStatusBar( true ))
1888 implts_writeWindowStateData( STATUS_BAR_ALIAS
, m_aStatusBarElement
);
1893 else if ( aElementType
.equalsIgnoreAsciiCase("progressbar") &&
1894 aElementName
.equalsIgnoreAsciiCase("progressbar") )
1896 bNotify
= implts_hideProgressBar();
1898 else if ( aElementType
.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
1900 SolarMutexClearableGuard aReadLock
;
1901 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
1904 if ( pToolbarManager
)
1906 bNotify
= pToolbarManager
->hideToolbar( aName
);
1907 bMustLayout
= pToolbarManager
->isLayoutDirty();
1910 else if ( aElementType
.equalsIgnoreAsciiCase("dockingwindow"))
1912 SolarMutexClearableGuard aReadGuard
;
1913 uno::Reference
< frame::XFrame
> xFrame( m_xFrame
);
1914 uno::Reference
< XComponentContext
> xContext( m_xContext
);
1917 impl_setDockingWindowVisibility( xContext
, xFrame
, aElementName
, false );
1924 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_INVISIBLE
, uno::makeAny( aName
) );
1929 sal_Bool SAL_CALL
LayoutManager::dockWindow( const OUString
& aName
, DockingArea DockingArea
, const awt::Point
& Pos
)
1930 throw (RuntimeException
, std::exception
)
1932 OUString aElementType
;
1933 OUString aElementName
;
1935 parseResourceURL( aName
, aElementType
, aElementName
);
1936 if ( aElementType
.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
1938 SolarMutexClearableGuard aReadLock
;
1939 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
1942 if ( pToolbarManager
)
1944 pToolbarManager
->dockToolbar( aName
, DockingArea
, Pos
);
1945 if ( pToolbarManager
->isLayoutDirty() )
1952 sal_Bool SAL_CALL
LayoutManager::dockAllWindows( ::sal_Int16
/*nElementType*/ ) throw (uno::RuntimeException
, std::exception
)
1954 SolarMutexClearableGuard aReadLock
;
1955 bool bResult( false );
1956 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
1959 if ( pToolbarManager
)
1961 bResult
= pToolbarManager
->dockAllToolbars();
1962 if ( pToolbarManager
->isLayoutDirty() )
1968 sal_Bool SAL_CALL
LayoutManager::floatWindow( const OUString
& aName
)
1969 throw (RuntimeException
, std::exception
)
1971 bool bResult( false );
1972 if ( getElementTypeFromResourceURL( aName
).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
1974 SolarMutexClearableGuard aReadLock
;
1975 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
1978 if ( pToolbarManager
)
1980 bResult
= pToolbarManager
->floatToolbar( aName
);
1981 if ( pToolbarManager
->isLayoutDirty() )
1988 sal_Bool SAL_CALL
LayoutManager::lockWindow( const OUString
& aName
)
1989 throw (uno::RuntimeException
, std::exception
)
1991 bool bResult( false );
1992 if ( getElementTypeFromResourceURL( aName
).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
1994 SolarMutexClearableGuard aReadLock
;
1995 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
1998 if ( pToolbarManager
)
2000 bResult
= pToolbarManager
->lockToolbar( aName
);
2001 if ( pToolbarManager
->isLayoutDirty() )
2008 sal_Bool SAL_CALL
LayoutManager::unlockWindow( const OUString
& aName
)
2009 throw (uno::RuntimeException
, std::exception
)
2011 bool bResult( false );
2012 if ( getElementTypeFromResourceURL( aName
).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2014 SolarMutexClearableGuard aReadLock
;
2015 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
2018 if ( pToolbarManager
)
2020 bResult
= pToolbarManager
->unlockToolbar( aName
);
2021 if ( pToolbarManager
->isLayoutDirty() )
2028 void SAL_CALL
LayoutManager::setElementSize( const OUString
& aName
, const awt::Size
& aSize
)
2029 throw (RuntimeException
, std::exception
)
2031 if ( getElementTypeFromResourceURL( aName
).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2033 SolarMutexClearableGuard aReadLock
;
2034 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
2037 if ( pToolbarManager
)
2039 pToolbarManager
->setToolbarSize( aName
, aSize
);
2040 if ( pToolbarManager
->isLayoutDirty() )
2046 void SAL_CALL
LayoutManager::setElementPos( const OUString
& aName
, const awt::Point
& aPos
)
2047 throw (RuntimeException
, std::exception
)
2049 if ( getElementTypeFromResourceURL( aName
).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2051 SolarMutexClearableGuard aReadLock
;
2052 ToolbarLayoutManager
* pToolbarManager( m_pToolbarManager
);
2055 if ( pToolbarManager
)
2057 pToolbarManager
->setToolbarPos( aName
, aPos
);
2058 if ( pToolbarManager
->isLayoutDirty() )
2064 void SAL_CALL
LayoutManager::setElementPosSize( const OUString
& aName
, const awt::Point
& aPos
, const awt::Size
& aSize
)
2065 throw (RuntimeException
, std::exception
)
2067 if ( getElementTypeFromResourceURL( aName
).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2069 SolarMutexClearableGuard aReadLock
;
2070 ToolbarLayoutManager
* pToolbarManager( m_pToolbarManager
);
2073 if ( pToolbarManager
)
2075 pToolbarManager
->setToolbarPosSize( aName
, aPos
, aSize
);
2076 if ( pToolbarManager
->isLayoutDirty() )
2082 sal_Bool SAL_CALL
LayoutManager::isElementVisible( const OUString
& aName
)
2083 throw (RuntimeException
, std::exception
)
2085 OUString aElementType
;
2086 OUString aElementName
;
2088 parseResourceURL( aName
, aElementType
, aElementName
);
2089 if ( aElementType
.equalsIgnoreAsciiCase("menubar") &&
2090 aElementName
.equalsIgnoreAsciiCase("menubar") )
2092 SolarMutexResettableGuard aReadLock
;
2093 if ( m_xContainerWindow
.is() )
2097 SolarMutexGuard aGuard
;
2098 SystemWindow
* pSysWindow
= getTopSystemWindow( m_xContainerWindow
);
2101 MenuBar
* pMenuBar
= pSysWindow
->GetMenuBar();
2102 if ( pMenuBar
&& pMenuBar
->IsDisplayable() )
2108 return m_bMenuVisible
;
2112 else if (( aElementType
.equalsIgnoreAsciiCase("statusbar") &&
2113 aElementName
.equalsIgnoreAsciiCase("statusbar") ) ||
2114 ( m_aStatusBarElement
.m_aName
== aName
))
2116 if ( m_aStatusBarElement
.m_xUIElement
.is() )
2118 Reference
< awt::XWindow
> xWindow( m_aStatusBarElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
2122 vcl::Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
2123 if ( pWindow
&& pWindow
->IsVisible() )
2130 else if ( aElementType
.equalsIgnoreAsciiCase("progressbar") &&
2131 aElementName
.equalsIgnoreAsciiCase("progressbar") )
2133 if ( m_aProgressBarElement
.m_xUIElement
.is() )
2134 return m_aProgressBarElement
.m_bVisible
;
2136 else if ( aElementType
.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2138 SolarMutexClearableGuard aReadLock
;
2139 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
2142 if ( pToolbarManager
)
2143 return pToolbarManager
->isToolbarVisible( aName
);
2145 else if ( aElementType
.equalsIgnoreAsciiCase("dockingwindow"))
2147 SolarMutexClearableGuard aReadGuard
;
2148 uno::Reference
< frame::XFrame
> xFrame( m_xFrame
);
2151 return IsDockingWindowVisible( xFrame
, aElementName
);
2157 sal_Bool SAL_CALL
LayoutManager::isElementFloating( const OUString
& aName
)
2158 throw (RuntimeException
, std::exception
)
2160 if ( getElementTypeFromResourceURL( aName
).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2162 SolarMutexClearableGuard aReadLock
;
2163 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
2166 if ( pToolbarManager
)
2167 return pToolbarManager
->isToolbarFloating( aName
);
2173 sal_Bool SAL_CALL
LayoutManager::isElementDocked( const OUString
& aName
)
2174 throw (RuntimeException
, std::exception
)
2176 if ( getElementTypeFromResourceURL( aName
).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2178 SolarMutexClearableGuard aReadLock
;
2179 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
2182 if ( pToolbarManager
)
2183 return pToolbarManager
->isToolbarDocked( aName
);
2189 sal_Bool SAL_CALL
LayoutManager::isElementLocked( const OUString
& aName
)
2190 throw (uno::RuntimeException
, std::exception
)
2192 if ( getElementTypeFromResourceURL( aName
).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2194 SolarMutexClearableGuard aReadLock
;
2195 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
2198 if ( pToolbarManager
)
2199 return pToolbarManager
->isToolbarLocked( aName
);
2205 awt::Size SAL_CALL
LayoutManager::getElementSize( const OUString
& aName
)
2206 throw (RuntimeException
, std::exception
)
2208 if ( getElementTypeFromResourceURL( aName
).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2210 SolarMutexClearableGuard aReadLock
;
2211 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
2214 if ( pToolbarManager
)
2215 return pToolbarManager
->getToolbarSize( aName
);
2221 awt::Point SAL_CALL
LayoutManager::getElementPos( const OUString
& aName
)
2222 throw (RuntimeException
, std::exception
)
2224 if ( getElementTypeFromResourceURL( aName
).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2226 SolarMutexClearableGuard aReadLock
;
2227 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
2230 if ( pToolbarManager
)
2231 return pToolbarManager
->getToolbarPos( aName
);
2234 return awt::Point();
2237 void SAL_CALL
LayoutManager::lock()
2238 throw (RuntimeException
, std::exception
)
2242 SolarMutexClearableGuard aReadLock
;
2243 sal_Int32
nLockCount( m_nLockCount
);
2246 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::lock lockCount=" << nLockCount
);
2248 OStringBuffer
aStr("LayoutManager::lock ");
2249 aStr
.append(reinterpret_cast<sal_Int64
>(this));
2251 aStr
.append(nLockCount
);
2252 SAL_INFO( "fwk", "" << aStr
.getStr());
2255 Any
a( nLockCount
);
2256 implts_notifyListeners( frame::LayoutManagerEvents::LOCK
, a
);
2259 void SAL_CALL
LayoutManager::unlock()
2260 throw (RuntimeException
, std::exception
)
2262 bool bDoLayout( implts_unlock() );
2264 SolarMutexClearableGuard aReadLock
;
2265 sal_Int32
nLockCount( m_nLockCount
);
2268 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::unlock lockCount=" << nLockCount
);
2270 OStringBuffer
aStr("LayoutManager::unlock ");
2271 aStr
.append(reinterpret_cast<sal_Int64
>(this));
2273 aStr
.append(nLockCount
);
2274 SAL_INFO( "fwk", "" << aStr
.getStr());
2276 // conform to documentation: unlock with lock count == 0 means force a layout
2278 SolarMutexClearableGuard aWriteLock
;
2280 m_aAsyncLayoutTimer
.Stop();
2283 Any
a( nLockCount
);
2284 implts_notifyListeners( frame::LayoutManagerEvents::UNLOCK
, a
);
2287 implts_doLayout_notify( true );
2290 void SAL_CALL
LayoutManager::doLayout()
2291 throw (RuntimeException
, std::exception
)
2293 implts_doLayout_notify( true );
2296 // ILayoutNotifications
2298 void LayoutManager::requestLayout( Hint eHint
)
2300 if ( eHint
== HINT_TOOLBARSPACE_HAS_CHANGED
)
2304 void LayoutManager::implts_doLayout_notify( bool bOuterResize
)
2306 bool bLayouted
= implts_doLayout( false, bOuterResize
);
2308 implts_notifyListeners( frame::LayoutManagerEvents::LAYOUT
, Any() );
2311 bool LayoutManager::implts_doLayout( bool bForceRequestBorderSpace
, bool bOuterResize
)
2313 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::implts_doLayout" );
2315 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2316 SolarMutexClearableGuard aReadLock
;
2318 if ( !m_xFrame
.is() || !m_bParentWindowVisible
)
2321 bool bPreserveContentSize( m_bPreserveContentSize
);
2322 bool bMustDoLayout( m_bMustDoLayout
);
2323 bool bNoLock
= ( m_nLockCount
== 0 );
2324 awt::Rectangle
aCurrBorderSpace( m_aDockingArea
);
2325 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
2326 Reference
< awt::XTopWindow2
> xContainerTopWindow( m_xContainerTopWindow
);
2327 Reference
< awt::XWindow
> xComponentWindow( m_xFrame
->getComponentWindow() );
2328 Reference
< XDockingAreaAcceptor
> xDockingAreaAcceptor( m_xDockingAreaAcceptor
);
2330 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2332 bool bLayouted( false );
2334 if ( bNoLock
&& xDockingAreaAcceptor
.is() && xContainerWindow
.is() && xComponentWindow
.is() )
2338 SolarMutexResettableGuard aWriteGuard
;
2340 aWriteGuard
.clear();
2342 awt::Rectangle
aDockSpace( implts_calcDockingAreaSizes() );
2343 awt::Rectangle
aBorderSpace( aDockSpace
);
2344 bool bGotRequestedBorderSpace( true );
2346 // We have to add the height of a possible status bar
2347 aBorderSpace
.Height
+= implts_getStatusBarSize().Height();
2349 if ( !equalRectangles( aBorderSpace
, aCurrBorderSpace
) || bForceRequestBorderSpace
|| bMustDoLayout
)
2351 // we always resize the content window (instead of the complete container window) if we're not set up
2352 // to (attempt to) preserve the content window's size
2353 if ( bOuterResize
&& !bPreserveContentSize
)
2354 bOuterResize
= false;
2356 // maximized windows can resized their content window only, not their container window
2357 if ( bOuterResize
&& xContainerTopWindow
.is() && xContainerTopWindow
->getIsMaximized() )
2358 bOuterResize
= false;
2360 // if the component window does not have a size (yet), then we can't use it to calc the container
2362 awt::Rectangle aComponentRect
= xComponentWindow
->getPosSize();
2363 if ( bOuterResize
&& ( aComponentRect
.Width
== 0 ) && ( aComponentRect
.Height
== 0 ) )
2364 bOuterResize
= false;
2366 bGotRequestedBorderSpace
= false;
2369 Reference
< awt::XDevice
> xDevice( xContainerWindow
, uno::UNO_QUERY
);
2370 awt::DeviceInfo aContainerInfo
= xDevice
->getInfo();
2372 awt::Size
aRequestedSize( aComponentRect
.Width
+ aContainerInfo
.LeftInset
+ aContainerInfo
.RightInset
+ aBorderSpace
.X
+ aBorderSpace
.Width
,
2373 aComponentRect
.Height
+ aContainerInfo
.TopInset
+ aContainerInfo
.BottomInset
+ aBorderSpace
.Y
+ aBorderSpace
.Height
);
2374 awt::Point
aComponentPos( aBorderSpace
.X
, aBorderSpace
.Y
);
2376 bGotRequestedBorderSpace
= implts_resizeContainerWindow( aRequestedSize
, aComponentPos
);
2379 // if we did not do an container window resize, or it failed, then use the DockingAcceptor as usual
2380 if ( !bGotRequestedBorderSpace
)
2381 bGotRequestedBorderSpace
= xDockingAreaAcceptor
->requestDockingAreaSpace( aBorderSpace
);
2383 if ( bGotRequestedBorderSpace
)
2385 aWriteGuard
.reset();
2386 m_aDockingArea
= aBorderSpace
;
2387 m_bMustDoLayout
= false;
2388 aWriteGuard
.clear();
2392 if ( bGotRequestedBorderSpace
)
2394 ::Size aContainerSize
;
2395 ::Size aStatusBarSize
;
2397 // Interim solution to let the layout method within the
2398 // toolbar layout manager.
2399 implts_setOffset( implts_getStatusBarSize().Height() );
2400 if ( m_pToolbarManager
)
2401 m_pToolbarManager
->setDockingArea( aDockSpace
);
2403 // Subtract status bar size from our container output size. Docking area windows
2404 // don't contain the status bar!
2405 aStatusBarSize
= implts_getStatusBarSize();
2406 aContainerSize
= implts_getContainerWindowOutputSize();
2407 aContainerSize
.Height() -= aStatusBarSize
.Height();
2409 if ( m_pToolbarManager
)
2410 m_pToolbarManager
->doLayout(aContainerSize
);
2412 // Position the status bar
2413 if ( aStatusBarSize
.Height() > 0 )
2415 implts_setStatusBarPosSize( ::Point( 0, std::max(( aContainerSize
.Height() ), long( 0 ))),
2416 ::Size( aContainerSize
.Width(),aStatusBarSize
.Height() ));
2419 xDockingAreaAcceptor
->setDockingAreaSpace( aBorderSpace
);
2421 aWriteGuard
.reset();
2422 m_bDoLayout
= false;
2423 aWriteGuard
.clear();
2430 bool LayoutManager::implts_resizeContainerWindow( const awt::Size
& rContainerSize
,
2431 const awt::Point
& rComponentPos
)
2433 SolarMutexClearableGuard aReadLock
;
2434 Reference
< awt::XWindow
> xContainerWindow
= m_xContainerWindow
;
2435 Reference
< awt::XTopWindow2
> xContainerTopWindow
= m_xContainerTopWindow
;
2436 Reference
< awt::XWindow
> xComponentWindow
= m_xFrame
->getComponentWindow();
2439 // calculate the maximum size we have for the container window
2440 sal_Int32 nDisplay
= xContainerTopWindow
->getDisplay();
2441 Rectangle aWorkArea
= Application::GetScreenPosSizePixel( nDisplay
);
2443 if (( aWorkArea
.GetWidth() > 0 ) && ( aWorkArea
.GetHeight() > 0 ))
2445 if (( rContainerSize
.Width
> aWorkArea
.GetWidth() ) || ( rContainerSize
.Height
> aWorkArea
.GetHeight() ))
2447 // Strictly, this is not correct. If we have a multi-screen display (css.awt.DisplayAccess.MultiDisplay == true),
2448 // the "effective work area" would be much larger than the work area of a single display, since we could in theory
2449 // position the container window across multiple screens.
2450 // However, this should suffice as a heuristics here ... (nobody really wants to check whether the different screens are
2451 // stacked horizontally or vertically, whether their work areas can really be combined, or are separated by non-work-areas,
2452 // and the like ... right?)
2455 // resize our container window
2456 xContainerWindow
->setPosSize( 0, 0, rContainerSize
.Width
, rContainerSize
.Height
, awt::PosSize::SIZE
);
2457 // position the component window
2458 xComponentWindow
->setPosSize( rComponentPos
.X
, rComponentPos
.Y
, 0, 0, awt::PosSize::POS
);
2462 void SAL_CALL
LayoutManager::setVisible( sal_Bool bVisible
)
2463 throw (uno::RuntimeException
, std::exception
)
2465 SolarMutexClearableGuard aWriteLock
;
2466 bool bWasVisible( m_bVisible
);
2467 m_bVisible
= bVisible
;
2470 if ( bWasVisible
!= bool(bVisible
) )
2471 implts_setVisibleState( bVisible
);
2474 sal_Bool SAL_CALL
LayoutManager::isVisible()
2475 throw (uno::RuntimeException
, std::exception
)
2481 ::Size
LayoutManager::implts_getStatusBarSize()
2483 SolarMutexClearableGuard aReadLock
;
2484 bool bStatusBarVisible( isElementVisible( STATUS_BAR_ALIAS
));
2485 bool bProgressBarVisible( isElementVisible( PROGRESS_BAR_ALIAS
));
2486 bool bVisible( m_bVisible
);
2487 Reference
< XUIElement
> xStatusBar( m_aStatusBarElement
.m_xUIElement
);
2488 Reference
< XUIElement
> xProgressBar( m_aProgressBarElement
.m_xUIElement
);
2490 Reference
< awt::XWindow
> xWindow
;
2491 if ( bStatusBarVisible
&& bVisible
&& xStatusBar
.is() )
2492 xWindow
= Reference
< awt::XWindow
>( xStatusBar
->getRealInterface(), UNO_QUERY
);
2493 else if ( xProgressBar
.is() && !xStatusBar
.is() && bProgressBarVisible
)
2495 ProgressBarWrapper
* pWrapper
= static_cast<ProgressBarWrapper
*>(xProgressBar
.get());
2497 xWindow
= pWrapper
->getStatusBar();
2503 awt::Rectangle aPosSize
= xWindow
->getPosSize();
2504 return ::Size( aPosSize
.Width
, aPosSize
.Height
);
2510 awt::Rectangle
LayoutManager::implts_calcDockingAreaSizes()
2512 SolarMutexClearableGuard aReadLock
;
2513 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
2514 Reference
< XDockingAreaAcceptor
> xDockingAreaAcceptor( m_xDockingAreaAcceptor
);
2517 awt::Rectangle aBorderSpace
;
2518 if ( m_pToolbarManager
&& xDockingAreaAcceptor
.is() && xContainerWindow
.is() )
2519 aBorderSpace
= m_pToolbarManager
->getDockingArea();
2521 return aBorderSpace
;
2524 void LayoutManager::implts_setDockingAreaWindowSizes( const awt::Rectangle
& /*rBorderSpace*/ )
2526 SolarMutexClearableGuard aReadLock
;
2527 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
2530 uno::Reference
< awt::XDevice
> xDevice( xContainerWindow
, uno::UNO_QUERY
);
2531 // Convert relativ size to output size.
2532 awt::Rectangle aRectangle
= xContainerWindow
->getPosSize();
2533 awt::DeviceInfo aInfo
= xDevice
->getInfo();
2534 awt::Size aContainerClientSize
= awt::Size( aRectangle
.Width
- aInfo
.LeftInset
- aInfo
.RightInset
,
2535 aRectangle
.Height
- aInfo
.TopInset
- aInfo
.BottomInset
);
2536 ::Size aStatusBarSize
= implts_getStatusBarSize();
2538 // Position the status bar
2539 if ( aStatusBarSize
.Height() > 0 )
2541 implts_setStatusBarPosSize( ::Point( 0, std::max(( aContainerClientSize
.Height
- aStatusBarSize
.Height() ), long( 0 ))),
2542 ::Size( aContainerClientSize
.Width
, aStatusBarSize
.Height() ));
2546 void LayoutManager::implts_updateMenuBarClose()
2548 SolarMutexClearableGuard aWriteLock
;
2549 bool bShowCloseButton( m_bMenuBarCloseButton
);
2550 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
2553 if ( xContainerWindow
.is() )
2555 SolarMutexGuard aGuard
;
2557 SystemWindow
* pSysWindow
= getTopSystemWindow( xContainerWindow
);
2560 MenuBar
* pMenuBar
= pSysWindow
->GetMenuBar();
2563 // TODO remove link on sal_False ?!
2564 pMenuBar
->ShowCloseButton(bShowCloseButton
);
2565 pMenuBar
->SetCloseButtonClickHdl(LINK(this, LayoutManager
, MenuBarClose
));
2571 bool LayoutManager::implts_resetMenuBar()
2573 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2574 SolarMutexClearableGuard aWriteLock
;
2575 bool bMenuVisible( m_bMenuVisible
);
2576 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
2578 MenuBar
* pSetMenuBar
= 0;
2579 if ( m_xInplaceMenuBar
.is() )
2580 pSetMenuBar
= static_cast<MenuBar
*>(m_pInplaceMenuBar
->GetMenuBar());
2583 MenuBarWrapper
* pMenuBarWrapper
= static_cast< MenuBarWrapper
* >( m_xMenuBar
.get() );
2584 if ( pMenuBarWrapper
)
2585 pSetMenuBar
= static_cast<MenuBar
*>(pMenuBarWrapper
->GetMenuBarManager()->GetMenuBar());
2588 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2590 SolarMutexGuard aGuard
;
2591 SystemWindow
* pSysWindow
= getTopSystemWindow( xContainerWindow
);
2592 if ( pSysWindow
&& bMenuVisible
&& pSetMenuBar
)
2594 pSysWindow
->SetMenuBar(pSetMenuBar
, m_xFrame
);
2595 pSetMenuBar
->SetDisplayable( true );
2602 IMPL_LINK_NOARG(LayoutManager
, MenuBarClose
)
2604 SolarMutexClearableGuard aReadLock
;
2605 uno::Reference
< frame::XDispatchProvider
> xProvider(m_xFrame
, uno::UNO_QUERY
);
2606 uno::Reference
< XComponentContext
> xContext( m_xContext
);
2609 if ( !xProvider
.is())
2612 uno::Reference
< frame::XDispatchHelper
> xDispatcher
= frame::DispatchHelper::create( xContext
);
2614 xDispatcher
->executeDispatch(
2616 OUString(".uno:CloseWin"),
2619 uno::Sequence
< beans::PropertyValue
>());
2624 IMPL_STATIC_LINK_NOARG(LayoutManager
, SettingsChanged
)
2629 // XLayoutManagerEventBroadcaster
2631 void SAL_CALL
LayoutManager::addLayoutManagerEventListener( const uno::Reference
< frame::XLayoutManagerListener
>& xListener
)
2632 throw (uno::RuntimeException
, std::exception
)
2634 m_aListenerContainer
.addInterface( cppu::UnoType
<frame::XLayoutManagerListener
>::get(), xListener
);
2637 void SAL_CALL
LayoutManager::removeLayoutManagerEventListener( const uno::Reference
< frame::XLayoutManagerListener
>& xListener
)
2638 throw (uno::RuntimeException
, std::exception
)
2640 m_aListenerContainer
.removeInterface( cppu::UnoType
<frame::XLayoutManagerListener
>::get(), xListener
);
2643 void LayoutManager::implts_notifyListeners(short nEvent
, const uno::Any
& rInfoParam
)
2645 lang::EventObject
aSource( static_cast< ::cppu::OWeakObject
*>(this) );
2646 ::cppu::OInterfaceContainerHelper
* pContainer
= m_aListenerContainer
.getContainer( cppu::UnoType
<frame::XLayoutManagerListener
>::get());
2647 if (pContainer
!=NULL
)
2649 ::cppu::OInterfaceIteratorHelper
pIterator(*pContainer
);
2650 while (pIterator
.hasMoreElements())
2654 static_cast<frame::XLayoutManagerListener
*>(pIterator
.next())->layoutEvent(aSource
, nEvent
, rInfoParam
);
2656 catch( const uno::RuntimeException
& )
2666 void SAL_CALL
LayoutManager::windowResized( const awt::WindowEvent
& aEvent
)
2667 throw( uno::RuntimeException
, std::exception
)
2670 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
2672 Reference
< XInterface
> xIfac( xContainerWindow
, UNO_QUERY
);
2673 if ( xIfac
== aEvent
.Source
&& m_bVisible
)
2675 // We have to call our resize handler at least once synchronously, as some
2676 // application modules need this. So we have to check if this is the first
2677 // call after the async layout time expired.
2678 m_bMustDoLayout
= true;
2679 if ( !m_aAsyncLayoutTimer
.IsActive() )
2681 const Link
<Timer
*, void>& aLink
= m_aAsyncLayoutTimer
.GetTimeoutHdl();
2682 if ( aLink
.IsSet() )
2683 aLink
.Call( &m_aAsyncLayoutTimer
);
2685 if ( m_nLockCount
== 0 )
2686 m_aAsyncLayoutTimer
.Start();
2688 else if ( m_xFrame
.is() && aEvent
.Source
== m_xFrame
->getContainerWindow() )
2690 // the container window of my DockingAreaAcceptor is not the same as of my frame
2691 // I still have to resize my frames' window as nobody else will do it
2692 Reference
< awt::XWindow
> xComponentWindow( m_xFrame
->getComponentWindow() );
2693 if( xComponentWindow
.is() )
2695 uno::Reference
< awt::XDevice
> xDevice( m_xFrame
->getContainerWindow(), uno::UNO_QUERY
);
2697 // Convert relativ size to output size.
2698 awt::Rectangle aRectangle
= m_xFrame
->getContainerWindow()->getPosSize();
2699 awt::DeviceInfo aInfo
= xDevice
->getInfo();
2700 awt::Size
aSize( aRectangle
.Width
- aInfo
.LeftInset
- aInfo
.RightInset
,
2701 aRectangle
.Height
- aInfo
.TopInset
- aInfo
.BottomInset
);
2703 // Resize our component window.
2704 xComponentWindow
->setPosSize( 0, 0, aSize
.Width
, aSize
.Height
, awt::PosSize::POSSIZE
);
2709 void SAL_CALL
LayoutManager::windowMoved( const awt::WindowEvent
& ) throw( uno::RuntimeException
, std::exception
)
2713 void SAL_CALL
LayoutManager::windowShown( const lang::EventObject
& aEvent
) throw( uno::RuntimeException
, std::exception
)
2715 SolarMutexClearableGuard aReadLock
;
2716 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
2717 bool bParentWindowVisible( m_bParentWindowVisible
);
2720 Reference
< XInterface
> xIfac( xContainerWindow
, UNO_QUERY
);
2721 if ( xIfac
== aEvent
.Source
)
2723 SolarMutexClearableGuard aWriteLock
;
2724 m_bParentWindowVisible
= true;
2725 bool bSetVisible
= ( m_bParentWindowVisible
!= bParentWindowVisible
);
2729 implts_updateUIElementsVisibleState( true );
2733 void SAL_CALL
LayoutManager::windowHidden( const lang::EventObject
& aEvent
) throw( uno::RuntimeException
, std::exception
)
2735 SolarMutexClearableGuard aReadLock
;
2736 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
2737 bool bParentWindowVisible( m_bParentWindowVisible
);
2740 Reference
< XInterface
> xIfac( xContainerWindow
, UNO_QUERY
);
2741 if ( xIfac
== aEvent
.Source
)
2743 SolarMutexClearableGuard aWriteLock
;
2744 m_bParentWindowVisible
= false;
2745 bool bSetInvisible
= ( m_bParentWindowVisible
!= bParentWindowVisible
);
2748 if ( bSetInvisible
)
2749 implts_updateUIElementsVisibleState( false );
2753 IMPL_LINK_NOARG_TYPED(LayoutManager
, AsyncLayoutHdl
, Timer
*, void)
2755 SolarMutexClearableGuard aReadLock
;
2756 m_aAsyncLayoutTimer
.Stop();
2758 if( !m_xContainerWindow
.is() )
2761 awt::Rectangle
aDockingArea( m_aDockingArea
);
2762 ::Size
aStatusBarSize( implts_getStatusBarSize() );
2764 // Subtract status bar height
2765 aDockingArea
.Height
-= aStatusBarSize
.Height();
2768 implts_setDockingAreaWindowSizes( aDockingArea
);
2769 implts_doLayout( true, false );
2772 // XFrameActionListener
2774 void SAL_CALL
LayoutManager::frameAction( const FrameActionEvent
& aEvent
)
2775 throw ( RuntimeException
, std::exception
)
2777 if (( aEvent
.Action
== FrameAction_COMPONENT_ATTACHED
) || ( aEvent
.Action
== FrameAction_COMPONENT_REATTACHED
))
2779 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)" );
2781 SolarMutexClearableGuard aWriteLock
;
2782 m_bComponentAttached
= true;
2783 m_bMustDoLayout
= true;
2786 implts_reset( true );
2787 implts_doLayout( true, false );
2788 implts_doLayout( true, true );
2790 else if (( aEvent
.Action
== FrameAction_FRAME_UI_ACTIVATED
) || ( aEvent
.Action
== FrameAction_FRAME_UI_DEACTIVATING
))
2792 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::frameAction (FRAME_UI_ACTIVATED|DEACTIVATING)" );
2794 SolarMutexClearableGuard aWriteLock
;
2795 m_bActive
= ( aEvent
.Action
== FrameAction_FRAME_UI_ACTIVATED
);
2798 implts_toggleFloatingUIElementsVisibility( aEvent
.Action
== FrameAction_FRAME_UI_ACTIVATED
);
2800 else if ( aEvent
.Action
== FrameAction_COMPONENT_DETACHING
)
2802 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_DETACHING)" );
2804 SolarMutexClearableGuard aWriteLock
;
2805 m_bComponentAttached
= false;
2808 implts_reset( false );
2812 void SAL_CALL
LayoutManager::disposing( const lang::EventObject
& rEvent
)
2813 throw( RuntimeException
, std::exception
)
2815 bool bDisposeAndClear( false );
2817 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2818 SolarMutexClearableGuard aWriteLock
;
2820 if ( rEvent
.Source
== Reference
< XInterface
>( m_xFrame
, UNO_QUERY
))
2822 // Our frame gets disposed, release all our references that depends on a working frame reference.
2823 Application::RemoveEventListener( LINK( this, LayoutManager
, SettingsChanged
) );
2825 setDockingAreaAcceptor( Reference
< ui::XDockingAreaAcceptor
>() );
2827 // destroy all elements, it's possible that dettaching is NOT called!
2828 implts_destroyElements();
2829 impl_clearUpMenuBar();
2831 if ( m_xInplaceMenuBar
.is() )
2833 m_pInplaceMenuBar
= 0;
2834 m_xInplaceMenuBar
->dispose();
2836 m_xInplaceMenuBar
.clear();
2837 m_xContainerWindow
.clear();
2838 m_xContainerTopWindow
.clear();
2840 // forward disposing call to toolbar manager
2841 if ( m_pToolbarManager
!= NULL
)
2842 m_pToolbarManager
->disposing(rEvent
);
2844 if ( m_xModuleCfgMgr
.is() )
2848 Reference
< XUIConfiguration
> xModuleCfgMgr( m_xModuleCfgMgr
, UNO_QUERY
);
2849 xModuleCfgMgr
->removeConfigurationListener(
2850 Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
2852 catch (const Exception
&)
2857 if ( m_xDocCfgMgr
.is() )
2861 Reference
< XUIConfiguration
> xDocCfgMgr( m_xDocCfgMgr
, UNO_QUERY
);
2862 xDocCfgMgr
->removeConfigurationListener(
2863 Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
2865 catch (const Exception
&)
2870 m_xDocCfgMgr
.clear();
2871 m_xModuleCfgMgr
.clear();
2873 delete m_pGlobalSettings
;
2874 m_pGlobalSettings
= 0;
2876 bDisposeAndClear
= true;
2878 else if ( rEvent
.Source
== Reference
< XInterface
>( m_xContainerWindow
, UNO_QUERY
))
2880 // Our container window gets disposed. Remove all user interface elements.
2881 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
2882 if ( pToolbarManager
)
2884 uno::Reference
< awt::XWindowPeer
> aEmptyWindowPeer
;
2885 pToolbarManager
->setParentWindow( aEmptyWindowPeer
);
2887 impl_clearUpMenuBar();
2889 if ( m_xInplaceMenuBar
.is() )
2891 m_pInplaceMenuBar
= 0;
2892 m_xInplaceMenuBar
->dispose();
2894 m_xInplaceMenuBar
.clear();
2895 m_xContainerWindow
.clear();
2896 m_xContainerTopWindow
.clear();
2898 else if ( rEvent
.Source
== Reference
< XInterface
>( m_xDocCfgMgr
, UNO_QUERY
))
2899 m_xDocCfgMgr
.clear();
2900 else if ( rEvent
.Source
== Reference
< XInterface
>( m_xModuleCfgMgr
, UNO_QUERY
))
2901 m_xModuleCfgMgr
.clear();
2904 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2906 // Send disposing to our listener when we have lost our frame.
2907 if ( bDisposeAndClear
)
2909 // Send message to all listener and forget her references.
2910 uno::Reference
< frame::XLayoutManager
> xThis( static_cast< ::cppu::OWeakObject
* >(this), uno::UNO_QUERY
);
2911 lang::EventObject
aEvent( xThis
);
2912 m_aListenerContainer
.disposeAndClear( aEvent
);
2916 void SAL_CALL
LayoutManager::elementInserted( const ui::ConfigurationEvent
& Event
) throw (uno::RuntimeException
, std::exception
)
2918 SolarMutexClearableGuard aReadLock
;
2919 Reference
< XFrame
> xFrame( m_xFrame
);
2920 Reference
< ui::XUIConfigurationListener
> xUICfgListener( m_xToolbarManager
);
2921 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
2926 OUString aElementType
;
2927 OUString aElementName
;
2928 bool bRefreshLayout(false);
2930 parseResourceURL( Event
.ResourceURL
, aElementType
, aElementName
);
2931 if ( aElementType
.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2933 if ( xUICfgListener
.is() )
2935 xUICfgListener
->elementInserted( Event
);
2936 bRefreshLayout
= pToolbarManager
->isLayoutDirty();
2939 else if ( aElementType
.equalsIgnoreAsciiCase( UIRESOURCETYPE_MENUBAR
))
2941 Reference
< XUIElement
> xUIElement
= implts_findElement( Event
.ResourceURL
);
2942 Reference
< XUIElementSettings
> xElementSettings( xUIElement
, UNO_QUERY
);
2943 if ( xElementSettings
.is() )
2945 OUString
aConfigSourcePropName( "ConfigurationSource" );
2946 uno::Reference
< XPropertySet
> xPropSet( xElementSettings
, uno::UNO_QUERY
);
2947 if ( xPropSet
.is() )
2949 if ( Event
.Source
== uno::Reference
< uno::XInterface
>( m_xDocCfgMgr
, uno::UNO_QUERY
))
2950 xPropSet
->setPropertyValue( aConfigSourcePropName
, makeAny( m_xDocCfgMgr
));
2952 xElementSettings
->updateSettings();
2956 if ( bRefreshLayout
)
2961 void SAL_CALL
LayoutManager::elementRemoved( const ui::ConfigurationEvent
& Event
) throw (uno::RuntimeException
, std::exception
)
2963 SolarMutexClearableGuard aReadLock
;
2964 Reference
< frame::XFrame
> xFrame( m_xFrame
);
2965 Reference
< ui::XUIConfigurationListener
> xToolbarManager( m_xToolbarManager
);
2966 Reference
< awt::XWindow
> xContainerWindow( m_xContainerWindow
);
2967 Reference
< ui::XUIElement
> xMenuBar( m_xMenuBar
);
2968 Reference
< ui::XUIConfigurationManager
> xModuleCfgMgr( m_xModuleCfgMgr
);
2969 Reference
< ui::XUIConfigurationManager
> xDocCfgMgr( m_xDocCfgMgr
);
2970 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
2975 OUString aElementType
;
2976 OUString aElementName
;
2977 bool bRefreshLayout(false);
2979 parseResourceURL( Event
.ResourceURL
, aElementType
, aElementName
);
2980 if ( aElementType
.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
2982 if ( xToolbarManager
.is() )
2984 xToolbarManager
->elementRemoved( Event
);
2985 bRefreshLayout
= pToolbarManager
->isLayoutDirty();
2990 Reference
< XUIElement
> xUIElement
= implts_findElement( Event
.ResourceURL
);
2991 Reference
< XUIElementSettings
> xElementSettings( xUIElement
, UNO_QUERY
);
2992 if ( xElementSettings
.is() )
2994 bool bNoSettings( false );
2995 OUString
aConfigSourcePropName( "ConfigurationSource" );
2996 Reference
< XInterface
> xElementCfgMgr
;
2997 Reference
< XPropertySet
> xPropSet( xElementSettings
, UNO_QUERY
);
2999 if ( xPropSet
.is() )
3000 xPropSet
->getPropertyValue( aConfigSourcePropName
) >>= xElementCfgMgr
;
3002 if ( !xElementCfgMgr
.is() )
3005 // Check if the same UI configuration manager has changed => check further
3006 if ( Event
.Source
== xElementCfgMgr
)
3008 // Same UI configuration manager where our element has its settings
3009 if ( Event
.Source
== Reference
< XInterface
>( xDocCfgMgr
, UNO_QUERY
))
3011 // document settings removed
3012 if ( xModuleCfgMgr
->hasSettings( Event
.ResourceURL
))
3014 xPropSet
->setPropertyValue( aConfigSourcePropName
, makeAny( m_xModuleCfgMgr
));
3015 xElementSettings
->updateSettings();
3023 // No settings anymore, element must be destroyed
3024 if ( xContainerWindow
.is() && bNoSettings
)
3026 if ( aElementType
.equalsIgnoreAsciiCase("menubar") &&
3027 aElementName
.equalsIgnoreAsciiCase("menubar") )
3029 SystemWindow
* pSysWindow
= getTopSystemWindow( xContainerWindow
);
3030 if ( pSysWindow
&& !m_bInplaceMenuSet
)
3031 pSysWindow
->SetMenuBar( 0 );
3033 Reference
< XComponent
> xComp( xMenuBar
, UNO_QUERY
);
3044 if ( bRefreshLayout
)
3049 void SAL_CALL
LayoutManager::elementReplaced( const ui::ConfigurationEvent
& Event
) throw (uno::RuntimeException
, std::exception
)
3051 SolarMutexClearableGuard aReadLock
;
3052 Reference
< XFrame
> xFrame( m_xFrame
);
3053 Reference
< ui::XUIConfigurationListener
> xToolbarManager( m_xToolbarManager
);
3054 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
3059 OUString aElementType
;
3060 OUString aElementName
;
3061 bool bRefreshLayout(false);
3063 parseResourceURL( Event
.ResourceURL
, aElementType
, aElementName
);
3064 if ( aElementType
.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR
))
3066 if ( xToolbarManager
.is() )
3068 xToolbarManager
->elementReplaced( Event
);
3069 bRefreshLayout
= pToolbarManager
->isLayoutDirty();
3074 Reference
< XUIElement
> xUIElement
= implts_findElement( Event
.ResourceURL
);
3075 Reference
< XUIElementSettings
> xElementSettings( xUIElement
, UNO_QUERY
);
3076 if ( xElementSettings
.is() )
3078 OUString
aConfigSourcePropName( "ConfigurationSource" );
3079 Reference
< XInterface
> xElementCfgMgr
;
3080 Reference
< XPropertySet
> xPropSet( xElementSettings
, UNO_QUERY
);
3082 if ( xPropSet
.is() )
3083 xPropSet
->getPropertyValue( aConfigSourcePropName
) >>= xElementCfgMgr
;
3085 if ( !xElementCfgMgr
.is() )
3088 // Check if the same UI configuration manager has changed => update settings
3089 if ( Event
.Source
== xElementCfgMgr
)
3090 xElementSettings
->updateSettings();
3094 if ( bRefreshLayout
)
3099 // OPropertySetHelper
3101 sal_Bool SAL_CALL
LayoutManager::convertFastPropertyValue( Any
& aConvertedValue
,
3104 const Any
& aValue
) throw( lang::IllegalArgumentException
)
3106 return LayoutManager_PBase::convertFastPropertyValue( aConvertedValue
, aOldValue
, nHandle
, aValue
);
3109 void SAL_CALL
LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
,
3110 const uno::Any
& aValue
) throw( uno::Exception
, std::exception
)
3112 if ( nHandle
!= LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY
)
3113 LayoutManager_PBase::setFastPropertyValue_NoBroadcast( nHandle
, aValue
);
3117 case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER
:
3118 implts_updateMenuBarClose();
3121 case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY
:
3124 if (( aValue
>>= bValue
) && bValue
)
3126 SolarMutexClearableGuard aReadLock
;
3127 ToolbarLayoutManager
* pToolbarManager
= m_pToolbarManager
;
3128 bool bAutomaticToolbars( m_bAutomaticToolbars
);
3131 if ( pToolbarManager
)
3132 pToolbarManager
->refreshToolbarsVisibility( bAutomaticToolbars
);
3137 case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI
:
3138 implts_setCurrentUIVisibility( !m_bHideCurrentUI
);
3144 void SAL_CALL
LayoutManager::getFastPropertyValue( uno::Any
& aValue
, sal_Int32 nHandle
) const
3146 LayoutManager_PBase::getFastPropertyValue( aValue
, nHandle
);
3151 class InfoHelperBuilder
: private ::boost::noncopyable
3154 ::cppu::OPropertyArrayHelper
*m_pInfoHelper
;
3156 InfoHelperBuilder(const LayoutManager
&rManager
)
3158 uno::Sequence
< beans::Property
> aProperties
;
3159 rManager
.describeProperties(aProperties
);
3160 m_pInfoHelper
= new ::cppu::OPropertyArrayHelper(aProperties
, sal_True
);
3162 ~InfoHelperBuilder()
3164 delete m_pInfoHelper
;
3167 ::cppu::OPropertyArrayHelper
& getHelper() { return *m_pInfoHelper
; }
3172 struct theInfoHelper
:
3173 public rtl::StaticWithArg
< detail::InfoHelperBuilder
, LayoutManager
,
3179 ::cppu::IPropertyArrayHelper
& SAL_CALL
LayoutManager::getInfoHelper()
3181 return theInfoHelper::get(*this).getHelper();
3184 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
LayoutManager::getPropertySetInfo() throw (uno::RuntimeException
, std::exception
)
3186 static uno::Reference
< beans::XPropertySetInfo
>* pInfo
= NULL
;
3190 osl::MutexGuard
aGuard( osl::Mutex::getGlobalMutex() );
3194 static uno::Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
3202 } // namespace framework
3204 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
* SAL_CALL
3205 com_sun_star_comp_framework_LayoutManager_get_implementation(
3206 css::uno::XComponentContext
*context
,
3207 css::uno::Sequence
<css::uno::Any
> const &)
3209 return cppu::acquire(new framework::LayoutManager(context
));
3212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */