framework/source/layoutmanager/toolbarlayoutmanager.cxx |    2 
 framework/source/services/desktop.cxx                   |    2 
 framework/source/services/frame.cxx                     |    2 
 framework/source/uielement/menubarmanager.cxx           |    8 +--
 framework/source/uielement/toolbarmanager.cxx           |    6 +-
 framework/source/uielement/toolbarsmenucontroller.cxx   |    8 ---
 include/unotools/cmdoptions.hxx                         |   10 ----
 sfx2/source/dialog/dinfdlg.cxx                          |    2 
 sw/source/ui/envelp/labprt.cxx                          |    2 
 unotools/source/config/cmdoptions.cxx                   |   33 ++++------------
 10 files changed, 26 insertions(+), 49 deletions(-)

New commits:
commit 41c248e066f454355dcceaa233ccf90f2adaee52
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Jun 6 11:49:27 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Jun 6 17:35:26 2023 +0200

    SvtCommandOptions only supports CMDOPTION_DISABLED
    
    CMDOPTION_NONE is just ignored, so remove this parameter
    
    Change-Id: If9de22a6b0522620a267cbc92b118f79e200d999
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152671
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx 
b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
index b7b1d248564d..846b111d5825 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
@@ -543,7 +543,7 @@ bool ToolbarLayoutManager::createToolbar( const OUString& 
rResourceURL )
             {
                 ToolBox* pToolbar = static_cast<ToolBox *>(pWindow.get());
                 ToolBoxMenuType nMenuType = pToolbar->GetMenuType();
-                if ( aCmdOptions.Lookup( 
SvtCommandOptions::CMDOPTION_DISABLED, "ConfigureDialog" ))
+                if ( aCmdOptions.LookupDisabled( "ConfigureDialog" ))
                     pToolbar->SetMenuType( nMenuType & 
~ToolBoxMenuType::Customize );
                 else
                     pToolbar->SetMenuType( nMenuType | 
ToolBoxMenuType::Customize );
diff --git a/framework/source/services/desktop.cxx 
b/framework/source/services/desktop.cxx
index ea0df283b8a6..35dfcd2e21eb 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -679,7 +679,7 @@ css::uno::Reference< css::frame::XDispatch > SAL_CALL 
Desktop::queryDispatch( co
         m_xCommandOptions.reset(new SvtCommandOptions);
 
     // Make std::unordered_map lookup if the current URL is in the disabled 
list
-    if (m_xCommandOptions && 
m_xCommandOptions->Lookup(SvtCommandOptions::CMDOPTION_DISABLED, aCommand))
+    if (m_xCommandOptions && m_xCommandOptions->LookupDisabled(aCommand))
         return css::uno::Reference< css::frame::XDispatch >();
     else
     {
diff --git a/framework/source/services/frame.cxx 
b/framework/source/services/frame.cxx
index 54df1a7eeac2..659578975a5e 100644
--- a/framework/source/services/frame.cxx
+++ b/framework/source/services/frame.cxx
@@ -2313,7 +2313,7 @@ css::uno::Reference< css::frame::XDispatch > SAL_CALL 
XFrameImpl::queryDispatch(
         aCommand = aURL.Path;
 
     // Make std::unordered_map lookup if the current URL is in the disabled 
list
-    if ( m_aCommandOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, 
aCommand ) )
+    if ( m_aCommandOptions.LookupDisabled( aCommand ) )
         return css::uno::Reference< css::frame::XDispatch >();
     else
     {
diff --git a/framework/source/uielement/menubarmanager.cxx 
b/framework/source/uielement/menubarmanager.cxx
index c7efdb92053d..b5608310188c 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -563,7 +563,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool )
     const StyleSettings& rSettings = 
Application::GetSettings().GetStyleSettings();
     bool bShowMenuImages     = rSettings.GetUseImagesInMenus();
     bool bShowShortcuts      = m_bHasMenuBar || 
rSettings.GetContextMenuShortcuts();
-    bool bHasDisabledEntries = SvtCommandOptions().HasEntries( 
SvtCommandOptions::CMDOPTION_DISABLED );
+    bool bHasDisabledEntries = SvtCommandOptions().HasEntriesDisabled();
 
     SolarMutexGuard g;
 
@@ -657,7 +657,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool )
 
                 if ( bHasDisabledEntries )
                 {
-                    if ( aCmdOptions.Lookup( 
SvtCommandOptions::CMDOPTION_DISABLED, aTargetURL.Path ))
+                    if ( aCmdOptions.LookupDisabled( aTargetURL.Path ))
                         pMenu->HideItem( menuItemHandler->nItemId );
                 }
 
@@ -840,7 +840,7 @@ bool MenuBarManager::MustBeHidden( PopupMenu* pPopupMenu, 
const Reference< XURLT
                 aTargetURL.Complete = pPopupMenu->GetItemCommand( nId );
                 rTransformer->parseStrict( aTargetURL );
 
-                if ( aCmdOptions.Lookup( 
SvtCommandOptions::CMDOPTION_DISABLED, aTargetURL.Path ))
+                if ( aCmdOptions.LookupDisabled( aTargetURL.Path ))
                     ++nHideCount;
             }
         }
@@ -1241,7 +1241,7 @@ void MenuBarManager::FillMenuWithConfiguration(
                                      
AddonsOptions().GetMergeMenuInstructions(),
                                      rModuleIdentifier );
 
-    bool bHasDisabledEntries = SvtCommandOptions().HasEntries( 
SvtCommandOptions::CMDOPTION_DISABLED );
+    bool bHasDisabledEntries = SvtCommandOptions().HasEntriesDisabled();
     if ( !bHasDisabledEntries )
         return;
 
diff --git a/framework/source/uielement/toolbarmanager.cxx 
b/framework/source/uielement/toolbarmanager.cxx
index 85fad251be05..5278906f8eae 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -594,7 +594,7 @@ void ToolBarManager::Init()
     // enables a menu for clipped items and customization
     SvtCommandOptions aCmdOptions;
     ToolBoxMenuType nMenuType = ToolBoxMenuType::ClippedItems;
-    if ( !aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, 
"CreateDialog"))
+    if ( !aCmdOptions.LookupDisabled( "CreateDialog"))
          nMenuType |= ToolBoxMenuType::Customize;
 
     m_pImpl->SetMenuType( nMenuType );
