summaryrefslogtreecommitdiff
path: root/basegfx/source
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2014-10-08 11:03:03 +0000
committerArmin Le Grand <alg@apache.org>2014-10-08 11:03:03 +0000
commitf077f99da3cb2903fa903dcf30e6cfd714fd009c (patch)
treed5db3e8b94bb44426a84c117d855a1d5b844f849 /basegfx/source
parentf4d179a8f647336b27098ebb2e0418b22b3ba44e (diff)
i125447 corrected some string to number conversion tools to correct svg:d imports
Notes
Diffstat (limited to 'basegfx/source')
-rwxr-xr-xbasegfx/source/inc/stringconversiontools.hxx10
-rwxr-xr-xbasegfx/source/tools/stringconversiontools.cxx57
2 files changed, 51 insertions, 16 deletions
diff --git a/basegfx/source/inc/stringconversiontools.hxx b/basegfx/source/inc/stringconversiontools.hxx
index 568772fde4b5..d18ccd3f3547 100755
--- a/basegfx/source/inc/stringconversiontools.hxx
+++ b/basegfx/source/inc/stringconversiontools.hxx
@@ -38,19 +38,19 @@ namespace basegfx
const ::rtl::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 ::rtl::OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true)
+ inline bool lcl_isOnNumberChar(const ::rtl::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 01fbf268826a..08c023b2f78e 100755
--- a/basegfx/source/tools/stringconversiontools.cxx
+++ b/basegfx/source/tools/stringconversiontools.cxx
@@ -51,37 +51,53 @@ namespace basegfx
}
}
- bool lcl_getDoubleChar(double& o_fRetval,
- sal_Int32& io_rPos,
- const ::rtl::OUString& rStr)
+ bool lcl_getDoubleChar(double& o_fRetval, sal_Int32& io_rPos, const ::rtl::OUString& rStr)
{
sal_Unicode aChar( rStr[io_rPos] );
::rtl::OUStringBuffer sNumberString;
+ // sign
if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar)
{
sNumberString.append(rStr[io_rPos]);
aChar = rStr[++io_rPos];
}
- while((sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
- || sal_Unicode('.') == aChar)
+ // numbers before point
+ while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
{
sNumberString.append(rStr[io_rPos]);
aChar = rStr[++io_rPos];
}
+ // point
+ if(sal_Unicode('.') == aChar)
+ {
+ sNumberString.append(rStr[io_rPos]);
+ aChar = rStr[++io_rPos];
+ }
+
+ // numbers after point
+ while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
+ {
+ sNumberString.append(rStr[io_rPos]);
+ aChar = rStr[++io_rPos];
+ }
+
+ // 'e'
if(sal_Unicode('e') == aChar || sal_Unicode('E') == aChar)
{
sNumberString.append(rStr[io_rPos]);
aChar = rStr[++io_rPos];
+ // sign for 'e'
if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar)
{
sNumberString.append(rStr[io_rPos]);
aChar = rStr[++io_rPos];
}
+ // number for 'e'
while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
{
sNumberString.append(rStr[io_rPos]);
@@ -153,34 +169,53 @@ namespace basegfx
{
bool bSignAllowed(true);
- while(io_rPos < nLen && lcl_isOnNumberChar(rStr, io_rPos, bSignAllowed))
+ while(io_rPos < nLen && lcl_isOnNumberChar(rStr, io_rPos, bSignAllowed, true))
{
bSignAllowed = false;
++io_rPos;
}
}
- void lcl_skipDouble(sal_Int32& io_rPos,
- const ::rtl::OUString& rStr)
+ void lcl_skipDouble(sal_Int32& io_rPos, const ::rtl::OUString& rStr)
{
sal_Unicode aChar( rStr[io_rPos] );
+ // sign
if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar)
+ {
aChar = rStr[++io_rPos];
+ }
- while((sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
- || sal_Unicode('.') == aChar)
+ // numbers before point
+ while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
{
aChar = rStr[++io_rPos];
}
+ // point
+ if(sal_Unicode('.') == aChar)
+ {
+ aChar = rStr[++io_rPos];
+ }
+
+ // numbers after point
+ while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
+ {
+ aChar = rStr[++io_rPos];
+ }
+
+ // 'e'
if(sal_Unicode('e') == aChar || sal_Unicode('E') == aChar)
{
aChar = rStr[++io_rPos];
+ // sign of 'e'
if(sal_Unicode('+') == aChar || sal_Unicode('-') == aChar)
+ {
aChar = rStr[++io_rPos];
+ }
+ // numbers for 'e'
while(sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
{
aChar = rStr[++io_rPos];
@@ -199,7 +234,7 @@ namespace basegfx
const sal_Int32 aLen( rStr.getLength() );
if(aLen)
{
- if( lcl_isOnNumberChar(rStr.charAt(aLen - 1), false) &&
+ if( lcl_isOnNumberChar(rStr.charAt(aLen - 1), false, true) &&
fValue >= 0.0 )
{
rStr.append( sal_Unicode(' ') );