From bc5dc66313aa64c558c214955c3bc43e43f3d335 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Wed, 13 Oct 2010 17:31:05 +0200 Subject: [PATCH] dockingwindows: Fixed problems with changes done via UI configuration API not being sent to the ToolbarLayoutManager --- framework/inc/services/layoutmanager.hxx | 2 +- .../source/layoutmanager/layoutmanager.cxx | 29 +++++++-------- .../layoutmanager/toolbarlayoutmanager.cxx | 35 +++++++++++++++++-- 3 files changed, 49 insertions(+), 17 deletions(-) diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx index ef827e7e85b9..6b0135a39e10 100644 --- a/framework/inc/services/layoutmanager.hxx +++ b/framework/inc/services/layoutmanager.hxx @@ -368,7 +368,7 @@ namespace framework ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; // container for ALL Listener PanelManager* m_pPanelManager; ToolbarLayoutManager* m_pToolbarManager; - css::uno::Reference< ::com::sun::star::lang::XComponent > m_xToolbarManager; + css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener > m_xToolbarManager; }; } // namespace framework diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 1e2ca064d140..2f16fbaef634 100755 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -189,7 +189,7 @@ LayoutManager::LayoutManager( const Reference< XMultiServiceFactory >& xServiceM m_aStatusBarElement.m_aName = m_aStatusBarAlias; m_pToolbarManager = new ToolbarLayoutManager( xServiceManager, m_xUIElementFactoryManager, this ); - m_xToolbarManager = uno::Reference< lang::XComponent >( static_cast< OWeakObject* >( m_pToolbarManager ), uno::UNO_QUERY ); + m_xToolbarManager = uno::Reference< ui::XUIConfigurationListener >( static_cast< OWeakObject* >( m_pToolbarManager ), uno::UNO_QUERY ); Application::AddEventListener( LINK( this, LayoutManager, SettingsChanged ) ); @@ -482,7 +482,7 @@ sal_Bool LayoutManager::implts_isEmbeddedLayoutManager() const void LayoutManager::implts_destroyElements() { WriteGuard aWriteLock( m_aLock ); - uno::Reference< lang::XComponent > xThis( m_xToolbarManager ); + uno::Reference< ui::XUIConfigurationListener > xThis( m_xToolbarManager ); ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; aWriteLock.unlock(); @@ -499,7 +499,7 @@ void LayoutManager::implts_destroyElements() void LayoutManager::implts_toggleFloatingUIElementsVisibility( sal_Bool bActive ) { ReadGuard aReadLock( m_aLock ); - uno::Reference< lang::XComponent > xThis( m_xToolbarManager ); + uno::Reference< ui::XUIConfigurationListener > xThis( m_xToolbarManager ); ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; aReadLock.unlock(); @@ -921,7 +921,7 @@ void LayoutManager::implts_updateUIElementsVisibleState( sal_Bool bSetVisible ) if ( bSetVisible ) { - uno::Reference< lang::XComponent > xThis( m_xToolbarManager ); + uno::Reference< ui::XUIConfigurationListener > xThis( m_xToolbarManager ); if ( xThis.is() ) m_pToolbarManager->setVisible(bSetVisible); implts_doLayout_notify( sal_False ); @@ -1270,7 +1270,7 @@ void LayoutManager::implts_setOffset( const sal_Int32 nBottomOffset ) aOffsetRect.setHeight( nBottomOffset ); // make sure that the toolbar manager refernence/pointer is valid - uno::Reference< lang::XComponent > xThis( m_xToolbarManager ); + uno::Reference< ui::XUIConfigurationListener > xThis( m_xToolbarManager ); if ( xThis.is() ) m_pToolbarManager->setDockingAreaOffsets( aOffsetRect ); } @@ -1427,7 +1427,7 @@ throw ( RuntimeException ) sal_Bool bAutomaticToolbars( m_bAutomaticToolbars ); std::vector< Reference< awt::XWindow > > oldDockingAreaWindows; - uno::Reference< lang::XComponent > xToolbarManager( m_xToolbarManager ); + uno::Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; if ( !xDockingAreaAcceptor.is() ) @@ -1566,7 +1566,7 @@ IMPL_LINK( LayoutManager, WindowEventListener, VclSimpleEvent*, pEvent ) long nResult( 1 ); ReadGuard aReadLock( m_aLock ); - uno::Reference< lang::XComponent > xThis( m_xToolbarManager ); + uno::Reference< ui::XUIConfigurationListener > xThis( m_xToolbarManager ); ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); aReadLock.unlock(); @@ -1827,14 +1827,15 @@ throw (uno::RuntimeException) bNotify = true; bDoLayout = true; } - else if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR ) && m_bParentWindowVisible ) + else if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR ) && + m_bParentWindowVisible && m_bVisible ) { - ReadGuard aReadLock( m_aLock ); + bool bComponentAttached( m_aModuleIdentifier.getLength() > 0 ); uno::Reference< uno::XInterface > xThis( m_xToolbarManager, uno::UNO_QUERY ); ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; - aReadLock.unlock(); + aWriteLock.unlock(); - if ( pToolbarManager ) + if ( pToolbarManager && bComponentAttached ) { bNotify = pToolbarManager->requestToolbar( rResourceURL ); bDoLayout = true; @@ -2243,7 +2244,7 @@ throw (RuntimeException) if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) { ReadGuard aReadLock( m_aLock ); - uno::Reference< lang::XComponent > xToolbarManager( m_xToolbarManager ); + uno::Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); aReadLock.unlock(); @@ -2262,7 +2263,7 @@ throw (RuntimeException) if ( aElementType.equalsIgnoreAsciiCaseAscii( UIRESOURCETYPE_TOOLBAR )) { ReadGuard aReadLock( m_aLock ); - uno::Reference< lang::XComponent > xToolbarManager( m_xToolbarManager ); + uno::Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); aReadLock.unlock(); @@ -3163,7 +3164,7 @@ throw( RuntimeException ) else if ( rEvent.Source == Reference< XInterface >( m_xContainerWindow, UNO_QUERY )) { // Our container window gets disposed. Remove all user interface elements. - uno::Reference< lang::XComponent > xToolbarManager( m_xToolbarManager ); + uno::Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; if ( pToolbarManager ) { diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index 4ef8aa6d64b9..45c53c98f3a9 100755 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -4208,10 +4208,41 @@ throw (uno::RuntimeException) } } -void SAL_CALL ToolbarLayoutManager::elementReplaced( - const ui::ConfigurationEvent& /*Event*/ ) +void SAL_CALL ToolbarLayoutManager::elementReplaced( const ui::ConfigurationEvent& rEvent ) throw (uno::RuntimeException) { + ::rtl::OUString aElementType; + ::rtl::OUString aElementName; + UIElement aUIElement = implts_findToolbar( rEvent.ResourceURL ); + + uno::Reference< ui::XUIElementSettings > xElementSettings( aUIElement.m_xUIElement, uno::UNO_QUERY ); + if ( xElementSettings.is() ) + { + ::rtl::OUString aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" )); + uno::Reference< uno::XInterface > xElementCfgMgr; + uno::Reference< beans::XPropertySet > xPropSet( xElementSettings, uno::UNO_QUERY ); + + if ( xPropSet.is() ) + xPropSet->getPropertyValue( aConfigSourcePropName ) >>= xElementCfgMgr; + + if ( !xElementCfgMgr.is() ) + return; + + // Check if the same UI configuration manager has changed => update settings + if ( rEvent.Source == xElementCfgMgr ) + { + xElementSettings->updateSettings(); + + WriteGuard aWriteLock( m_aLock ); + bool bDirty = !aUIElement.m_bFloating; + m_bLayoutDirty = bDirty; + ILayoutNotifications* pParentLayouter( m_pParentLayouter ); + aWriteLock.unlock(); + + if ( bDirty && pParentLayouter ) + pParentLayouter->requestLayout( ILayoutNotifications::HINT_TOOLBARSPACE_HAS_CHANGED ); + } + } } //---------------------------------------------------------------------------------------------------------