@@ -1032,7 +1032,7 @@ void ToolBarManager::CreateControllers()
     Reference< XWindow > xToolbarWindow = m_pImpl->GetInterface();
 
     css::util::URL      aURL;
-    bool                bHasDisabledEntries = SvtCommandOptions().HasEntries( 
SvtCommandOptions::CMDOPTION_DISABLED );
+    bool                bHasDisabledEntries = 
SvtCommandOptions().HasEntriesDisabled();
     SvtCommandOptions   aCmdOptions;
 
     for ( ToolBox::ImplToolItems::size_type i = 0; i < 
m_pImpl->GetItemCount(); i++ )
@@ -1056,7 +1056,7 @@ void ToolBarManager::CreateControllers()
         {
             aURL.Complete = aCommandURL;
             m_xURLTransformer->parseStrict( aURL );
-            if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, 
aURL.Path ))
+            if ( aCmdOptions.LookupDisabled( aURL.Path ))
             {
                 m_aControllerMap[ nId ] = xController;
                 m_pImpl->HideItem( nId, aCommandURL );
diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx 
b/framework/source/uielement/toolbarsmenucontroller.cxx
index c4c8c3f73e1f..1378645ce07e 100644
--- a/framework/source/uielement/toolbarsmenucontroller.cxx
+++ b/framework/source/uielement/toolbarsmenucontroller.cxx
@@ -410,12 +410,8 @@ void ToolbarsMenuController::fillPopupMenu( Reference< 
css::awt::XPopupMenu > co
     bool          bAddCommand( true );
     SvtCommandOptions aCmdOptions;
 
-    if ( aCmdOptions.HasEntries( SvtCommandOptions::CMDOPTION_DISABLED ))
-    {
-        if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED,
-                                 "ConfigureDialog"))
-            bAddCommand = false;
-    }
+    if ( aCmdOptions.HasEntriesDisabled() && 
aCmdOptions.LookupDisabled("ConfigureDialog"))
+        bAddCommand = false;
 
     if ( bAddCommand )
     {
diff --git a/include/unotools/cmdoptions.hxx b/include/unotools/cmdoptions.hxx
index bb3414f8ff41..73c76ffa1154 100644
--- a/include/unotools/cmdoptions.hxx
+++ b/include/unotools/cmdoptions.hxx
@@ -64,12 +64,6 @@ class SAL_WARN_UNUSED UNOTOOLS_DLLPUBLIC SvtCommandOptions 
final : public utl::d
     friend class SvtCommandOptions_Impl;
 
 public:
-    enum CmdOption
-    {
-        CMDOPTION_DISABLED,
-        CMDOPTION_NONE
-    };
-
     SvtCommandOptions();
     virtual ~SvtCommandOptions() override;
 
@@ -83,7 +77,7 @@ public:
         @onerror    We return an empty list.
     
**-***************************************************************************************************/
 
-    bool HasEntries(CmdOption eOption) const;
+    bool HasEntriesDisabled() const;
 
     
/*-****************************************************************************************************
         @short      Lookup if a command URL is inside a given list
@@ -93,7 +87,7 @@ public:
         @return     "sal_True" if the command is inside the list otherwise 
"sal_False"
     
**-***************************************************************************************************/
 
-    bool Lookup(CmdOption eOption, const OUString& aCommandURL) const;
+    bool LookupDisabled(const OUString& aCommandURL) const;
 
     
/*-****************************************************************************************************
         @short      register an office frame, which must update its dispatches 
if
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index ece02823fd37..7d97ab8b3ba8 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -718,7 +718,7 @@ SfxDocumentPage::SfxDocumentPage(weld::Container* pPage, 
weld::DialogController*
     // [i96288] Check if the document signature command is enabled
     // on the main list enable/disable the pushbutton accordingly
     SvtCommandOptions aCmdOptions;
-    if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, 
"Signature" ) )
+    if ( aCmdOptions.LookupDisabled( "Signature" ) )
         m_xSignatureBtn->set_sensitive(false);
 }
 
diff --git a/sw/source/ui/envelp/labprt.cxx b/sw/source/ui/envelp/labprt.cxx
index fb48899d61e4..6b1c78f160ae 100644
--- a/sw/source/ui/envelp/labprt.cxx
+++ b/sw/source/ui/envelp/labprt.cxx
@@ -46,7 +46,7 @@ SwLabPrtPage::SwLabPrtPage(weld::Container* pPage, 
weld::DialogController* pCont
     m_xPrtSetup->connect_clicked(LINK(this, SwLabPrtPage, PrtSetupHdl));
 
     SvtCommandOptions aCmdOpts;
-    if (aCmdOpts.Lookup(SvtCommandOptions::CMDOPTION_DISABLED, "Print"))
+    if (aCmdOpts.LookupDisabled("Print"))
     {
         m_xPrinterFrame->hide();
     }
diff --git a/unotools/source/config/cmdoptions.cxx 
b/unotools/source/config/cmdoptions.cxx
index 397e07718bef..ec4e826b8c8a 100644
--- a/unotools/source/config/cmdoptions.cxx
+++ b/unotools/source/config/cmdoptions.cxx
@@ -119,8 +119,8 @@ class SvtCommandOptions_Impl : public ConfigItem
                         => The code exist only for one time and isn't 
duplicated for every instance!
         
*//*-*****************************************************************************************************/
 
-        bool                HasEntries  (   SvtCommandOptions::CmdOption    
eOption     ) const;
-        bool                Lookup      (   SvtCommandOptions::CmdOption    
eCmdOption, const OUString& ) const;
+        bool                HasEntriesDisabled() const;
+        bool                LookupDisabled( const OUString& ) const;
         void EstablishFrameCallback(const css::uno::Reference< 
css::frame::XFrame >& xFrame);
 
     private:
@@ -239,29 +239,16 @@ void SvtCommandOptions_Impl::ImplCommit()
 
 //  public method
 
-bool SvtCommandOptions_Impl::HasEntries( SvtCommandOptions::CmdOption eOption 
) const
+bool SvtCommandOptions_Impl::HasEntriesDisabled() const
 {
-    if ( eOption == SvtCommandOptions::CMDOPTION_DISABLED )
-        return m_aDisabledCommands.HasEntries();
-    else
-        return false;
+    return m_aDisabledCommands.HasEntries();
 }
 
 //  public method
 
-bool SvtCommandOptions_Impl::Lookup( SvtCommandOptions::CmdOption eCmdOption, 
const OUString& aCommand ) const
+bool SvtCommandOptions_Impl::LookupDisabled( const OUString& aCommand ) const
 {
-    switch( eCmdOption )
-    {
-        case SvtCommandOptions::CMDOPTION_DISABLED:
-        {
-            return m_aDisabledCommands.Lookup( aCommand );
-        }
-        default:
-            SAL_WARN( "unotools.config", "SvtCommandOptions_Impl::Lookup() 
Unknown option type given!" );
-    }
-
-    return false;
+    return m_aDisabledCommands.Lookup( aCommand );
 }
 
 //  public method
@@ -323,18 +310,18 @@ SvtCommandOptions::~SvtCommandOptions()
 
 //  public method
 
-bool SvtCommandOptions::HasEntries( CmdOption eOption ) const
+bool SvtCommandOptions::HasEntriesDisabled() const
 {
     std::unique_lock aGuard( GetOwnStaticMutex() );
-    return m_pImpl->HasEntries( eOption );
+    return m_pImpl->HasEntriesDisabled();
 }
 
 //  public method
 
-bool SvtCommandOptions::Lookup( CmdOption eCmdOption, const OUString& 
aCommandURL ) const
+bool SvtCommandOptions::LookupDisabled( const OUString& aCommandURL ) const
 {
     std::unique_lock aGuard( GetOwnStaticMutex() );
-    return m_pImpl->Lookup( eCmdOption, aCommandURL );
+    return m_pImpl->LookupDisabled( aCommandURL );
 }
 
 //  public method

Reply via email to