summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-02-02 12:59:49 +0000
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2022-02-04 15:39:25 +0100
commit61339f316ec7a91733b62ca667faeca0b75297e9 (patch)
tree99a59e0a4ba3afdc5eb36cd7592f1b7aebc05180
parenttdf#137920 sw: avoid layout loop when inserting at-char anchored large image (diff)
downloadcore-61339f316ec7a91733b62ca667faeca0b75297e9.tar.gz
core-61339f316ec7a91733b62ca667faeca0b75297e9.zip
tdf#125849 cannot modify the ruler unit of measure in translated UI
Change-Id: Ica74dd5e55d30605ee03affa4b724ffa4ec65b5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129334 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--include/vcl/fieldvalues.hxx3
-rw-r--r--svx/source/dialog/svxruler.cxx4
-rw-r--r--vcl/source/app/svdata.cxx17
-rw-r--r--vcl/source/control/field.cxx4
4 files changed, 23 insertions, 5 deletions
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 e6b57aac5fb7..6b27d7ce722d 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 1d1375b24d7b..7d815ad0acc9 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>
@@ -277,6 +278,22 @@ 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)
+ {
+ const char *pId = strchr(SV_FUNIT_STRINGS[i].first, '\004');
+ assert(pId);
+ if (rEnglishMetricString.equalsAscii(pId+1))
+ 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 )