summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-02-05 09:36:59 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-02-05 17:04:00 +0100
commitd7e5fa3bd8f4240665f13994589f5e72d362c097 (patch)
tree5709b7600d9f3ee8bec08b87e9b52f475990e16e /oox
parentcb2a94a4a7ecb449d0731627ee6d58bd1b4e35f3 (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 'oox')
-rw-r--r--oox/source/drawingml/textparagraphpropertiescontext.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx
index 6aa8fef0cd04..e7e77da8564f 100644
--- a/oox/source/drawingml/textparagraphpropertiescontext.cxx
+++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx
@@ -29,6 +29,7 @@
#include <svx/unopage.hxx>
#include <sal/log.hxx>
#include <tools/diagnose_ex.h>
+#include <tools/UnitConversion.hxx>
#include <drawingml/colorchoicecontext.hxx>
#include <drawingml/misccontexts.hxx>
@@ -305,7 +306,7 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl
{
TextSpacing& rSpacing = mrTextParagraphProperties.getParaTopMargin();
rSpacing.nUnit = TextSpacing::Unit::Points;
- rSpacing.nValue = TwipsToHMM(oBefore.get());
+ rSpacing.nValue = convertTwipToMm100(oBefore.get());
rSpacing.bHasValue = true;
}
else
@@ -329,7 +330,7 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl
{
TextSpacing& rSpacing = mrTextParagraphProperties.getParaBottomMargin();
rSpacing.nUnit = TextSpacing::Unit::Points;
- rSpacing.nValue = TwipsToHMM(oAfter.get());
+ rSpacing.nValue = convertTwipToMm100(oAfter.get());
rSpacing.bHasValue = true;
}
else
@@ -359,7 +360,7 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl
else
{
rLineSpacing.nUnit = TextSpacing::Unit::Points;
- rLineSpacing.nValue = TwipsToHMM(oLineSpacing.get());
+ rLineSpacing.nValue = convertTwipToMm100(oLineSpacing.get());
}
rLineSpacing.bHasValue = true;
}