[Libreoffice-commits] core.git: sax/source
Rosemary Sebastian
rosemaryseb8 at gmail.com
Wed May 4 10:10:09 UTC 2016
sax/source/tools/converter.cxx | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
New commits:
commit 9144a54a7612aa75cf58e857ddd4913f8bac6965
Author: Rosemary Sebastian <rosemaryseb8 at gmail.com>
Date: Sun May 1 14:46:15 2016 +0530
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 at cib.de>
Tested-by: Oliver Specht <oliver.specht at cib.de>
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index d1f6c9f..39baec9 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;
More information about the Libreoffice-commits
mailing list