basic/qa/basic_coverage/test_isnumeric_method.bas |   35 +++-
 basic/source/sbx/sbxconv.hxx                      |    6 
 basic/source/sbx/sbxexec.cxx                      |    2 
 basic/source/sbx/sbxscan.cxx                      |  190 +++++++++-------------
 basic/source/sbx/sbxvalue.cxx                     |    5 
 include/basic/sbxvar.hxx                          |    2 
 6 files changed, 121 insertions(+), 119 deletions(-)

New commits:
commit fdf39c37624847d0b5ef51058f06e94ad86c49d3
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Jan 6 14:45:44 2025 +0500
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Jan 8 13:04:34 2025 +0100

    tdf#154284: check if ImpScan found a number at all
    
    Change-Id: Iddc87bd0d04f9b0212b03d63f3177b17bb07d278
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179863
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179933

diff --git a/basic/qa/basic_coverage/test_isnumeric_method.bas 
b/basic/qa/basic_coverage/test_isnumeric_method.bas
index 1b454aa8d5ec..21e4a91a8b45 100644
--- a/basic/qa/basic_coverage/test_isnumeric_method.bas
+++ b/basic/qa/basic_coverage/test_isnumeric_method.bas
@@ -8,13 +8,32 @@
 
 Option Explicit
 
-Function doUnitTest as String
+Function doUnitTest() As String
+    TestUtil.TestInit
+    verify_IsNumeric
+    doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_IsNumeric
+    On Error GoTo errorHandler
+
     dim aVariant as Variant
     aVariant = 3
