summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2016-11-06 21:31:15 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2016-11-06 21:37:27 +0200
commitcea3b8762bfb7f0da19bab8a3d468bcbf987eb0f (patch)
treed4708f1e6af17ebcd6f9fb9772618bd5bba5273b /framework
parent5bd6b61a7cad81d8385e5bc4ea0e6546b1eb7314 (diff)
NewMenuController: Fix template manager icon
The current logic is swapped. MenuAttributes::aImageId can be only handled by SvFileInformationManager, while the menu item command is what might be (in case of .uno command) handled by CommandInfoProvider. This gone wrong in tdf#96059 which wrongly assumed that GetImageFromURL is equivalent to what's provided by CommandInfoProvider (so other places should be checked too). Change-Id: Ia487c602753dde3fb0d0462ef4b3d63209398b36
Diffstat (limited to 'framework')
-rw-r--r--framework/source/uielement/newmenucontroller.cxx33
1 files changed, 8 insertions, 25 deletions
diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx
index 09ca33e28f5c..e8963fd76e88 100644
--- a/framework/source/uielement/newmenucontroller.cxx
+++ b/framework/source/uielement/newmenucontroller.cxx
@@ -72,7 +72,6 @@ DEFINE_INIT_SERVICE ( NewMenuController, {} )
void NewMenuController::setMenuImages( PopupMenu* pPopupMenu, bool bSetImages )
{
sal_uInt16 nItemCount = pPopupMenu->GetItemCount();
- Image aImage;
Reference< XFrame > xFrame( m_xFrame );
for ( sal_uInt16 i = 0; i < nItemCount; i++ )
@@ -82,39 +81,23 @@ void NewMenuController::setMenuImages( PopupMenu* pPopupMenu, bool bSetImages )
{
if ( bSetImages )
{
- bool bImageSet( false );
OUString aImageId;
-
+ OUString aCmd( pPopupMenu->GetItemCommand( nItemId ) );
sal_uLong nAttributePtr = pPopupMenu->GetUserValue(sal::static_int_cast<sal_uInt16>(i));
MenuAttributes* pAttributes = reinterpret_cast<MenuAttributes *>(nAttributePtr);
if (pAttributes)
aImageId = pAttributes->aImageId;
- if ( !aImageId.isEmpty() )
- {
- aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aImageId, xFrame);
- if ( !!aImage )
- {
- bImageSet = true;
- pPopupMenu->SetItemImage( nItemId, aImage );
- }
- }
-
- if ( !bImageSet )
- {
- OUString aCmd( pPopupMenu->GetItemCommand( nItemId ) );
- if ( !aCmd.isEmpty() )
- {
- INetURLObject aURLObj( aCmd );
- aImage = SvFileInformationManager::GetImageNoDefault( aURLObj );
- }
+ INetURLObject aURLObj( aImageId.isEmpty() ? aCmd : aImageId );
+ Image aImage = SvFileInformationManager::GetImageNoDefault( aURLObj );
+ if ( !aImage )
+ aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aCmd, xFrame);
- if ( !!aImage )
- pPopupMenu->SetItemImage( nItemId, aImage );
- }
+ if ( !!aImage )
+ pPopupMenu->SetItemImage( nItemId, aImage );
}
else
- pPopupMenu->SetItemImage( nItemId, aImage );
+ pPopupMenu->SetItemImage( nItemId, Image() );
}
}
}