summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-10-31 08:54:42 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-11-01 00:25:55 +0100
commit013618308c2d24702de18c12922931b130b6fade (patch)
treef70af86abdc8eea17471c1c1767986ce68c21834 /editeng
parentaab1018339fba9e6c618a17dfb2a01464555c4dc (diff)
ofz#3934 Integer-overflow
Change-Id: I2c58cca6f01d7c50244dfec6acdfaa988cdbaa07 Reviewed-on: https://gerrit.libreoffice.org/44102 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 'editeng')
-rw-r--r--editeng/source/uno/unoipset.cxx16
1 files changed, 6 insertions, 10 deletions
diff --git a/editeng/source/uno/unoipset.cxx b/editeng/source/uno/unoipset.cxx
index cc2a5c6c1861..8d4b41e4ffb1 100644
--- a/editeng/source/uno/unoipset.cxx
+++ b/editeng/source/uno/unoipset.cxx
@@ -19,9 +19,8 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <svl/eitem.hxx>
-
#include <svl/itemprop.hxx>
-
+#include <tools/helpers.hxx>
#include <editeng/unoipset.hxx>
#include <editeng/editids.hrc>
#include <editeng/editeng.hxx>
@@ -272,9 +271,6 @@ uno::Reference< beans::XPropertySetInfo > const & SvxItemPropertySet::getProper
#ifndef TWIPS_TO_MM
#define TWIPS_TO_MM(val) ((val * 127 + 36) / 72)
#endif
-#ifndef MM_TO_TWIPS
-#define MM_TO_TWIPS(val) ((val * 72 + 63) / 127)
-#endif
/** converts the given any with a metric to 100th/mm if needed */
void SvxUnoConvertToMM( const MapUnit eSourceMapUnit, uno::Any & rMetric ) throw()
@@ -324,19 +320,19 @@ void SvxUnoConvertFromMM( const MapUnit eDestinationMapUnit, uno::Any & rMetric
switch( rMetric.getValueTypeClass() )
{
case uno::TypeClass_BYTE:
- rMetric <<= (sal_Int8)(MM_TO_TWIPS(*o3tl::forceAccess<sal_Int8>(rMetric)));
+ rMetric <<= (sal_Int8)(sanitiseMm100ToTwip(*o3tl::forceAccess<sal_Int8>(rMetric)));
break;
case uno::TypeClass_SHORT:
- rMetric <<= (sal_Int16)(MM_TO_TWIPS(*o3tl::forceAccess<sal_Int16>(rMetric)));
+ rMetric <<= (sal_Int16)(sanitiseMm100ToTwip(*o3tl::forceAccess<sal_Int16>(rMetric)));
break;
case uno::TypeClass_UNSIGNED_SHORT:
- rMetric <<= (sal_uInt16)(MM_TO_TWIPS(*o3tl::forceAccess<sal_uInt16>(rMetric)));
+ rMetric <<= (sal_uInt16)(sanitiseMm100ToTwip(*o3tl::forceAccess<sal_uInt16>(rMetric)));
break;
case uno::TypeClass_LONG:
- rMetric <<= (sal_Int32)(MM_TO_TWIPS(*o3tl::forceAccess<sal_Int32>(rMetric)));
+ rMetric <<= (sal_Int32)(sanitiseMm100ToTwip(*o3tl::forceAccess<sal_Int32>(rMetric)));
break;
case uno::TypeClass_UNSIGNED_LONG:
- rMetric <<= (sal_uInt32)(MM_TO_TWIPS(*o3tl::forceAccess<sal_uInt32>(rMetric)));
+ rMetric <<= (sal_uInt32)(sanitiseMm100ToTwip(*o3tl::forceAccess<sal_uInt32>(rMetric)));
break;
default:
OSL_FAIL("AW: Missing unit translation to 100th mm!");