summaryrefslogtreecommitdiff
path: root/include/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-08-22 15:13:58 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-08-22 16:35:54 +0200
commitf26e35c93526cdd1c4fcb6614c3fb1f6a3c511e8 (patch)
tree374c65e3564fd2c969de01c9359cf11c3e6ba255 /include/oox
parent166510ed48bf49b75a031ce973f41d08fb4e4518 (diff)
oox::drawingml::convertEmuToHmm: fix rounding for negative values
This commit also moves the floating table DOCX import testcase to the export suite. That test now passes fine, though previously it failed with: - Expected: -199 - Actual : -198 Due to the rounding error. Change-Id: I9bdc9295f68b6bd3e5f5bee868aae15194b30804
Diffstat (limited to 'include/oox')
-rw-r--r--include/oox/drawingml/drawingmltypes.hxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/oox/drawingml/drawingmltypes.hxx b/include/oox/drawingml/drawingmltypes.hxx
index 5df664ee66a4..9e011f302ae2 100644
--- a/include/oox/drawingml/drawingmltypes.hxx
+++ b/include/oox/drawingml/drawingmltypes.hxx
@@ -150,7 +150,8 @@ inline sal_Int64 convertHmmToEmu( sal_Int32 nValue )
/** Converts the passed 64-bit integer value from EMUs to 1/100 mm. */
inline sal_Int32 convertEmuToHmm( sal_Int64 nValue )
{
- return getLimitedValue< sal_Int32, sal_Int64 >( (nValue + EMU_PER_HMM / 2) / EMU_PER_HMM, SAL_MIN_INT32, SAL_MAX_INT32 );
+ sal_Int32 nCorrection = (nValue > 0 ? 1 : -1) * EMU_PER_HMM / 2; // So that the implicit floor will round.
+ return getLimitedValue< sal_Int32, sal_Int64 >( (nValue + nCorrection) / EMU_PER_HMM, SAL_MIN_INT32, SAL_MAX_INT32 );
}
// ============================================================================