basegfx/source/inc/stringconversiontools.hxx | 10 ++-- basegfx/source/tools/stringconversiontools.cxx | 57 ++++++++++++++++++++----- 2 files changed, 51 insertions(+), 16 deletions(-)
New commits: commit f077f99da3cb2903fa903dcf30e6cfd714fd009c Author: Armin Le Grand <a...@apache.org> Date: Wed Oct 8 11:03:03 2014 +0000 i125447 corrected some string to number conversion tools to correct svg:d imports diff --git a/basegfx/source/inc/stringconversiontools.hxx b/basegfx/source/inc/stringconversiontools.hxx index 568772f..d18ccd3 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 01fbf26..08c023b 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(' ') ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits