diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2017-05-09 14:51:57 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2017-05-09 18:49:18 +0200 |
commit | a7851b522cd0e33c391037c1aaa901b8d675ad7a (patch) | |
tree | c2f6c340299ce40d63908c7b328171ce991e7efa /cui | |
parent | fd6150b49356c3cb5c4f44700392143ce5aa6001 (diff) |
tdf#103491 Show correct label for the current UI element type
Change-Id: Ia7ad3c9e6d70fd47aa8346403682a17a70c5c237
Reviewed-on: https://gerrit.libreoffice.org/37432
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Tested-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/customize/cfg.cxx | 45 | ||||
-rw-r--r-- | cui/source/inc/cfg.hxx | 2 |
2 files changed, 34 insertions, 13 deletions
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 5122f35908ee..92c3422731ce 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -22,6 +22,7 @@ #include <cassert> #include <stdlib.h> #include <time.h> +#include <typeinfo> #include <vcl/commandinfoprovider.hxx> #include <vcl/help.hxx> @@ -949,12 +950,12 @@ MenuSaveInData::GetEntries() if ( m_xMenuSettings.is() ) { - LoadSubMenus( m_xMenuSettings, OUString(), pRootEntry ); + LoadSubMenus( m_xMenuSettings, OUString(), pRootEntry, false ); } else if ( GetDefaultData() != nullptr ) { // If the doc has no config settings use module config settings - LoadSubMenus( GetDefaultData()->m_xMenuSettings, OUString(), pRootEntry ); + LoadSubMenus( GetDefaultData()->m_xMenuSettings, OUString(), pRootEntry, false ); } } @@ -971,10 +972,8 @@ MenuSaveInData::SetEntries( SvxEntries* pNewEntries ) pRootEntry->SetEntries( pNewEntries ); } -bool SaveInData::LoadSubMenus( - const uno::Reference< container::XIndexAccess >& xMenuSettings, - const OUString& rBaseTitle, - SvxConfigEntry* pParentData ) +bool SaveInData::LoadSubMenus( const uno::Reference< container::XIndexAccess >& xMenuSettings, + const OUString& rBaseTitle, SvxConfigEntry* pParentData, bool bContextMenu ) { SvxEntries* pEntries = pParentData->GetEntries(); @@ -1019,14 +1018,29 @@ bool SaveInData::LoadSubMenus( uno::Sequence< beans::PropertyValue > aPropSeq; if ( a >>= aPropSeq ) { + OUString aMenuLabel; for ( sal_Int32 i = 0; i < aPropSeq.getLength(); ++i ) { - if ( aPropSeq[i].Name == ITEM_DESCRIPTOR_LABEL ) + if ( bContextMenu ) + { + if ( aPropSeq[i].Name == "PopupLabel" ) + { + aPropSeq[i].Value >>= aLabel; + break; + } + else if ( aPropSeq[i].Name == "Label" ) + { + aPropSeq[i].Value >>= aMenuLabel; + } + } + else if ( aPropSeq[i].Name == "Label" ) { aPropSeq[i].Value >>= aLabel; break; } } + if ( aLabel.isEmpty() ) + aLabel = aMenuLabel; } } @@ -1055,7 +1069,7 @@ bool SaveInData::LoadSubMenus( subMenuTitle += stripHotKey( aLabel ); - LoadSubMenus( xSubMenu, subMenuTitle, pEntry ); + LoadSubMenus( xSubMenu, subMenuTitle, pEntry, bContextMenu ); } } else @@ -1315,7 +1329,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries() SvxConfigEntry* pEntry = new SvxConfigEntry( aUIMenuName, aUrl, true ); pEntry->SetMain(); m_pRootEntry->GetEntries()->push_back( pEntry ); - LoadSubMenus( xPopupMenu, aUIMenuName, pEntry ); + LoadSubMenus( xPopupMenu, aUIMenuName, pEntry, true ); } } @@ -1360,7 +1374,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries() SvxConfigEntry* pEntry = new SvxConfigEntry( aUIMenuName, aUrl, true, true ); pEntry->SetMain(); m_pRootEntry->GetEntries()->push_back( pEntry ); - LoadSubMenus( xPopupMenu, aUIMenuName, pEntry ); + LoadSubMenus( xPopupMenu, aUIMenuName, pEntry, true ); } } std::sort( m_pRootEntry->GetEntries()->begin(), m_pRootEntry->GetEntries()->end(), EntrySort ); @@ -2123,8 +2137,15 @@ SvTreeListEntry* SvxConfigPage::AddFunction( return nullptr; } + OUString aDisplayName; OUString aModuleId = vcl::CommandInfoProvider::GetModuleIdentifier( m_xFrame ); - OUString aDisplayName = vcl::CommandInfoProvider::GetMenuLabelForCommand( aURL, aModuleId ); + + if ( typeid(*pCurrentSaveInData) == typeid(ContextMenuSaveInData) ) + aDisplayName = vcl::CommandInfoProvider::GetPopupLabelForCommand( aURL, aModuleId ); + else if ( typeid(*pCurrentSaveInData) == typeid(MenuSaveInData) ) + aDisplayName = vcl::CommandInfoProvider::GetMenuLabelForCommand( aURL, aModuleId ); + else + aDisplayName = vcl::CommandInfoProvider::GetLabelForCommand( aURL, aModuleId ); SvxConfigEntry* pNewEntryData = new SvxConfigEntry( aDisplayName, aURL, false ); @@ -4315,7 +4336,7 @@ void ToolbarSaveInData::LoadToolbar( { for ( sal_Int32 i = 0; i < aPropSeq.getLength(); ++i ) { - if ( aPropSeq[i].Name == ITEM_DESCRIPTOR_LABEL ) + if ( aPropSeq[i].Name == "Name" ) { aPropSeq[i].Value >>= aLabel; break; diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx index 40dc23710dc7..329b69526522 100644 --- a/cui/source/inc/cfg.hxx +++ b/cui/source/inc/cfg.hxx @@ -105,7 +105,7 @@ protected: bool LoadSubMenus( const css::uno::Reference< css::container::XIndexAccess >& xMenuSettings, - const OUString& rBaseTitle, SvxConfigEntry* pParentData ); + const OUString& rBaseTitle, SvxConfigEntry* pParentData, bool bContextMenu ); public: |