officecfg/registry/data/org/openoffice/VCL.xcu   |    5 ----
 officecfg/registry/schema/org/openoffice/VCL.xcs |    5 ++++
 vcl/source/window/menu.cxx                       |   24 +++--------------------
 3 files changed, 9 insertions(+), 25 deletions(-)

New commits:
commit 3a8234187977bb5935164b322e1d2dd6cce1eebf
Author:     Gabor Kelemen <[email protected]>
AuthorDate: Sat May 10 15:56:50 2025 +0200
Commit:     Gabor Kelemen <[email protected]>
CommitDate: Thu Jun 19 09:08:20 2025 +0200

    [API CHANGE] Replace VCL Settings with more static ones 
(SuppressAccelerators)
    
    in order to simplify code.
    
    The flexibility provided by the ConfigurableSettings template
    is not really necessary for the simple settings VCL has
    
    Change-Id: Iee125cad1e3f3486f368d9e34b77dbe14b814d0b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185174
    Tested-by: Jenkins
    Reviewed-by: Gabor Kelemen <[email protected]>

diff --git a/officecfg/registry/data/org/openoffice/VCL.xcu 
b/officecfg/registry/data/org/openoffice/VCL.xcu
index f4165f268c50..8899bcc59ec9 100644
--- a/officecfg/registry/data/org/openoffice/VCL.xcu
+++ b/officecfg/registry/data/org/openoffice/VCL.xcu
@@ -19,11 +19,6 @@
 <!DOCTYPE oor:component-data SYSTEM "../../../component-update.dtd">
 <oor:component-data xmlns:oor="http://openoffice.org/2001/registry"; 
xmlns:install="http://openoffice.org/2004/installation"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; oor:name="VCL" 
oor:package="org.openoffice">
   <node oor:name="Settings">
-    <node oor:name="Menu" oor:op="replace">
-      <prop oor:name="SuppressAccelerators" oor:type="xs:string" 
oor:op="replace">
-        <value>false</value>
-      </prop>
-    </node>
     <node oor:name="PrintDialog" oor:op="replace">
       <prop oor:name="Collate" oor:op="replace" oor:type="xs:string">
         <value>true</value>
diff --git a/officecfg/registry/schema/org/openoffice/VCL.xcs 
b/officecfg/registry/schema/org/openoffice/VCL.xcs
index 66d0432803cc..81088b39ee88 100644
--- a/officecfg/registry/schema/org/openoffice/VCL.xcs
+++ b/officecfg/registry/schema/org/openoffice/VCL.xcs
@@ -118,6 +118,11 @@
                     <value>false</value>
                 </prop>
             </group>
+            <group oor:name="Menu">
+                <prop oor:name="SuppressAccelerators" oor:type="xs:boolean" 
oor:nillable="false">
+                    <value>false</value>
+                </prop>
+            </group>
     </group>
   </component>
 </oor:component-schema>
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 632ba6deb314..b85bd19bb98c 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -56,13 +56,12 @@
 #include <vcl/toolkit/unowrap.hxx>
 #include <rtl/ustrbuf.hxx>
 
-#include <configsettings.hxx>
-
 #include <map>
 #include <string_view>
 #include <vector>
 
 #include <officecfg/Office/Common.hxx>
+#include <officecfg/VCL.hxx>
 
 namespace vcl
 {
@@ -80,21 +79,6 @@ using namespace vcl;
 constexpr auto EXTRAITEMHEIGHT = 4;
 constexpr auto SPACE_AROUND_TITLE = 4;
 
-static bool ImplAccelDisabled()
-{
-    // display of accelerator strings may be suppressed via configuration
-    static int nAccelDisabled = -1;
-
-    if( nAccelDisabled == -1 )
-    {
-        OUString aStr =
-            vcl::SettingsConfigItem::get()->
-            getValue( u"Menu"_ustr, u"SuppressAccelerators"_ustr );
-        nAccelDisabled = aStr.equalsIgnoreAsciiCase("true") ? 1 : 0;
-    }
-    return nAccelDisabled == 1;
-}
-
 static void ImplSetMenuItemData( MenuItemData* pData )
 {
     // convert data
@@ -1549,7 +1533,7 @@ Size Menu::ImplCalcSize( vcl::Window* pWin )
             }
 
             // Accel
-            if (!IsMenuBar()&& pData->aAccelKey.GetCode() && 
!ImplAccelDisabled())
+            if (!IsMenuBar()&& pData->aAccelKey.GetCode() && 
!officecfg::VCL::VCLSettings::Menu::SuppressAccelerators::get())
             {
                 OUString aName = pData->aAccelKey.GetName();
                 tools::Long nAccWidth = pWin->GetTextWidth( aName );
@@ -1984,7 +1968,7 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, 
Size const & rSize,
                     }
                     // how much space is there for the text?
                     tools::Long nMaxItemTextWidth = aOutSz.Width() - 
aTmpPos.X() - nExtra - nOuterSpaceX;
-                    if (!IsMenuBar() && pData->aAccelKey.GetCode() && 
!ImplAccelDisabled())
+                    if (!IsMenuBar() && pData->aAccelKey.GetCode() && 
!officecfg::VCL::VCLSettings::Menu::SuppressAccelerators::get())
                     {
                         OUString aAccText = pData->aAccelKey.GetName();
                         nMaxItemTextWidth -= 
rRenderContext.GetTextWidth(aAccText) + 3 * nExtra;
@@ -2024,7 +2008,7 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, 
Size const & rSize,
                 }
 
                 // Accel
-                if (!bLayout && !IsMenuBar() && pData->aAccelKey.GetCode() && 
!ImplAccelDisabled())
+                if (!bLayout && !IsMenuBar() && pData->aAccelKey.GetCode() && 
!officecfg::VCL::VCLSettings::Menu::SuppressAccelerators::get())
                 {
                     OUString aAccText = pData->aAccelKey.GetName();
                     aTmpPos.setX( aOutSz.Width() - 
rRenderContext.GetTextWidth(aAccText) );

Reply via email to