include/vcl/fieldvalues.hxx | 3 ++- svx/source/dialog/svxruler.cxx | 4 ++-- vcl/source/app/svdata.cxx | 15 +++++++++++++++ vcl/source/control/field.cxx | 4 ++-- 4 files changed, 21 insertions(+), 5 deletions(-)
New commits: commit 8ea0cb60e8b16671cb48d17f11605b3684753264 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Feb 2 12:59:49 2022 +0000 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Fri Feb 4 15:38:38 2022 +0100 tdf#125849 cannot modify the ruler unit of measure in translated UI Change-Id: Ica74dd5e55d30605ee03affa4b724ffa4ec65b5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129333 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/include/vcl/fieldvalues.hxx b/include/vcl/fieldvalues.hxx index e8f78bd5e119..b00fc5a47128 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 43000ea7279c..6e960a18433d 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 f91e1fe67fa9..7574746db780 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 cc5a6330d1a9..281566ed174a 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 )