summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-12-10 09:44:39 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-12-10 21:28:13 +0100
commit137c9e826cdce429a004f05bde40d274437d7554 (patch)
tree77c1fef9226f7166031507a6ad424ed2ccd10954 /svx
parentca19ae6e0595f8b69fc4929072636bf10ca3027e (diff)
Related: tdf#129267 format numbers with the UI locale
Change-Id: Ib7712f56140e5ef9a67700c8ea86383adbf2a4fc Reviewed-on: https://gerrit.libreoffice.org/84800 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/inc/spacing.hrc101
-rw-r--r--svx/source/dialog/spacinglistbox.cxx21
2 files changed, 78 insertions, 44 deletions
diff --git a/svx/inc/spacing.hrc b/svx/inc/spacing.hrc
index 82f107fc67db..b8ca2661c528 100644
--- a/svx/inc/spacing.hrc
+++ b/svx/inc/spacing.hrc
@@ -13,60 +13,81 @@
#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+struct measurement
+{
+ const char* key;
+ int twips;
+ int human;
+};
+
// To translators: this is a listbox labelled by "Spacing:", inch units
-const std::pair<const char*, int> RID_SVXSTRARY_SPACING_INCH[] =
+const measurement RID_SVXSTRARY_SPACING_INCH[] =
{
- { NC_("RID_SVXSTRARY_SPACING_INCH", "None"), 0 },
- { NC_("RID_SVXSTRARY_SPACING_INCH", "Extra Small (1/16″)"), 91 },
- { NC_("RID_SVXSTRARY_SPACING_INCH", "Small (1/8″)"), 181 },
- { NC_("RID_SVXSTRARY_SPACING_INCH", "Small Medium (1/4″)"), 363 },
- { NC_("RID_SVXSTRARY_SPACING_INCH", "Medium (3/8″)"), 539 },
- { NC_("RID_SVXSTRARY_SPACING_INCH", "Medium Large (1/2″)"), 720 },
- { NC_("RID_SVXSTRARY_SPACING_INCH", "Large (3/4″)"), 1077 },
- { NC_("RID_SVXSTRARY_SPACING_INCH", "Extra Large (1″)"), 1440 },
- { nullptr, 0 }
+ { NC_("RID_SVXSTRARY_SPACING_INCH", "None"), 0, 0 },
+ { NC_("RID_SVXSTRARY_SPACING_INCH", "Extra Small (1/16″)"), 91, 0 },
+ { NC_("RID_SVXSTRARY_SPACING_INCH", "Small (1/8″)"), 181, 0 },
+ { NC_("RID_SVXSTRARY_SPACING_INCH", "Small Medium (1/4″)"), 363, 0 },
+ { NC_("RID_SVXSTRARY_SPACING_INCH", "Medium (3/8″)"), 539, 0 },
+ { NC_("RID_SVXSTRARY_SPACING_INCH", "Medium Large (1/2″)"), 720, 0 },
+ { NC_("RID_SVXSTRARY_SPACING_INCH", "Large (3/4″)"), 1077, 0 },
+ { NC_("RID_SVXSTRARY_SPACING_INCH", "Extra Large (1″)"), 1440, 0 },
+ { nullptr, 0, 0 }
};
// To translators: this is a listbox labelled by "Spacing:", cm units
-const std::pair<const char*, int> RID_SVXSTRARY_SPACING_CM[] =
+const measurement RID_SVXSTRARY_SPACING_CM[] =
{
- { NC_("RID_SVXSTRARY_SPACING_CM", "None"), 0 },
- { NC_("RID_SVXSTRARY_SPACING_CM", "Extra Small (0.16 cm)"), 91 },
- { NC_("RID_SVXSTRARY_SPACING_CM", "Small (0.32 cm)"), 181 },
- { NC_("RID_SVXSTRARY_SPACING_CM", "Small Medium (0.64 cm)"), 363 },
- { NC_("RID_SVXSTRARY_SPACING_CM", "Medium (0.95 cm)"), 539 },
- { NC_("RID_SVXSTRARY_SPACING_CM", "Medium Large (1.27 cm)"), 720 },
- { NC_("RID_SVXSTRARY_SPACING_CM", "Large (1.9 cm)"), 1077 },
- { NC_("RID_SVXSTRARY_SPACING_CM", "Extra Large (2.54 cm)"), 1440 },
- { nullptr, 0 }
+ { NC_("RID_SVXSTRARY_SPACING_CM", "None"), 0, 0 },
+ // Extra Small (0.16 cm)
+ { NC_("RID_SVXSTRARY_SPACING_CM", "Extra Small (%1)"), 91, 16 },
+ // Small (0.32 cm)
+ { NC_("RID_SVXSTRARY_SPACING_CM", "Small (%1)"), 181, 32 },
+ // Small Medium (0.64 cm)
+ { NC_("RID_SVXSTRARY_SPACING_CM", "Small Medium (%1)"), 363, 64 },
+ // Medium (0.95 cm)
+ { NC_("RID_SVXSTRARY_SPACING_CM", "Medium (%1)"), 539, 95 },
+ // Medium Large (1.27 cm)
+ { NC_("RID_SVXSTRARY_SPACING_CM", "Medium Large (%1)"), 720, 127 },
+ // Large (1.9 cm)
+ { NC_("RID_SVXSTRARY_SPACING_CM", "Large (%1)"), 1077, 190 },
+ // Extra Large (2.54 cm)
+ { NC_("RID_SVXSTRARY_SPACING_CM", "Extra Large (%1)"), 1440, 254 },
+ { nullptr, 0, 0 }
};
// To translators: this is a listbox labelled by "Margins:", inch units
-const std::pair<const char*, int> RID_SVXSTRARY_MARGINS_INCH[] =
+const measurement RID_SVXSTRARY_MARGINS_INCH[] =
{
- { NC_("RID_SVXSTRARY_MARGINS_INCH", "None"), 0 },
- { NC_("RID_SVXSTRARY_MARGINS_INCH", "Extra Small (1/16″)"), 91 },
- { NC_("RID_SVXSTRARY_MARGINS_INCH", "Small (1/8″)"), 181 },
- { NC_("RID_SVXSTRARY_MARGINS_INCH", "Small Medium (1/4″)"), 363 },
- { NC_("RID_SVXSTRARY_MARGINS_INCH", "Medium (3/8″)"), 539 },
- { NC_("RID_SVXSTRARY_MARGINS_INCH", "Medium Large (1/2″)"), 720 },
- { NC_("RID_SVXSTRARY_MARGINS_INCH", "Large (3/4″)"), 1077 },
- { NC_("RID_SVXSTRARY_MARGINS_INCH", "Extra Large (1″)"), 1440 },
- { nullptr, 0 }
+ { NC_("RID_SVXSTRARY_MARGINS_INCH", "None"), 0, 0 },
+ { NC_("RID_SVXSTRARY_MARGINS_INCH", "Extra Small (1/16″)"), 91, 0 },
+ { NC_("RID_SVXSTRARY_MARGINS_INCH", "Small (1/8″)"), 181, 0 },
+ { NC_("RID_SVXSTRARY_MARGINS_INCH", "Small Medium (1/4″)"), 363, 0 },
+ { NC_("RID_SVXSTRARY_MARGINS_INCH", "Medium (3/8″)"), 539, 0 },
+ { NC_("RID_SVXSTRARY_MARGINS_INCH", "Medium Large (1/2″)"), 720, 0 },
+ { NC_("RID_SVXSTRARY_MARGINS_INCH", "Large (3/4″)"), 1077, 0 },
+ { NC_("RID_SVXSTRARY_MARGINS_INCH", "Extra Large (1″)"), 1440, 0 },
+ { nullptr, 0, 0 }
};
// To translators: this is a listbox labelled by "Margins:", cm units
-const std::pair<const char*, int> RID_SVXSTRARY_MARGINS_CM[] =
+const measurement RID_SVXSTRARY_MARGINS_CM[] =
{
- { NC_("RID_SVXSTRARY_MARGINS_CM", "None"), 0 },
- { NC_("RID_SVXSTRARY_MARGINS_CM", "Extra Small (0.16 cm)"), 91 },
- { NC_("RID_SVXSTRARY_MARGINS_CM", "Small (0.32 cm)"), 181 },
- { NC_("RID_SVXSTRARY_MARGINS_CM", "Small Medium (0.64 cm)"), 363 },
- { NC_("RID_SVXSTRARY_MARGINS_CM", "Medium (0.95 cm)"), 539 },
- { NC_("RID_SVXSTRARY_MARGINS_CM", "Medium Large (1.27 cm)"), 720 },
- { NC_("RID_SVXSTRARY_MARGINS_CM", "Large (1.9 cm)"), 1077 },
- { NC_("RID_SVXSTRARY_MARGINS_CM", "Extra Large (2.54 cm)"), 1440 },
- { nullptr, 0 }
+ { NC_("RID_SVXSTRARY_MARGINS_CM", "None"), 0, 0 },
+ // Extra Small (0.16 cm)
+ { NC_("RID_SVXSTRARY_MARGINS_CM", "Extra Small (%1)"), 91, 16 },
+ // Small (0.32 cm)
+ { NC_("RID_SVXSTRARY_MARGINS_CM", "Small (%1)"), 181, 32 },
+ // Small Medium (0.64 cm)
+ { NC_("RID_SVXSTRARY_MARGINS_CM", "Small Medium (%1)"), 363, 64 },
+ // Medium (0.95 cm)
+ { NC_("RID_SVXSTRARY_MARGINS_CM", "Medium (%1)"), 539, 95 },
+ // Medium Large (1.27 cm)
+ { NC_("RID_SVXSTRARY_MARGINS_CM", "Medium Large (%1)"), 720, 127 },
+ // Large (1.9 cm)
+ { NC_("RID_SVXSTRARY_MARGINS_CM", "Large (%1)"), 1077, 190 },
+ // Extra Large (2.54 cm)
+ { NC_("RID_SVXSTRARY_MARGINS_CM", "Extra Large (%1)"), 1440, 254 },
+ { nullptr, 0, 0 }
};
#endif
diff --git a/svx/source/dialog/spacinglistbox.cxx b/svx/source/dialog/spacinglistbox.cxx
index 85ebc624931c..90654618f994 100644
--- a/svx/source/dialog/spacinglistbox.cxx
+++ b/svx/source/dialog/spacinglistbox.cxx
@@ -19,7 +19,11 @@
#include <svx/strings.hrc>
#include <svx/dialmgr.hxx>
#include <svx/spacinglistbox.hxx>
+#include <unotools/localedatawrapper.hxx>
#include <vcl/builderfactory.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/weld.hxx>
#include <spacing.hrc>
SpacingListBox::SpacingListBox(vcl::Window* pParent)
@@ -34,29 +38,38 @@ void SpacingListBox::Init(SpacingType eType)
nSelected = 0;
Clear();
- const std::pair<const char*, int>* pResources;
+ const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper();
+ OUString sSuffix;
+
+ const measurement* pResources;
switch (eType)
{
case SpacingType::SPACING_INCH:
pResources = RID_SVXSTRARY_SPACING_INCH;
+ sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH);
break;
case SpacingType::MARGINS_INCH:
pResources = RID_SVXSTRARY_MARGINS_INCH;
+ sSuffix = weld::MetricSpinButton::MetricToString(FieldUnit::INCH);
break;
case SpacingType::SPACING_CM:
pResources = RID_SVXSTRARY_SPACING_CM;
+ sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM);
break;
default:
case SpacingType::MARGINS_CM:
+ sSuffix = " " + weld::MetricSpinButton::MetricToString(FieldUnit::CM);
pResources = RID_SVXSTRARY_MARGINS_CM;
break;
}
- while (pResources->first)
+ while (pResources->key)
{
- OUString aStr = SvxResId(pResources->first);
- sal_uInt16 nData = pResources->second;
+ OUString sMeasurement = rLocaleData.getNum(pResources->human, 2, true, false) + sSuffix;
+ OUString aStr = SvxResId(pResources->key).replaceFirst("%1", sMeasurement);
+ sal_uInt16 nData = pResources->twips;
sal_Int32 nPos = InsertEntry( aStr );
+
SetEntryData( nPos, reinterpret_cast<void*>(static_cast<sal_uLong>(nData)) );
++pResources;
}