[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sc/source

Andreas Heinisch (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 9 19:09:50 UTC 2020


 sc/source/ui/vba/vbarange.cxx |   25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

New commits:
commit a7cf65ac009819cb6ae3c08e5fe3f496ef31260a
Author:     Andreas Heinisch <andreas.heinisch at yahoo.de>
AuthorDate: Tue Apr 7 16:43:18 2020 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Thu Jul 9 21:09:14 2020 +0200

    tdf#107885 - VBA AutoFilter can't compare strings
    
     This is a combination of 2 commits.
    
    tdf#107885 - VBA AutoFilter can't compare strings
    
    During the creation of table fields from an auto filter
    search criteria, check if the search text is numeric
    in order to search either for strings or numeric values.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91834
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit 59374ea361815b022b1f2a415f995852f23f222e)
    
    Use OUString::toChar(), tdf#107885 follow-up
    
    (cherry picked from commit 978862b99ca7af6a17012084923494b6c85754d5)
    Change-Id: I6f334e7fd06c03850a535a0d54438577d15ccac4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98453
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 403ea1c2f1d5..f780474622f6 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -4303,7 +4303,6 @@ static void lcl_setTableFieldsFromCriteria( OUString& sCriteria1, const uno::Ref
     //  *searchtext* - contains
     //  <>*searchtext* - doesn't contain
     // [>|>=|<=|...]searchtext for GREATER_value, GREATER_EQUAL_value etc.
-    bool bIsNumeric = false;
     if ( sCriteria1.startsWith( EQUALS ) )
     {
         if ( sCriteria1.getLength() == static_cast<sal_Int32>(strlen(EQUALS)) )
@@ -4335,7 +4334,6 @@ static void lcl_setTableFieldsFromCriteria( OUString& sCriteria1, const uno::Ref
     }
     else if ( sCriteria1.startsWith( GREATERTHAN ) )
     {
-        bIsNumeric = true;
         if ( sCriteria1.startsWith( GREATERTHANEQUALS ) )
         {
             sCriteria1 = sCriteria1.copy( strlen(GREATERTHANEQUALS) );
@@ -4350,7 +4348,6 @@ static void lcl_setTableFieldsFromCriteria( OUString& sCriteria1, const uno::Ref
     }
     else if ( sCriteria1.startsWith( LESSTHAN ) )
     {
-        bIsNumeric = true;
         if ( sCriteria1.startsWith( LESSTHANEQUALS ) )
         {
             sCriteria1 = sCriteria1.copy( strlen(LESSTHANEQUALS) );
@@ -4366,11 +4363,27 @@ static void lcl_setTableFieldsFromCriteria( OUString& sCriteria1, const uno::Ref
     else
         rFilterField.Operator = sheet::FilterOperator2::EQUAL;
 
-    if ( bIsNumeric )
+    // tdf#107885 - check if criteria is numeric using locale dependent settings without group seperator
+    // or, if the decimal separator is different from the English locale, without any locale.
+    sal_Int32 nParseEnd = 0;
+    rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
+    double fValue = ScGlobal::getLocaleDataPtr()->stringToDouble( sCriteria1, false, &eStatus, &nParseEnd );
+    if ( nParseEnd == sCriteria1.getLength() && eStatus == rtl_math_ConversionStatus_Ok )
     {
-        rFilterField.IsNumeric= true;
-        rFilterField.NumericValue = sCriteria1.toDouble();
+        rFilterField.IsNumeric = true;
+        rFilterField.NumericValue = fValue;
     }
+    else if ( ScGlobal::getLocaleDataPtr()->getNumDecimalSep().toChar() != '.' )
+    {
+        eStatus = rtl_math_ConversionStatus_Ok;
+        fValue = ::rtl::math::stringToDouble( sCriteria1, '.', 0, &eStatus, &nParseEnd );
+        if ( nParseEnd == sCriteria1.getLength() && eStatus == rtl_math_ConversionStatus_Ok )
+        {
+            rFilterField.IsNumeric = true;
+            rFilterField.NumericValue = fValue;
+        }
+    }
+
     rFilterField.StringValue = sCriteria1;
 }
 


More information about the Libreoffice-commits mailing list