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
|
// XUIElement
|
||||||
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRealInterface() throw (::com::sun::star::uno::RuntimeException);
|
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRealInterface() throw (::com::sun::star::uno::RuntimeException);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------
|
// cf. ToolbarLayoutManager
|
||||||
// protected methods
|
void populateImages();
|
||||||
//-------------------------------------------------------------------------------------------------------------
|
|
||||||
private:
|
private:
|
||||||
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
|
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::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;
|
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 <toolbarlayoutmanager.hxx>
|
||||||
|
#include <uielement/addonstoolbarwrapper.hxx>
|
||||||
#include <helpers.hxx>
|
#include <helpers.hxx>
|
||||||
#include <services.h>
|
#include <services.h>
|
||||||
#include <services/layoutmanager.hxx>
|
#include <services/layoutmanager.hxx>
|
||||||
@@ -442,6 +443,7 @@ bool ToolbarLayoutManager::requestToolbar( const OUString& rResourceURL )
|
|||||||
bMustCallCreate = true;
|
bMustCallCreate = true;
|
||||||
|
|
||||||
bool bCreateOrShowToolbar( aRequestedToolbar.m_bVisible & !aRequestedToolbar.m_bMasterHide );
|
bool bCreateOrShowToolbar( aRequestedToolbar.m_bVisible & !aRequestedToolbar.m_bMasterHide );
|
||||||
|
|
||||||
uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow, uno::UNO_QUERY );
|
uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow, uno::UNO_QUERY );
|
||||||
if ( xContainerWindow.is() && aRequestedToolbar.m_bFloating )
|
if ( xContainerWindow.is() && aRequestedToolbar.m_bFloating )
|
||||||
bCreateOrShowToolbar &= bool( xContainerWindow->isActive());
|
bCreateOrShowToolbar &= bool( xContainerWindow->isActive());
|
||||||
@@ -569,6 +571,14 @@ bool ToolbarLayoutManager::showToolbar( const OUString& rResourceURL )
|
|||||||
|
|
||||||
SolarMutexGuard aGuard;
|
SolarMutexGuard aGuard;
|
||||||
Window* pWindow = getWindowFromXUIElement( aUIElement.m_xUIElement );
|
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 ( pWindow )
|
||||||
{
|
{
|
||||||
if ( !aUIElement.m_bFloating )
|
if ( !aUIElement.m_bFloating )
|
||||||
|
@@ -205,7 +205,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue
|
|||||||
if ( m_bDisposed )
|
if ( m_bDisposed )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sal_uInt16 nId( 1 );
|
sal_uInt16 nId( 1 );
|
||||||
|
|
||||||
RemoveControllers();
|
RemoveControllers();
|
||||||
|
|
||||||
@@ -262,9 +262,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue
|
|||||||
|
|
||||||
m_pToolBar->InsertItem( nId, aTitle );
|
m_pToolBar->InsertItem( nId, aTitle );
|
||||||
|
|
||||||
Image aImage = RetrieveImage( m_xFrame, aImageId, aURL, !m_bSmallSymbols );
|
// don't setup images yet, AddonsToolbarWrapper::populateImages does that.
|
||||||
if ( !!aImage )
|
|
||||||
m_pToolBar->SetItemImage( nId, aImage );
|
|
||||||
|
|
||||||
// Create TbRuntimeItemData to hold additional information we will need in the future
|
// Create TbRuntimeItemData to hold additional information we will need in the future
|
||||||
AddonsParams* pRuntimeItemData = new AddonsParams;
|
AddonsParams* pRuntimeItemData = new AddonsParams;
|
||||||
|
@@ -55,7 +55,8 @@ namespace framework
|
|||||||
|
|
||||||
AddonsToolBarWrapper::AddonsToolBarWrapper( const Reference< XComponentContext >& xContext ) :
|
AddonsToolBarWrapper::AddonsToolBarWrapper( const Reference< XComponentContext >& xContext ) :
|
||||||
UIElementWrapperBase( UIElementType::TOOLBAR ),
|
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 >();
|
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
|
} // namespace framework
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
Reference in New Issue
Block a user