[Libreoffice-commits] core.git: cui/source

Maxim Monastirsky momonasmon at gmail.com
Sun Dec 27 13:22:19 PST 2015


 cui/source/customize/cfg.cxx |   21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

New commits:
commit 0c4bd60eed821990247c1a64e1602e3a090b003d
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date:   Sun Dec 27 23:02:19 2015 +0200

    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

diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 9f6c8fd..0b9fa28 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();


More information about the Libreoffice-commits mailing list