summaryrefslogtreecommitdiff
path: root/editeng
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 /editeng
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 'editeng')
-rw-r--r--editeng/source/uno/unoipset.cxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/editeng/source/uno/unoipset.cxx b/editeng/source/uno/unoipset.cxx
index 417e62d771e0..fc70a623d0ef 100644
--- a/editeng/source/uno/unoipset.cxx
+++ b/editeng/source/uno/unoipset.cxx
@@ -19,7 +19,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <svl/itemprop.hxx>
-#include <tools/helpers.hxx>
+#include <tools/UnitConversion.hxx>
#include <editeng/unoipset.hxx>
#include <svl/itempool.hxx>
#include <svl/solar.hrc>
@@ -271,19 +271,19 @@ void SvxUnoConvertToMM( const MapUnit eSourceMapUnit, uno::Any & rMetric ) throw
switch( rMetric.getValueTypeClass() )
{
case uno::TypeClass_BYTE:
- rMetric <<= static_cast<sal_Int8>(TwipsToHMM(*o3tl::forceAccess<sal_Int8>(rMetric)));
+ rMetric <<= static_cast<sal_Int8>(convertTwipToMm100(*o3tl::forceAccess<sal_Int8>(rMetric)));
break;
case uno::TypeClass_SHORT:
- rMetric <<= static_cast<sal_Int16>(TwipsToHMM(*o3tl::forceAccess<sal_Int16>(rMetric)));
+ rMetric <<= static_cast<sal_Int16>(convertTwipToMm100(*o3tl::forceAccess<sal_Int16>(rMetric)));
break;
case uno::TypeClass_UNSIGNED_SHORT:
- rMetric <<= static_cast<sal_uInt16>(TwipsToHMM(*o3tl::forceAccess<sal_uInt16>(rMetric)));
+ rMetric <<= static_cast<sal_uInt16>(convertTwipToMm100(*o3tl::forceAccess<sal_uInt16>(rMetric)));
break;
case uno::TypeClass_LONG:
- rMetric <<= static_cast<sal_Int32>(TwipsToHMM(*o3tl::forceAccess<sal_Int32>(rMetric)));
+ rMetric <<= static_cast<sal_Int32>(convertTwipToMm100(*o3tl::forceAccess<sal_Int32>(rMetric)));
break;
case uno::TypeClass_UNSIGNED_LONG:
- rMetric <<= static_cast<sal_uInt32>(TwipsToHMM(*o3tl::forceAccess<sal_uInt32>(rMetric)));
+ rMetric <<= static_cast<sal_uInt32>(convertTwipToMm100(*o3tl::forceAccess<sal_uInt32>(rMetric)));
break;
default:
SAL_WARN("editeng", "AW: Missing unit translation to 100th mm, " << OString::number(static_cast<sal_Int32>(rMetric.getValueTypeClass())));