-    ' ISNUMERIC
-    If ( IsNumeric( aVariant ) = False ) Then
-        doUnitTest = "FAIL"
-    Else
-        doUnitTest = "OK"
-    End If
-End Function
+    TestUtil.Assert(IsNumeric(aVariant), "IsNumeric(aVariant)")
+
+    TestUtil.Assert(IsNumeric(" 0 "), "IsNumeric("" 0 "")")
+    TestUtil.Assert(IsNumeric(" +0 "), "IsNumeric("" +0 "")")
+    TestUtil.Assert(IsNumeric(" -0 "), "IsNumeric("" -0 "")")
+    TestUtil.Assert(Not IsNumeric(""), "Not IsNumeric("""")")
+    TestUtil.Assert(Not IsNumeric(" "), "Not IsNumeric("" "")")
+    TestUtil.Assert(Not IsNumeric(" + "), "Not IsNumeric("" + "")")
+    TestUtil.Assert(Not IsNumeric(" - "), "Not IsNumeric("" - "")")
+    ' Note: the two following tests should behave different in VBA 
(TODO/FIXME);
+    ' should it be unified maybe in non-VBA, too (a breaking change)?
+    TestUtil.Assert(Not IsNumeric(" + 0 "), "Not IsNumeric("" + 0 "")")
+    TestUtil.Assert(Not IsNumeric(" - 0 "), "Not IsNumeric("" - 0 "")")
+
+    Exit Sub
+errorHandler:
+    TestUtil.ReportErrorHandler("verify_IsNumeric", Err, Error$, Erl)
+End Sub
diff --git a/basic/source/sbx/sbxconv.hxx b/basic/source/sbx/sbxconv.hxx
index 82652e5dbff6..11725dec5b29 100644
--- a/basic/source/sbx/sbxconv.hxx
+++ b/basic/source/sbx/sbxconv.hxx
@@ -64,7 +64,7 @@ inline auto ImpDoubleToSalInt64(double d)
 extern void ImpCvtNum( double nNum, short nPrec, OUString& rRes, bool 
bCoreString=false );
 extern ErrCode ImpScan
     ( std::u16string_view rSrc, double& nVal, SbxDataType& rType, sal_uInt16* 
pLen,
-      bool bOnlyIntntl );
+      bool* pHasNumber, bool bOnlyIntntl );
 // A version that uses defaults / compatibility settings for bOnlyIntntl
 extern ErrCode ImpScan
     ( std::u16string_view rSrc, double& nVal, SbxDataType& rType, sal_uInt16* 
pLen );
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index 1084d6cf2810..008b5aeb0a4e 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -71,7 +71,7 @@ static bool ImpStrChr( std::u16string_view str, sal_Unicode c 
) { return str.fin
 // conversion error if data type is fixed and it doesn't fit
 
 ErrCode ImpScan( std::u16string_view rWSrc, double& nVal, SbxDataType& rType,
-                  sal_uInt16* pLen, bool bOnlyIntntl )
+                  sal_uInt16* pLen, bool* pHasNumber, bool bOnlyIntntl )
 {
     sal_Unicode cDecSep, cGrpSep, cDecSepAlt;
     if( bOnlyIntntl )
@@ -102,6 +102,7 @@ ErrCode ImpScan( std::u16string_view rWSrc, double& nVal, 
SbxDataType& rType,
         p++;
         bMinus = true;
     }
+    const auto pNumberStart = p;
     if (p != rWSrc.end()
         && (rtl::isAsciiDigit(*p)
             || ((*p == cDecSep || (cGrpSep && *p == cGrpSep) || (cDecSepAlt && 
*p == cDecSepAlt))
@@ -231,11 +232,14 @@ ErrCode ImpScan( std::u16string_view rWSrc, double& nVal, 
SbxDataType& rType,
         return ERRCODE_BASIC_CONVERSION;
     }
 #endif
+    const auto pNumberEnd = p;
     // tdf#146672 - skip whitespaces and tabs at the end of the scanned string
     while (p != rWSrc.end() && (*p == ' ' || *p == '   '))
         p++;
     if( pLen )
         *pLen = static_cast<sal_uInt16>( p - pStart );
+    if (pHasNumber)
+        *pHasNumber = pNumberEnd > pNumberStart;
     if( bMinus )
         nVal = -nVal;
     rType = eScanType;
@@ -248,14 +252,14 @@ ErrCode ImpScan(std::u16string_view rSrc, double& nVal, 
SbxDataType& rType, sal_
     static const bool bEnv = std::getenv("LIBREOFFICE6FLOATINGPOINTMODE") != 
nullptr;
     bool bMode = bEnv || 
Basic::Compatibility::UseLibreOffice6FloatingPointConversion::get();
 
-    return ImpScan(rSrc, nVal, rType, pLen, !bMode);
+    return ImpScan(rSrc, nVal, rType, pLen, nullptr, !bMode);
 }
 
 // port for CDbl in the Basic
 ErrCode SbxValue::ScanNumIntnl( const OUString& rSrc, double& nVal, bool 
bSingle )
 {
     sal_uInt16 nLen = 0;
-    ErrCode nRetError = ImpScan( rSrc, nVal, o3tl::temporary(SbxDataType()), 
&nLen,
+    ErrCode nRetError = ImpScan( rSrc, nVal, o3tl::temporary(SbxDataType()), 
&nLen, nullptr,
         /*bOnlyIntntl*/true );
     // read completely?
     if( nRetError == ERRCODE_NONE && nLen != rSrc.getLength() )
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index da1efcf688ce..6b70fe31131a 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -693,8 +693,9 @@ bool SbxValue::ImpIsNumeric( bool bOnlyIntntl ) const
             double n;
             SbxDataType t2;
             sal_uInt16 nLen = 0;
-            if( ImpScan( s, n, t2, &nLen, bOnlyIntntl ) == ERRCODE_NONE )
-                return nLen == s.getLength();
+            bool bHasNumber = false;
+            if( ImpScan( s, n, t2, &nLen, &bHasNumber, bOnlyIntntl ) == 
ERRCODE_NONE )
+                return nLen == s.getLength() && bHasNumber;
         }
         return false;
     }
commit 2779673365b386c4e0a51240f10529382f7b2f83
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Dec 23 14:26:20 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Jan 8 13:04:28 2025 +0100

    Simplify ImpScan
    
    Change-Id: I8928d3c7f0fc6884a75c05e77908df7f482c9e44
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179246
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179932

diff --git a/basic/source/sbx/sbxconv.hxx b/basic/source/sbx/sbxconv.hxx
index 52bcb09bff05..82652e5dbff6 100644
--- a/basic/source/sbx/sbxconv.hxx
+++ b/basic/source/sbx/sbxconv.hxx
@@ -63,11 +63,11 @@ inline auto ImpDoubleToSalInt64(double d)
 // SBXSCAN.CXX
 extern void ImpCvtNum( double nNum, short nPrec, OUString& rRes, bool 
bCoreString=false );
 extern ErrCode ImpScan
-    ( const OUString& rSrc, double& nVal, SbxDataType& rType, sal_uInt16* pLen,
+    ( std::u16string_view rSrc, double& nVal, SbxDataType& rType, sal_uInt16* 
pLen,
       bool bOnlyIntntl );
 // A version that uses defaults / compatibility settings for bOnlyIntntl
 extern ErrCode ImpScan
-    ( const OUString& rSrc, double& nVal, SbxDataType& rType, sal_uInt16* pLen 
);
+    ( std::u16string_view rSrc, double& nVal, SbxDataType& rType, sal_uInt16* 
pLen );
 
 void ImpGetIntntlSep( sal_Unicode& rcDecimalSep, sal_Unicode& rcThousandSep, 
sal_Unicode& rcDecimalSepAlt );
 
diff --git a/basic/source/sbx/sbxexec.cxx b/basic/source/sbx/sbxexec.cxx
index af7d12c00651..8c88099efbee 100644
--- a/basic/source/sbx/sbxexec.cxx
+++ b/basic/source/sbx/sbxexec.cxx
@@ -130,7 +130,7 @@ static SbxVariableRef Operand
     {
         // A number could be scanned in directly!
         sal_uInt16 nLen;
-        if( !refVar->Scan( OUString( p ), &nLen ) )
+        if (!refVar->Scan(p, &nLen))
         {
             refVar.clear();
         }
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index db042b0b9315..1084d6cf2810 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -70,7 +70,7 @@ static bool ImpStrChr( std::u16string_view str, sal_Unicode c 
) { return str.fin
 // but exponent may also be a D, so data type is SbxDOUBLE
 // conversion error if data type is fixed and it doesn't fit
 
-ErrCode ImpScan( const OUString& rWSrc, double& nVal, SbxDataType& rType,
+ErrCode ImpScan( std::u16string_view rWSrc, double& nVal, SbxDataType& rType,
                   sal_uInt16* pLen, bool bOnlyIntntl )
 {
     sal_Unicode cDecSep, cGrpSep, cDecSepAlt;
@@ -88,30 +88,27 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
         cDecSepAlt = 0;
     }
 
-    const sal_Unicode* const pStart = rWSrc.getStr();
-    const sal_Unicode* p = pStart;
-    OUStringBuffer aBuf( rWSrc.getLength());
-    bool bRes = true;
+    auto const pStart = rWSrc.begin();
+    auto p = pStart;
     bool bMinus = false;
     nVal = 0;
     SbxDataType eScanType = SbxSINGLE;
-    while( *p == ' ' || *p == '        ' )
+    while (p != rWSrc.end() && (*p == ' ' || *p == '   '))
         p++;
-    if (*p == '+')
+    if (p != rWSrc.end() && *p == '+')
         p++;
-    else if( *p == '-' )
+    else if (p != rWSrc.end() && *p == '-')
     {
         p++;
         bMinus = true;
     }
-    if (rtl::isAsciiDigit(*p)
-        || ((*p == cDecSep || (cGrpSep && *p == cGrpSep) || (cDecSepAlt && *p 
== cDecSepAlt))
-            && rtl::isAsciiDigit(*(p + 1))))
+    if (p != rWSrc.end()
+        && (rtl::isAsciiDigit(*p)
+            || ((*p == cDecSep || (cGrpSep && *p == cGrpSep) || (cDecSepAlt && 
*p == cDecSepAlt))
+                && p + 1 != rWSrc.end() && rtl::isAsciiDigit(*(p + 1)))))
     {
-        // tdf#118442: Whitespace and minus are skipped; store the position to 
calculate index
-        const sal_Unicode* const pDigitsStart = p;
-        short exp = 0;
-        short decsep = 0;
+        bool exp = false;
+        bool decsep = false;
         short ndig = 0;
         short ncdig = 0;    // number of digits after decimal point
         OUStringBuffer aSearchStr("0123456789DEde" + OUStringChar(cDecSep));
@@ -119,61 +116,59 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
             aSearchStr.append(cDecSepAlt);
         if (cGrpSep)
             aSearchStr.append(cGrpSep);
-        const OUString pSearchStr = aSearchStr.makeStringAndClear();
-        static constexpr OUStringLiteral pDdEe = u"DdEe";
-        while( ImpStrChr( pSearchStr, *p ) )
+        OUStringBuffer aBuf(rWSrc.end() - p);
+        for (; p != rWSrc.end() && ImpStrChr(aSearchStr, *p); ++p)
         {
-            aBuf.append( *p );
-            if (cGrpSep && *p == cGrpSep)
+            if (rtl::isAsciiDigit(*p))
             {
-                p++;
-                continue;
+                aBuf.append(*p);
+                if (!exp)
+                {
+                    ndig++;
+                    if (decsep)
+                        ncdig++;
+                }
             }
-            if (*p == cDecSep || (cDecSepAlt && *p == cDecSepAlt))
+            else if (cGrpSep && *p == cGrpSep)
             {
+                aBuf.append(*p);
+            }
+            else if (*p == cDecSep || (cDecSepAlt && *p == cDecSepAlt))
+            {
+                if (decsep)
+                    return ERRCODE_BASIC_CONVERSION;
+                decsep = true;
+
                 // Use the separator that is passed to stringToDouble()
-                aBuf[p - pDigitsStart] = cDecSep;
-                p++;
-                if( ++decsep > 1 )
-                    continue;
+                aBuf.append(cDecSep);
             }
-            else if( ImpStrChr( pDdEe, *p ) )
+            else // DdEe
             {
-                if( ++exp > 1 )
-                {
-                    p++;
-                    continue;
-                }
+                if (exp)
+                    return ERRCODE_BASIC_CONVERSION;
+                exp = true;
+
                 if( *p == 'D' || *p == 'd' )
                     eScanType = SbxDOUBLE;
-                aBuf[p - pDigitsStart] = 'E';
-                p++;
-                if (*p == '+')
-                    ++p;
-                else if (*p == '-')
+                aBuf.append('E');
+                if (auto pNext = p + 1; pNext != rWSrc.end())
                 {
-                    aBuf.append('-');
-                    ++p;
+                    if (*pNext == '+')
+                        ++p;
+                    else if (*pNext == '-')
+                    {
+                        aBuf.append('-');
+                        ++p;
+                    }
                 }
             }
-            else
-            {
-                p++;
-                if( decsep && !exp )
-                    ncdig++;
-            }
-            if( !exp )
-                ndig++;
         }
 
-        if( decsep > 1 || exp > 1 )
-            bRes = false;
-
         rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
         sal_Int32 nParseEnd = 0;
         nVal = rtl::math::stringToDouble(aBuf, cDecSep, cGrpSep, &eStatus, 
&nParseEnd);
         if( eStatus != rtl_math_ConversionStatus_Ok || nParseEnd != 
aBuf.getLength() )
-            bRes = false;
+            return ERRCODE_BASIC_CONVERSION;
 
         if( !decsep && !exp )
         {
@@ -183,29 +178,29 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
                 eScanType = SbxLONG;
         }
 
-        ndig = ndig - decsep;
         // too many numbers for SINGLE?
         if( ndig > 15 || ncdig > 6 )
             eScanType = SbxDOUBLE;
 
         // type detection?
-        static constexpr OUStringLiteral pTypes = u"%!&#";
-        if( ImpStrChr( pTypes, *p ) )
+        static constexpr std::u16string_view pTypes = u"%!&#";
+        if (p != rWSrc.end() && ImpStrChr(pTypes, *p))
             p++;
     }
     // hex/octal number? read in and convert:
-    else if( *p == '&' )
+    else if (p != rWSrc.end() && *p == '&')
     {
-        p++;
+        if (++p == rWSrc.end())
+            return ERRCODE_BASIC_CONVERSION;
         eScanType = SbxLONG;
-        OUString aCmp( u"0123456789ABCDEF"_ustr );
+        auto isValidDigit = rtl::isAsciiHexDigit<sal_Unicode>;
         char base = 16;
         char ndig = 8;
         switch( *p++ )
         {
             case 'O':
             case 'o':
-                aCmp = "01234567";
+                isValidDigit = rtl::isAsciiOctalDigit<sal_Unicode>;
                 base = 8;
                 ndig = 11;
                 break;
@@ -213,29 +208,18 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
             case 'h':
                 break;
             default :
-                bRes = false;
+                return ERRCODE_BASIC_CONVERSION;
         }
-        while( rtl::isAsciiAlphanumeric( *p ) )    /* XXX: really munge all 
alnum also when error? */
+        const auto pDigitsStart = p;
+        for (; p != rWSrc.end() && rtl::isAsciiAlphanumeric(*p); ++p)
         {
-            sal_Unicode ch = rtl::toAsciiUpperCase(*p);
-            if( ImpStrChr( aCmp, ch ) )
-                aBuf.append( ch );
-            else
-                bRes = false;
-            p++;
+            if (!isValidDigit(*p))
+                return ERRCODE_BASIC_CONVERSION;
         }
-        OUString aBufStr( aBuf.makeStringAndClear());
-        sal_Int32 l = 0;
-        for( const sal_Unicode* q = aBufStr.getStr(); bRes && *q; q++ )
-        {
-            int i = *q - '0';
-            if( i > 9 )
-                i -= 7;     // 'A'-'0' = 17 => 10, ...
-            l = ( l * base ) + i;
-            if( !ndig-- )
-                bRes = false;
-        }
-        if( *p == '&' )
+        if (p - pDigitsStart > ndig)
+                return ERRCODE_BASIC_CONVERSION;
+        sal_Int32 l = o3tl::toInt32(rWSrc.substr(pDigitsStart - pStart, p - 
pDigitsStart), base);
+        if (p != rWSrc.end() && *p == '&')
             p++;
         nVal = static_cast<double>(l);
         if( l >= SbxMININT && l <= SbxMAXINT )
@@ -248,19 +232,17 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
     }
 #endif
     // tdf#146672 - skip whitespaces and tabs at the end of the scanned string
-    while (*p == ' ' || *p == '        ')
+    while (p != rWSrc.end() && (*p == ' ' || *p == '   '))
         p++;
     if( pLen )
         *pLen = static_cast<sal_uInt16>( p - pStart );
-    if( !bRes )
-        return ERRCODE_BASIC_CONVERSION;
     if( bMinus )
         nVal = -nVal;
     rType = eScanType;
     return ERRCODE_NONE;
 }
 
-ErrCode ImpScan(const OUString& rSrc, double& nVal, SbxDataType& rType, 
sal_uInt16* pLen)
+ErrCode ImpScan(std::u16string_view rSrc, double& nVal, SbxDataType& rType, 
sal_uInt16* pLen)
 {
     using namespace officecfg::Office::Scripting;
     static const bool bEnv = std::getenv("LIBREOFFICE6FLOATINGPOINTMODE") != 
nullptr;
@@ -338,7 +320,7 @@ static void printfmtstr(std::u16string_view rStr, OUString& 
rRes, std::u16string
 }
 
 
-bool SbxValue::Scan( const OUString& rSrc, sal_uInt16* pLen )
+bool SbxValue::Scan(std::u16string_view rSrc, sal_uInt16* pLen)
 {
     ErrCode eRes = ERRCODE_NONE;
     if( !CanWrite() )
diff --git a/include/basic/sbxvar.hxx b/include/basic/sbxvar.hxx
index b6aed459ca6c..29976d1fe7f6 100644
--- a/include/basic/sbxvar.hxx
+++ b/include/basic/sbxvar.hxx
@@ -189,7 +189,7 @@ public:
     SAL_DLLPRIVATE bool Convert( SbxDataType );
     bool Compute( SbxOperator, const SbxValue& );
     bool Compare( SbxOperator, const SbxValue& ) const;
-    SAL_DLLPRIVATE bool Scan( const OUString&, sal_uInt16* );
+    SAL_DLLPRIVATE bool Scan( std::u16string_view, sal_uInt16* );
     SAL_DLLPRIVATE void Format( OUString&, const OUString* = nullptr ) const;
 
     // The following operators are defined for easier handling.
commit d8384563990f15a0bc9fac10d588c48cab481c56
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Dec 23 09:46:31 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Jan 8 13:04:21 2025 +0100

    Simplify a bit
    
    The previous code made sure that cNonIntntlDecSep is always equal to
    IntntlDecSep (in the code handling bOnlyIntntl). Frop the redundancy,
    and make the variable names simpler.
    
    Change-Id: I31c994cd49bdbf007e110f593297acf112cc420b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179198
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179931

diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index a7b63710a55c..db042b0b9315 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -73,21 +73,19 @@ static bool ImpStrChr( std::u16string_view str, sal_Unicode 
c ) { return str.fin
 ErrCode ImpScan( const OUString& rWSrc, double& nVal, SbxDataType& rType,
                   sal_uInt16* pLen, bool bOnlyIntntl )
 {
-    sal_Unicode cIntntlDecSep, cIntntlGrpSep, cIntntlDecSepAlt;
-    sal_Unicode cNonIntntlDecSep = '.';
+    sal_Unicode cDecSep, cGrpSep, cDecSepAlt;
     if( bOnlyIntntl )
     {
-        ImpGetIntntlSep( cIntntlDecSep, cIntntlGrpSep, cIntntlDecSepAlt );
-        cNonIntntlDecSep = cIntntlDecSep;
+        ImpGetIntntlSep(cDecSep, cGrpSep, cDecSepAlt);
         // Ensure that the decimal separator alternative is really one.
-        if (cIntntlDecSepAlt && cIntntlDecSepAlt == cNonIntntlDecSep)
-            cIntntlDecSepAlt = 0;
+        if (cDecSepAlt == cDecSep)
+            cDecSepAlt = 0;
     }
     else
     {
-        cIntntlDecSep = cNonIntntlDecSep;
-        cIntntlGrpSep = 0;  // no group separator accepted in non-i18n
-        cIntntlDecSepAlt = 0;
+        cDecSep = '.';
+        cGrpSep = 0;  // no group separator accepted in non-i18n
+        cDecSepAlt = 0;
     }
 
     const sal_Unicode* const pStart = rWSrc.getStr();
@@ -106,9 +104,9 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
         p++;
         bMinus = true;
     }
-    if( rtl::isAsciiDigit( *p ) || ((*p == cNonIntntlDecSep || *p == 
cIntntlDecSep ||
-                    (cIntntlGrpSep && *p == cIntntlGrpSep) || 
(cIntntlDecSepAlt && *p == cIntntlDecSepAlt)) &&
-                rtl::isAsciiDigit( *(p+1) )))
+    if (rtl::isAsciiDigit(*p)
+        || ((*p == cDecSep || (cGrpSep && *p == cGrpSep) || (cDecSepAlt && *p 
== cDecSepAlt))
+            && rtl::isAsciiDigit(*(p + 1))))
     {
         // tdf#118442: Whitespace and minus are skipped; store the position to 
calculate index
         const sal_Unicode* const pDigitsStart = p;
@@ -116,27 +114,25 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
         short decsep = 0;
         short ndig = 0;
         short ncdig = 0;    // number of digits after decimal point
-        OUStringBuffer aSearchStr(OUString::Concat("0123456789DEde") + 
OUStringChar(cNonIntntlDecSep));
-        if( cIntntlDecSep != cNonIntntlDecSep )
-            aSearchStr.append(cIntntlDecSep);
-        if( cIntntlDecSepAlt && cIntntlDecSepAlt != cNonIntntlDecSep )
-            aSearchStr.append(cIntntlDecSepAlt);
-        if( bOnlyIntntl )
-            aSearchStr.append(cIntntlGrpSep);
+        OUStringBuffer aSearchStr("0123456789DEde" + OUStringChar(cDecSep));
+        if (cDecSepAlt)
+            aSearchStr.append(cDecSepAlt);
+        if (cGrpSep)
+            aSearchStr.append(cGrpSep);
         const OUString pSearchStr = aSearchStr.makeStringAndClear();
         static constexpr OUStringLiteral pDdEe = u"DdEe";
         while( ImpStrChr( pSearchStr, *p ) )
         {
             aBuf.append( *p );
-            if( bOnlyIntntl && *p == cIntntlGrpSep )
+            if (cGrpSep && *p == cGrpSep)
             {
                 p++;
                 continue;
             }
-            if( *p == cNonIntntlDecSep || *p == cIntntlDecSep || 
(cIntntlDecSepAlt && *p == cIntntlDecSepAlt) )
+            if (*p == cDecSep || (cDecSepAlt && *p == cDecSepAlt))
             {
                 // Use the separator that is passed to stringToDouble()
-                aBuf[p - pDigitsStart] = cIntntlDecSep;
+                aBuf[p - pDigitsStart] = cDecSep;
                 p++;
                 if( ++decsep > 1 )
                     continue;
@@ -175,7 +171,7 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
 
         rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
         sal_Int32 nParseEnd = 0;
-        nVal = rtl::math::stringToDouble( aBuf, cIntntlDecSep, cIntntlGrpSep, 
&eStatus, &nParseEnd );
+        nVal = rtl::math::stringToDouble(aBuf, cDecSep, cGrpSep, &eStatus, 
&nParseEnd);
         if( eStatus != rtl_math_ConversionStatus_Ok || nParseEnd != 
aBuf.getLength() )
             bRes = false;
 

Reply via email to