diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-02-13 13:55:22 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-02-14 12:50:01 +0100 |
commit | cfff893b9c82843a90aac4ecdb3a3936721b74a0 (patch) | |
tree | 2859340e329ea6dbffe5ae9c7eba0f67a88c57af /emfio/source | |
parent | 20305894243e24eb383ab9feefebf4a0e9f2644f (diff) |
Move unit conversion code to o3tl, and unify on that in more places
This also allows to easily add more units, both of length and for other
unit categories.
The conversion for "Line" unit (312 twip) is questionable. Corresponding
entries in aImplFactor in vcl/source/control/field.cxx were inconsistent
(45/11 in; 10/13 pc; 156/10 pt). They were added without explanation in
commit c85db626029fd8a5e0dfcb312937279df32339a0. I haven't found a spec
of the unit (https://en.wikipedia.org/wiki/Line_(unit) is not specific).
I used the definition based on "by pt", "by mm/100", "by char" (they all
were consistent); "by pc" seems inverted; "by twip" was half as much.
This accepted conversion makes unit test for tdf#79236 pass.
Change-Id: Iae5a21d915fa8e934a1f47f8ba9f6df03b79a9fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110839
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'emfio/source')
-rw-r--r-- | emfio/source/reader/wmfreader.cxx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 78fee922ff35..999584b02294 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -24,6 +24,7 @@ #include <memory> #include <optional> #include <o3tl/safeint.hxx> +#include <o3tl/unit_conversion.hxx> #include <rtl/crc.h> #include <rtl/tencinfo.h> #include <sal/log.hxx> @@ -1291,8 +1292,8 @@ namespace emfio { // #n417818#: If we have an external header then overwrite the bounds! tools::Rectangle aExtRect(0, 0, - static_cast<double>(mpExternalHeader->xExt) * 567 * mnUnitsPerInch / 1440000, - static_cast<double>(mpExternalHeader->yExt) * 567 * mnUnitsPerInch / 1440000); + o3tl::convert(mpExternalHeader->xExt, o3tl::Length::mm100, o3tl::Length::px), + o3tl::convert(mpExternalHeader->yExt, o3tl::Length::mm100, o3tl::Length::px)); aPlaceableBound = aExtRect; SAL_INFO("vcl.wmf", "External header size " |