From 84272d115da1165ac5f7cf4ae53875855d762b25 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Fri, 4 Apr 2014 13:39:38 +0300 Subject: Introduce twip/mm100 conversion functions instead of duplicated macros Change-Id: Ib689e35b417e0e9016cd6a239c986e0603a99d62 Reviewed-on: https://gerrit.libreoffice.org/8837 Tested-by: LibreOffice gerrit bot Reviewed-by: Miklos Vajna --- writerfilter/source/dmapper/ConversionHelper.cxx | 7 +++-- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 34 ++++++++++++------------ writerfilter/source/rtftok/rtfsdrimport.cxx | 19 +++++++------ 3 files changed, 29 insertions(+), 31 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx index 9de86eeb8f0a..bff0e823b2a7 100644 --- a/writerfilter/source/dmapper/ConversionHelper.cxx +++ b/writerfilter/source/dmapper/ConversionHelper.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -226,11 +227,9 @@ OUString ConvertMSFormatStringToSO( } -#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L)) - sal_Int32 convertTwipToMM100(sal_Int32 _t) { - return TWIP_TO_MM100( _t ); + return ::convertTwipToMm100( _t ); } sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t) @@ -241,7 +240,7 @@ sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t) // anything that's bigger than 32767 appears to be simply ignored. if( _t >= 0x8000 ) return 0; - return TWIP_TO_MM100( _t ); + return ::convertTwipToMm100( _t ); } sal_Int32 convertEMUToMM100(sal_Int32 _t) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 39da5cc9bead..b9b99fe93764 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -56,7 +57,6 @@ #include #include -#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L)) #define MM100_TO_EMU(MM100) (MM100 * 360) using std::make_pair; @@ -3479,15 +3479,15 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_aStates.top().aPicture.nHeight = nParam; break; case RTF_PICWGOAL: - m_aStates.top().aPicture.nGoalWidth = TWIP_TO_MM100(nParam); + m_aStates.top().aPicture.nGoalWidth = convertTwipToMm100(nParam); break; case RTF_PICHGOAL: - m_aStates.top().aPicture.nGoalHeight = TWIP_TO_MM100(nParam); + m_aStates.top().aPicture.nGoalHeight = convertTwipToMm100(nParam); break; - case RTF_PICCROPL: m_aStates.top().aPicture.nCropL = TWIP_TO_MM100(nParam); break; - case RTF_PICCROPR: m_aStates.top().aPicture.nCropR = TWIP_TO_MM100(nParam); break; - case RTF_PICCROPT: m_aStates.top().aPicture.nCropT = TWIP_TO_MM100(nParam); break; - case RTF_PICCROPB: m_aStates.top().aPicture.nCropB = TWIP_TO_MM100(nParam); break; + case RTF_PICCROPL: m_aStates.top().aPicture.nCropL = convertTwipToMm100(nParam); break; + case RTF_PICCROPR: m_aStates.top().aPicture.nCropR = convertTwipToMm100(nParam); break; + case RTF_PICCROPT: m_aStates.top().aPicture.nCropT = convertTwipToMm100(nParam); break; + case RTF_PICCROPB: m_aStates.top().aPicture.nCropB = convertTwipToMm100(nParam); break; case RTF_SHPWRK: { int nValue = 0; @@ -3704,16 +3704,16 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) } break; case RTF_SHPLEFT: - m_aStates.top().aShape.nLeft = TWIP_TO_MM100(nParam); + m_aStates.top().aShape.nLeft = convertTwipToMm100(nParam); break; case RTF_SHPTOP: - m_aStates.top().aShape.nTop = TWIP_TO_MM100(nParam); + m_aStates.top().aShape.nTop = convertTwipToMm100(nParam); break; case RTF_SHPRIGHT: - m_aStates.top().aShape.nRight = TWIP_TO_MM100(nParam); + m_aStates.top().aShape.nRight = convertTwipToMm100(nParam); break; case RTF_SHPBOTTOM: - m_aStates.top().aShape.nBottom = TWIP_TO_MM100(nParam); + m_aStates.top().aShape.nBottom = convertTwipToMm100(nParam); break; case RTF_SHPZ: m_aStates.top().aShape.oZ.reset(nParam); @@ -3832,16 +3832,16 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) NS_ooxml::LN_CT_PPrBase_spacing, NS_ooxml::LN_CT_Spacing_after, pIntValue, OVERWRITE_YES); break; case RTF_DPX: - m_aStates.top().aDrawingObject.nLeft = TWIP_TO_MM100(nParam); + m_aStates.top().aDrawingObject.nLeft = convertTwipToMm100(nParam); break; case RTF_DPY: - m_aStates.top().aDrawingObject.nTop = TWIP_TO_MM100(nParam); + m_aStates.top().aDrawingObject.nTop = convertTwipToMm100(nParam); break; case RTF_DPXSIZE: - m_aStates.top().aDrawingObject.nRight = TWIP_TO_MM100(nParam); + m_aStates.top().aDrawingObject.nRight = convertTwipToMm100(nParam); break; case RTF_DPYSIZE: - m_aStates.top().aDrawingObject.nBottom = TWIP_TO_MM100(nParam); + m_aStates.top().aDrawingObject.nBottom = convertTwipToMm100(nParam); break; case RTF_PNSTART: m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_start, pIntValue); @@ -3933,7 +3933,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) if (!rDrawingObject.aPolyLinePoints.hasElements()) dispatchValue(RTF_DPPOLYCOUNT, 2); - rDrawingObject.aPolyLinePoints[rDrawingObject.aPolyLinePoints.getLength() - rDrawingObject.nPolyLineCount].X = TWIP_TO_MM100(nParam); + rDrawingObject.aPolyLinePoints[rDrawingObject.aPolyLinePoints.getLength() - rDrawingObject.nPolyLineCount].X = convertTwipToMm100(nParam); } break; case RTF_DPPTY: @@ -3941,7 +3941,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) RTFDrawingObject& rDrawingObject = m_aStates.top().aDrawingObject; if (rDrawingObject.aPolyLinePoints.hasElements()) { - rDrawingObject.aPolyLinePoints[rDrawingObject.aPolyLinePoints.getLength() - rDrawingObject.nPolyLineCount].Y = TWIP_TO_MM100(nParam); + rDrawingObject.aPolyLinePoints[rDrawingObject.aPolyLinePoints.getLength() - rDrawingObject.nPolyLineCount].Y = convertTwipToMm100(nParam); rDrawingObject.nPolyLineCount--; if (rDrawingObject.nPolyLineCount == 0) { diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 5f5869427041..cc5d6cd4eff0 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "../dmapper/GraphicHelpers.hxx" @@ -39,8 +40,6 @@ #include #include -#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L)) - namespace writerfilter { namespace rtftok { @@ -527,21 +526,21 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose) } } else if (i->first == "groupLeft") - oGroupLeft.reset(TWIP_TO_MM100(i->second.toInt32())); + oGroupLeft.reset(convertTwipToMm100(i->second.toInt32())); else if (i->first == "groupTop") - oGroupTop.reset(TWIP_TO_MM100(i->second.toInt32())); + oGroupTop.reset(convertTwipToMm100(i->second.toInt32())); else if (i->first == "groupRight") - oGroupRight.reset(TWIP_TO_MM100(i->second.toInt32())); + oGroupRight.reset(convertTwipToMm100(i->second.toInt32())); else if (i->first == "groupBottom") - oGroupBottom.reset(TWIP_TO_MM100(i->second.toInt32())); + oGroupBottom.reset(convertTwipToMm100(i->second.toInt32())); else if (i->first == "relLeft") - oRelLeft.reset(TWIP_TO_MM100(i->second.toInt32())); + oRelLeft.reset(convertTwipToMm100(i->second.toInt32())); else if (i->first == "relTop") - oRelTop.reset(TWIP_TO_MM100(i->second.toInt32())); + oRelTop.reset(convertTwipToMm100(i->second.toInt32())); else if (i->first == "relRight") - oRelRight.reset(TWIP_TO_MM100(i->second.toInt32())); + oRelRight.reset(convertTwipToMm100(i->second.toInt32())); else if (i->first == "relBottom") - oRelBottom.reset(TWIP_TO_MM100(i->second.toInt32())); + oRelBottom.reset(convertTwipToMm100(i->second.toInt32())); else if (i->first == "fBehindDocument") bOpaque = !i->second.toInt32(); else if (i->first == "pctHoriz" || i->first == "pctVert") -- cgit