[Libreoffice-commits] core.git: sc/source
Andreas Heinisch (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 9 15:10:06 UTC 2020
sc/source/ui/vba/vbarange.cxx | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
New commits:
commit 59374ea361815b022b1f2a415f995852f23f222e
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 17:09:20 2020 +0200
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.
Change-Id: I6f334e7fd06c03850a535a0d54438577d15ccac4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91834
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 30c1904aed8b..94d32d9eed93 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()[0] != '.' )
+ {
+ 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