diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2015-12-27 23:02:19 +0200 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2015-12-27 23:18:40 +0200 |
commit | 0c4bd60eed821990247c1a64e1602e3a090b003d (patch) | |
tree | 3bd4808104b35be05c0e134d42f2a717a6b65421 /cui | |
parent | 466d2389cc3157a87d9cdb8a8c8d4b4e2f1849dc (diff) |
Don't allow customizing menus without UI name
If a developer wants a menu to be customizable, he'll
probably set a name to show in the UI, not just leave
the file name. The plan is to use popupmenus for
different kind of things, like menubar sub-menus,
toolbar buttons etc., not just as a context menus,
and we don't want let people customize some of those.
Change-Id: Ie258aa13924c10a26c9279793e64805dd000e285
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/customize/cfg.cxx | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 9f6c8fd4bd44..0b9fa2848079 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -1403,7 +1403,10 @@ SvxEntries* ContextMenuSaveInData::GetEntries() for ( const auto& aElementProp : aElement ) { if ( aElementProp.Name == ITEM_DESCRIPTOR_RESOURCEURL ) + { aElementProp.Value >>= aUrl; + break; + } } css::uno::Reference< css::container::XIndexAccess > xPopupMenu; @@ -1416,13 +1419,13 @@ SvxEntries* ContextMenuSaveInData::GetEntries() if ( xPopupMenu.is() ) { - OUString aMenuName = aUrl.copy( aUrl.lastIndexOf( '/' ) + 1 ); + // insert into std::unordered_map to filter duplicates from the parent + aMenuInfo.insert( MenuInfo::value_type( aUrl, true ) ); + OUString aUIMenuName = GetUIName( aUrl ); if ( aUIMenuName.isEmpty() ) - aUIMenuName = aMenuName; - - // insert into std::unordered_map to filter duplicates from the parent - aMenuInfo.insert( MenuInfo::value_type( aMenuName, true ) ); + // Menus without UI name aren't supposed to be customized. + continue; SvxConfigEntry* pEntry = new SvxConfigEntry( aUIMenuName, aUrl, true ); pEntry->SetMain(); @@ -1444,20 +1447,20 @@ SvxEntries* ContextMenuSaveInData::GetEntries() for ( const auto& aElement : aParentElementsInfo ) { - OUString aUrl, aMenuName; + OUString aUrl; for ( const auto& aElementProp : aElement ) { if ( aElementProp.Name == ITEM_DESCRIPTOR_RESOURCEURL ) { aElementProp.Value >>= aUrl; - aMenuName = aUrl.copy( aUrl.lastIndexOf( '/' ) + 1 ); + break; } } css::uno::Reference< css::container::XIndexAccess > xPopupMenu; try { - if ( aMenuInfo.find( aMenuName ) == aMenuInfo.end() ) + if ( aMenuInfo.find( aUrl ) == aMenuInfo.end() ) xPopupMenu = xParentCfgMgr->getSettings( aUrl, sal_False ); } catch ( const css::uno::Exception& ) @@ -1467,7 +1470,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries() { OUString aUIMenuName = GetUIName( aUrl ); if ( aUIMenuName.isEmpty() ) - aUIMenuName = aMenuName; + continue; SvxConfigEntry* pEntry = new SvxConfigEntry( aUIMenuName, aUrl, true, true ); pEntry->SetMain(); |