[Libreoffice-commits] core.git: basegfx/source
Armin Le Grand
alg at apache.org
Wed Oct 8 06:59:09 PDT 2014
basegfx/source/inc/stringconversiontools.hxx | 10 +++----
basegfx/source/tools/stringconversiontools.cxx | 32 ++++++++++++++++++-------
2 files changed, 29 insertions(+), 13 deletions(-)
New commits:
commit e6bd33d4425bc568fbb40d5dd9137c72c82d411c
Author: Armin Le Grand <alg at apache.org>
Date: Wed Oct 8 11:03:03 2014 +0000
Resolves: #i125447# corrected some string to number conversion...
tools to correct svg:d imports
(cherry picked from commit f077f99da3cb2903fa903dcf30e6cfd714fd009c)
Conflicts:
basegfx/source/inc/stringconversiontools.hxx
basegfx/source/tools/stringconversiontools.cxx
Change-Id: I7de1558682990f83e66fdded3d9d30e21e4f97fe
diff --git a/basegfx/source/inc/stringconversiontools.hxx b/basegfx/source/inc/stringconversiontools.hxx
index 834c0de..d759bbb 100644
--- a/basegfx/source/inc/stringconversiontools.hxx
+++ b/basegfx/source/inc/stringconversiontools.hxx
@@ -35,19 +35,19 @@ namespace basegfx
const OUString& rStr,
const sal_Int32 nLen);
- inline bool lcl_isOnNumberChar(const sal_Unicode aChar, bool bSignAllowed = true)
+ inline bool lcl_isOnNumberChar(const sal_Unicode aChar, bool bSignAllowed = true, bool bDotAllowed = true)
{
const bool bPredicate( (sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
|| (bSignAllowed && sal_Unicode('+') == aChar)
- || (bSignAllowed && sal_Unicode('-') == aChar) );
+ || (bSignAllowed && sal_Unicode('-') == aChar)
+ || (bDotAllowed && sal_Unicode('.') == aChar));
return bPredicate;
}
- inline bool lcl_isOnNumberChar(const OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true)
+ inline bool lcl_isOnNumberChar(const OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true, bool bDotAllowed = true)
{
- return lcl_isOnNumberChar(rStr[nPos],
- bSignAllowed);
+ return lcl_isOnNumberChar(rStr[nPos], bSignAllowed, bDotAllowed);
}
bool lcl_getDoubleChar(double& o_fRetval,
diff --git a/basegfx/source/tools/stringconversiontools.cxx b/basegfx/source/tools/stringconversiontools.cxx
index 211f899..df37126 100644
--- a/basegfx/source/tools/stringconversiontools.cxx
+++ b/basegfx/source/tools/stringconversiontools.cxx
@@ -46,35 +46,50 @@ namespace basegfx
}
}
- bool lcl_getDoubleChar(double& o_fRetval,
- sal_Int32& io_rPos,
- const OUString& rStr)
+ bool lcl_getDoubleChar(double& o_fRetval, sal_Int32& io_rPos, const OUString& rStr)
{
sal_Unicode aChar( rStr[io_rPos] );
OUStringBuffer sNumberString;
- bool separator_seen=false;
+ // sign
if('+' == aChar || '-' == aChar)
{
sNumberString.append(rStr[io_rPos]);
aChar = rStr[++io_rPos];
}
- while(('0' <= aChar && '9' >= aChar)
- || (!separator_seen && '.' == aChar))
+ // numbers before point
+ while('0' <= aChar && '9' >= aChar)
{
- if ('.' == aChar) separator_seen = true;
sNumberString.append(rStr[io_rPos]);
io_rPos++;
aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
}
+ // point
+ if('.' == aChar)
+ {
+ sNumberString.append(rStr[io_rPos]);
+ io_rPos++;
+ aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
+ }
+
+ // numbers after point
+ while ('0' <= aChar && '9' >= aChar)
+ {
+ sNumberString.append(rStr[io_rPos]);
+ io_rPos++;
+ aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
+ }
+
+ // 'e'
if('e' == aChar || 'E' == aChar)
{
sNumberString.append(rStr[io_rPos]);
io_rPos++;
aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
+ // sign for 'e'
if('+' == aChar || '-' == aChar)
{
sNumberString.append(rStr[io_rPos]);
@@ -82,6 +97,7 @@ namespace basegfx
aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
}
+ // number for 'e'
while('0' <= aChar && '9' >= aChar)
{
sNumberString.append(rStr[io_rPos]);
@@ -153,7 +169,7 @@ namespace basegfx
const sal_Int32 aLen( rStr.getLength() );
if(aLen)
{
- if( lcl_isOnNumberChar(rStr[aLen - 1], false) &&
+ if( lcl_isOnNumberChar(rStr[aLen - 1], false, true) &&
fValue >= 0.0 )
{
rStr.append( ' ' );
More information about the Libreoffice-commits
mailing list