From dd69bde36a4ee4636933a80c0291486593a37670 Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Mon, 6 Jul 2015 02:50:08 +0300 Subject: ToolBarManager: Let XSubToolbarController update itself The doc for XSubToolbarController::updateImage says: "gets called to notify a controller that it should set an image which represents the current selected function. Only the controller instance is able to set the correct image for the current function. A toolbar implementation will ask sub-toolbar controllers to update their image whenever it has to update the images of all its buttons." However, it didn't work that way until now. Steps to reproduce: 1. Open one of the custom shapes dropdowns, and choose a shape other than the default. Note that the button is now updated with the last selection. 2. Change the icon theme. Note that the button shows now the default shape, despite the fact that a future activation of that button, will still draw the last used shape. Change-Id: I9345c9faa17dc82a5f590b242b60751ce5d8e648 Reviewed-on: https://gerrit.libreoffice.org/16781 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky --- framework/source/uielement/toolbarmanager.cxx | 28 ++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'framework') diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index fbb13018278f..ac021706db35 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -331,13 +331,27 @@ void ToolBarManager::RefreshImages() if ( nId > 0 ) { - OUString aCommandURL = m_pToolBar->GetItemCommand( nId ); - Image aImage = GetImageFromURL( m_xFrame, aCommandURL, bBigImages ); - // Try also to query for add-on images before giving up and use an - // empty image. - if ( !aImage ) - aImage = QueryAddonsImage( aCommandURL, bBigImages ); - m_pToolBar->SetItemImage( nId, aImage ); + ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId ); + if ( pIter != m_aControllerMap.end() ) + { + Reference< XSubToolbarController > xController( pIter->second, UNO_QUERY ); + if ( xController.is() && xController->opensSubToolbar() ) + { + // The button should show the last function that was selected from the + // dropdown. The controller should know better than us what it was. + xController->updateImage(); + } + else + { + OUString aCommandURL = m_pToolBar->GetItemCommand( nId ); + Image aImage = GetImageFromURL( m_xFrame, aCommandURL, bBigImages ); + // Try also to query for add-on images before giving up and use an + // empty image. + if ( !aImage ) + aImage = QueryAddonsImage( aCommandURL, bBigImages ); + m_pToolBar->SetItemImage( nId, aImage ); + } + } } } -- cgit