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
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -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 )
|
||||
|
@@ -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;
|
||||
|
@@ -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: */
|
||||
|
Reference in New Issue
Block a user