summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-04-02 15:30:08 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-04-02 21:54:03 +0200
commitfa8822c48e2a79589bebbd015b36d1da8b338cc2 (patch)
tree0e3c8c305f08a2dee687e540b4795e7de90ad20f /svtools
parent5d5a7293bf6a49b1828bdd9fdff989f0a9cd2e53 (diff)
weld SwTableWidthDlg
Change-Id: I272a783c9b7a8f725314e416fbd81217105ee5a6 Reviewed-on: https://gerrit.libreoffice.org/52266 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/misc/unitconv.cxx54
1 files changed, 54 insertions, 0 deletions
diff --git a/svtools/source/misc/unitconv.cxx b/svtools/source/misc/unitconv.cxx
index 88845fe9794b..f99b2806076c 100644
--- a/svtools/source/misc/unitconv.cxx
+++ b/svtools/source/misc/unitconv.cxx
@@ -19,6 +19,60 @@
#include <svtools/unitconv.hxx>
+void SetFieldUnit(weld::MetricSpinButton& rField, FieldUnit eUnit, bool bAll)
+{
+ int nMin, nMax;
+ rField.get_range(nMin, nMax, FUNIT_TWIP);
+ nMin = rField.denormalize(nMin);
+ nMax = rField.denormalize(nMax);
+
+ if (!bAll)
+ {
+ switch (eUnit)
+ {
+ case FUNIT_M:
+ case FUNIT_KM:
+ eUnit = FUNIT_CM;
+ break;
+ case FUNIT_FOOT:
+ case FUNIT_MILE:
+ eUnit = FUNIT_INCH;
+ break;
+ default: //prevent warning
+ break;
+ }
+ }
+
+ rField.set_unit(eUnit);
+
+ if (FUNIT_POINT == eUnit && rField.get_digits() > 1)
+ rField.set_digits(1);
+ else
+ rField.set_digits(2);
+
+ switch (eUnit)
+ {
+ // _CHAR and _LINE sets the step of "char" and "line" unit, they are same as FUNIT_MM
+ case FUNIT_CHAR:
+ case FUNIT_LINE:
+ case FUNIT_MM:
+ rField.set_increments(50, 500, eUnit);
+ break;
+ case FUNIT_INCH:
+ rField.set_increments(2, 20, eUnit);
+ break;
+ default:
+ rField.set_increments(10, 100, eUnit);
+ break;
+ }
+
+ if (!bAll)
+ {
+ nMin = rField.normalize(nMin);
+ nMax = rField.normalize(nMax);
+ rField.set_range(nMin, nMax, FUNIT_TWIP);
+ }
+}
void SetFieldUnit( MetricField& rField, FieldUnit eUnit, bool bAll )
{