diff options
author | Michael Meeks <michael.meeks@suse.com> | 2013-07-05 16:44:19 +0100 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2013-07-08 08:59:47 +0000 |
commit | 706ed1aa74a3e68abe2ed80cd81db8f04150c247 (patch) | |
tree | e1f6159eda72a27c88c52522d515456b4215d3a5 | |
parent | b508bad66665cac58ee47294d3d0a9a5b52f99b2 (diff) |
fdo#66524 - defer population of AddOns toolbar icons until they are shown.
Some addons eg. LibreLogo are almost never shown, so avoid their startup cost.
Change-Id: Ibbc072dd740eca6a97aeff918ae0a5c105278acf
Reviewed-on: https://gerrit.libreoffice.org/4746
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
4 files changed, 38 insertions, 8 deletions
diff --git a/framework/inc/uielement/addonstoolbarwrapper.hxx b/framework/inc/uielement/addonstoolbarwrapper.hxx index 34d80ae28929..c5a8173444d5 100644 --- a/framework/inc/uielement/addonstoolbarwrapper.hxx +++ b/framework/inc/uielement/addonstoolbarwrapper.hxx @@ -45,13 +45,14 @@ class AddonsToolBarWrapper : public UIElementWrapperBase // XUIElement virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRealInterface() throw (::com::sun::star::uno::RuntimeException); - //------------------------------------------------------------------------------------------------------------- - // protected methods - //------------------------------------------------------------------------------------------------------------- + // cf. ToolbarLayoutManager + void populateImages(); + private: com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xToolBarManager; com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > > m_aConfigData; + bool m_bCreatedImages; }; } diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index 93ca44481125..52a0d7bf78aa 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -18,6 +18,7 @@ */ #include <toolbarlayoutmanager.hxx> +#include <uielement/addonstoolbarwrapper.hxx> #include <helpers.hxx> #include <services.h> #include <services/layoutmanager.hxx> @@ -442,6 +443,7 @@ bool ToolbarLayoutManager::requestToolbar( const OUString& rResourceURL ) bMustCallCreate = true; bool bCreateOrShowToolbar( aRequestedToolbar.m_bVisible & !aRequestedToolbar.m_bMasterHide ); + uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow, uno::UNO_QUERY ); if ( xContainerWindow.is() && aRequestedToolbar.m_bFloating ) bCreateOrShowToolbar &= bool( xContainerWindow->isActive()); @@ -569,6 +571,14 @@ bool ToolbarLayoutManager::showToolbar( const OUString& rResourceURL ) SolarMutexGuard aGuard; Window* pWindow = getWindowFromXUIElement( aUIElement.m_xUIElement ); + + // Addons appear to need to be populated at start, but we don't + // want to populate them with (scaled) images until later. + AddonsToolBarWrapper *pAddOns; + pAddOns = dynamic_cast<AddonsToolBarWrapper *>( aUIElement.m_xUIElement.get()); + if (pAddOns) + pAddOns->populateImages(); + if ( pWindow ) { if ( !aUIElement.m_bFloating ) diff --git a/framework/source/uielement/addonstoolbarmanager.cxx b/framework/source/uielement/addonstoolbarmanager.cxx index 0bde95d0ccae..8ddb3eab92f4 100644 --- a/framework/source/uielement/addonstoolbarmanager.cxx +++ b/framework/source/uielement/addonstoolbarmanager.cxx @@ -204,7 +204,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue if ( m_bDisposed ) return; - sal_uInt16 nId( 1 ); + sal_uInt16 nId( 1 ); RemoveControllers(); @@ -261,9 +261,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue m_pToolBar->InsertItem( nId, aTitle ); - Image aImage = RetrieveImage( m_xFrame, aImageId, aURL, !m_bSmallSymbols ); - if ( !!aImage ) - m_pToolBar->SetItemImage( nId, aImage ); + // don't setup images yet, AddonsToolbarWrapper::populateImages does that. // Create TbRuntimeItemData to hold additional information we will need in the future AddonsParams* pRuntimeItemData = new AddonsParams; diff --git a/framework/source/uielement/addonstoolbarwrapper.cxx b/framework/source/uielement/addonstoolbarwrapper.cxx index 3153b2abbafc..0a04a6127a7d 100644 --- a/framework/source/uielement/addonstoolbarwrapper.cxx +++ b/framework/source/uielement/addonstoolbarwrapper.cxx @@ -55,7 +55,8 @@ namespace framework AddonsToolBarWrapper::AddonsToolBarWrapper( const Reference< XComponentContext >& xContext ) : UIElementWrapperBase( UIElementType::TOOLBAR ), - m_xContext( xContext ) + m_xContext( xContext ), + m_bCreatedImages( false ) { } @@ -160,6 +161,26 @@ Reference< XInterface > SAL_CALL AddonsToolBarWrapper::getRealInterface() throw return Reference< XInterface >(); } +// allow late population of images for add-on toolbars +void AddonsToolBarWrapper::populateImages() +{ + ResetableGuard aLock( m_aLock ); + + if (m_bCreatedImages) + return; + + if ( m_xToolBarManager.is() ) + { + AddonsToolBarManager* pToolBarManager = static_cast< AddonsToolBarManager *>( m_xToolBarManager.get() ); + if (pToolBarManager) + { + pToolBarManager->RefreshImages(); + m_bCreatedImages = true; + } + } +} + + } // namespace framework /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |