tdf#125849 cannot modify the ruler unit of measure in translated UI

Change-Id: Ica74dd5e55d30605ee03affa4b724ffa4ec65b5a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129357
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/vcl/fieldvalues.hxx b/include/vcl/fieldvalues.hxx
index e8f78bd..b00fc5a 100644
--- a/include/vcl/fieldvalues.hxx
+++ b/include/vcl/fieldvalues.hxx
@@ -29,7 +29,8 @@ class LocaleDataWrapper;

namespace vcl
{
VCL_DLLPUBLIC FieldUnit StringToMetric(const OUString& rMetricString);
VCL_DLLPUBLIC FieldUnit EnglishStringToMetric(const OUString& rEnglishMetricString);

VCL_DLLPUBLIC bool TextToValue(const OUString& rStr, double& rValue, sal_Int64 nBaseValue,
                               sal_uInt16 nDecDigits, const LocaleDataWrapper& rLocaleDataWrapper,
                               FieldUnit eUnit);
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index 43000ea..6e960a1 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -3257,7 +3257,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::StringToMetric(OUString::fromUtf8(ident)));
    SetUnit(vcl::EnglishStringToMetric(OUString::fromUtf8(ident)));
}

void SvxRuler::TabMenuSelect(const OString& rIdent)
@@ -3338,7 +3338,7 @@ void SvxRuler::Command( const CommandEvent& rCommandEvent )
            for ( sal_uInt16 i = nCount; i; --i )
            {
                OString sIdent = xMenu->get_id(i - 1);
                FieldUnit eMenuUnit = vcl::StringToMetric(OUString::fromUtf8(sIdent));
                FieldUnit eMenuUnit = vcl::EnglishStringToMetric(OUString::fromUtf8(sIdent));
                xMenu->set_active(sIdent, eMenuUnit == eUnit);
                if( bReduceMetric )
                {
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 7ba78527..1493729 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -29,6 +29,7 @@
#include <vcl/QueueInfo.hxx>
#include <vcl/cvtgrf.hxx>
#include <vcl/dockwin.hxx>
#include <vcl/fieldvalues.hxx>
#include <vcl/menu.hxx>
#include <vcl/print.hxx>
#include <vcl/settings.hxx>
@@ -276,6 +277,20 @@ const FieldUnitStringList& ImplGetFieldUnits()
    return pSVData->maCtrlData.maFieldUnitStrings;
}

namespace vcl
{
    FieldUnit EnglishStringToMetric(const OUString& rEnglishMetricString)
    {
        sal_uInt32 nUnits = SAL_N_ELEMENTS(SV_FUNIT_STRINGS);
        for (sal_uInt32 i = 0; i < nUnits; ++i)
        {
            if (rEnglishMetricString.equalsAscii(SV_FUNIT_STRINGS[i].first.mpId))
                return SV_FUNIT_STRINGS[i].second;
        }
        return FieldUnit::NONE;
    }
}

const FieldUnitStringList& ImplGetCleanedFieldUnits()
{
    ImplSVData* pSVData = ImplGetSVData();
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 7fabe96..0e00937 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -960,7 +960,7 @@ static OUString ImplMetricToString( FieldUnit rUnit )
    return OUString();
}

namespace vcl
namespace
{
    FieldUnit StringToMetric(const OUString &rMetricString)
    {
@@ -979,7 +979,7 @@ namespace vcl
static FieldUnit ImplMetricGetUnit(const OUString& rStr)
{
    OUString aStr = ImplMetricGetUnitText(rStr);
    return vcl::StringToMetric(aStr);
    return StringToMetric(aStr);
}

static FieldUnit ImplMap2FieldUnit( MapUnit meUnit, tools::Long& nDecDigits )