diff options
author | Michael Meeks <michael.meeks@suse.com> | 2013-07-05 16:44:19 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-07-05 17:11:46 +0100 |
commit | 67feb571330ec4b9eaff7791b27219b62d4c2f6a (patch) | |
tree | 401d3a2bf0e668fe39359dde44a97172bb9b288f /framework | |
parent | fdo#66524 - defer loading and scaling AddOns images until necessary. (diff) | |
download | core-67feb571330ec4b9eaff7791b27219b62d4c2f6a.tar.gz core-67feb571330ec4b9eaff7791b27219b62d4c2f6a.zip |
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
Diffstat (limited to 'framework')
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 670c2a4f2f0b..4abdbc928382 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 8168326bf877..24e002ee2841 100644 --- a/framework/source/uielement/addonstoolbarmanager.cxx +++ b/framework/source/uielement/addonstoolbarmanager.cxx @@ -205,7 +205,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue if ( m_bDisposed ) return; - sal_uInt16 nId( 1 ); + sal_uInt16 nId( 1 ); RemoveControllers(); @@ -262,9 +262,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 92cfa0fa5274..3c71c18c6796 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: */ |