summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2015-07-06 02:50:08 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2015-07-06 14:54:54 +0000
commitdd69bde36a4ee4636933a80c0291486593a37670 (patch)
tree5636f3de7e1cef26ea3fa2716aff681b1efdc1c2
parentae20b8147307de84318598be72977abc3f7bdda9 (diff)
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 <ci@libreoffice.org> Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
-rw-r--r--framework/source/uielement/toolbarmanager.cxx28
1 files changed, 21 insertions, 7 deletions
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 );
+ }
+ }
}
}