include/vcl/fieldvalues.hxx    |    6 +++++-
 svx/source/dialog/svxruler.cxx |    4 ++--
 vcl/source/app/svdata.cxx      |    4 ++--
 3 files changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 5337675a31a4aad5151691b9c7587bd4b3140715
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Mon Mar 14 08:05:40 2022 +0100
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Mon Mar 14 10:39:48 2022 +0100

    Simplify vcl::EnglishStringToMetric
    
    Change-Id: I10b93a073a58c175d487b7aac3a65d461974eb6a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131514
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/include/vcl/fieldvalues.hxx b/include/vcl/fieldvalues.hxx
index b00fc5a47128..999f3e5fa355 100644
--- a/include/vcl/fieldvalues.hxx
+++ b/include/vcl/fieldvalues.hxx
@@ -20,6 +20,10 @@
 #ifndef INCLUDED_VCL_FIELDVALUES_HXX
 #define INCLUDED_VCL_FIELDVALUES_HXX
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <vcl/dllapi.h>
 #include <rtl/ustring.hxx>
 #include <tools/fldunit.hxx>
@@ -29,7 +33,7 @@ class LocaleDataWrapper;
 
 namespace vcl
 {
-VCL_DLLPUBLIC FieldUnit EnglishStringToMetric(const OUString& 
rEnglishMetricString);
+VCL_DLLPUBLIC FieldUnit EnglishStringToMetric(std::string_view 
rEnglishMetricString);
 
 VCL_DLLPUBLIC bool TextToValue(const OUString& rStr, double& rValue, sal_Int64 
nBaseValue,
                                sal_uInt16 nDecDigits, const LocaleDataWrapper& 
rLocaleDataWrapper,
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index ddbf54445a76..ca680dd09bb9 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -3267,7 +3267,7 @@ void SvxRuler::MenuSelect(std::string_view ident)
     if (ident.empty())
         return;
     /* Handler of the context menus for switching the unit of measurement */
-    SetUnit(vcl::EnglishStringToMetric(OUString::fromUtf8(ident)));
+    SetUnit(vcl::EnglishStringToMetric(ident));
 }
 
 void SvxRuler::TabMenuSelect(const OString& rIdent)
@@ -3348,7 +3348,7 @@ void SvxRuler::Command( const CommandEvent& rCommandEvent 
)
             for ( sal_uInt16 i = nCount; i; --i )
             {
                 OString sIdent = xMenu->get_id(i - 1);
-                FieldUnit eMenuUnit = 
vcl::EnglishStringToMetric(OUString::fromUtf8(sIdent));
+                FieldUnit eMenuUnit = vcl::EnglishStringToMetric(sIdent);
                 xMenu->set_active(sIdent, eMenuUnit == eUnit);
                 if( bReduceMetric )
                 {
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index cb553176cc36..68884767406b 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -279,12 +279,12 @@ const FieldUnitStringList& ImplGetFieldUnits()
 
 namespace vcl
 {
-    FieldUnit EnglishStringToMetric(const OUString& rEnglishMetricString)
+    FieldUnit EnglishStringToMetric(std::string_view rEnglishMetricString)
     {
         sal_uInt32 nUnits = SAL_N_ELEMENTS(SV_FUNIT_STRINGS);
         for (sal_uInt32 i = 0; i < nUnits; ++i)
         {
-            if (rEnglishMetricString.toUtf8() == 
SV_FUNIT_STRINGS[i].first.mpId)
+            if (rEnglishMetricString == SV_FUNIT_STRINGS[i].first.mpId)
                 return SV_FUNIT_STRINGS[i].second;
         }
         return FieldUnit::NONE;

Reply via email to