diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-02-05 09:36:59 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-02-05 17:04:00 +0100 |
commit | d7e5fa3bd8f4240665f13994589f5e72d362c097 (patch) | |
tree | 5709b7600d9f3ee8bec08b87e9b52f475990e16e /sw/source/filter/ww8/wrtw8esh.cxx | |
parent | cb2a94a4a7ecb449d0731627ee6d58bd1b4e35f3 (diff) |
Make sanitiseMm100ToTwip simpler and more correct
The result's absolute value is always smaller than n.
Returning an uncorrected value taken from reversing
multiplication and division order when intermediate
value would overflow is better than arbitrary constant.
Also further deduplicate Twips <-> 100th-mm conversion,
and make sure they all are in a single header.
Using conversion implementation that handles negatives
correctly improves accuracy, as seen in unit tests; e.g.
in testPictureEffectPreservation (the original doc had
"dir" equal to "8100000", while we tested that it was
"8076614" after roundtrip).
Change-Id: Icd027af6238a9f45f916f53f8684506cc959e696
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110433
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source/filter/ww8/wrtw8esh.cxx')
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index e6d75e7ceeba..bee858964b4e 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -90,6 +90,7 @@ #include <o3tl/enumrange.hxx> #include <o3tl/enumarray.hxx> #include <sfx2/docfile.hxx> +#include <tools/UnitConversion.hxx> #include <algorithm> @@ -3041,8 +3042,8 @@ void SwMSConvertControls::ExportControl(WW8Export &rWW8Wrt, const SdrUnoObj& rFo tools::Rectangle aRect = rFormObj.GetLogicRect(); aRect.SetPos(Point(0,0)); awt::Size aSize; - aSize.Width = TwipsToHMM(aRect.Right()); - aSize.Height = TwipsToHMM(aRect.Bottom()); + aSize.Width = convertTwipToMm100(aRect.Right()); + aSize.Height = convertTwipToMm100(aRect.Bottom()); //Open the ObjectPool tools::SvRef<SotStorage> xObjPool = rWW8Wrt.GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool); |