diff options
author | Rosemary Sebastian <rosemaryseb8@gmail.com> | 2016-05-01 14:46:15 +0530 |
---|---|---|
committer | Oliver Specht <oliver.specht@cib.de> | 2016-05-04 10:09:47 +0000 |
commit | 9144a54a7612aa75cf58e857ddd4913f8bac6965 (patch) | |
tree | dd360d4c7834ba80188b7faf0a47fe3a58668f69 /sax | |
parent | 6e70103da07ec67b1c1f106a8fcd064e3df97271 (diff) |
tdf#94260 Convert pixel to 1/100 mm
The scaling factor 0.28 is chosen as per
https://www.w3.org/TR/2001/REC-xsl-20011015/slice5.html#pixels
Change-Id: I8dc7846699fbb2aa6e2a181a041b66d3cc33b8e5
Reviewed-on: https://gerrit.libreoffice.org/24547
Reviewed-by: Oliver Specht <oliver.specht@cib.de>
Tested-by: Oliver Specht <oliver.specht@cib.de>
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/tools/converter.cxx | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx index d1f6c9f2854e..39baec90c824 100644 --- a/sax/source/tools/converter.cxx +++ b/sax/source/tools/converter.cxx @@ -125,10 +125,11 @@ bool Converter::convertMeasure( sal_Int32& rValue, else { OSL_ENSURE( MeasureUnit::TWIP == nTargetUnit || MeasureUnit::POINT == nTargetUnit || - MeasureUnit::MM_100TH == nTargetUnit || MeasureUnit::MM_10TH == nTargetUnit, "unit is not supported"); - const sal_Char *aCmpsL[2] = { nullptr, nullptr }; - const sal_Char *aCmpsU[2] = { nullptr, nullptr }; - double aScales[2] = { 1., 1. }; + MeasureUnit::MM_100TH == nTargetUnit || MeasureUnit::MM_10TH == nTargetUnit || + MeasureUnit::PIXEL == nTargetUnit, "unit is not supported"); + const sal_Char *aCmpsL[3] = { nullptr, nullptr, nullptr }; + const sal_Char *aCmpsU[3] = { nullptr, nullptr, nullptr }; + double aScales[3] = { 1., 1., 1. }; if( MeasureUnit::TWIP == nTargetUnit ) { @@ -196,6 +197,10 @@ bool Converter::convertMeasure( sal_Int32& rValue, aCmpsL[1] = "pc"; aCmpsU[1] = "PC"; aScales[1] = (10.0 * nScaleFactor*2.54)/12.; // mm/100 + + aCmpsL[2] = "px"; + aCmpsU[2] = "PX"; + aScales[2] = 0.28 * nScaleFactor; // mm/100 break; } } @@ -213,22 +218,23 @@ bool Converter::convertMeasure( sal_Int32& rValue, return false; double nScale = 0.; - for( sal_uInt16 i= 0; i < 2; i++ ) + for( sal_uInt16 i= 0; i < 3; i++ ) { + sal_Int32 nTmp = nPos; // come back to the initial position before each iteration const sal_Char *pL = aCmpsL[i]; if( pL ) { const sal_Char *pU = aCmpsU[i]; - while( nPos < nLen && *pL ) + while( nTmp < nLen && *pL ) { - sal_Unicode c = rString[nPos]; + sal_Unicode c = rString[nTmp]; if( c != *pL && c != *pU ) break; pL++; pU++; - nPos++; + nTmp++; } - if( !*pL && (nPos == nLen || ' ' == rString[nPos]) ) + if( !*pL && (nTmp == nLen || ' ' == rString[nTmp]) ) { nScale = aScales[i]; break; |