[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sc/qa sc/source

Szymon Kłos szymon.klos at collabora.com
Tue Aug 15 12:20:31 UTC 2017


 sc/qa/extras/testdocuments/AutoFilter.xls |binary
 sc/source/ui/vba/vbarange.cxx             |   45 ++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 5 deletions(-)

New commits:
commit 44ec0adc7ea196f5aede4964fe49248aded4ab28
Author: Szymon Kłos <szymon.klos at collabora.com>
Date:   Wed May 10 12:36:48 2017 +0200

    tdf#107238 VBA autofilter: list of strings
    
    * support of string arrays in the VBA AutoFilter
    * tests:
      - reading string arrays
      - skip Criteria2 when Criteria1 is an array
      - use only last element of Criteria2 array
    
    Change-Id: I8faf6af8c4fbf9b654885b31210ef77bae3a39af
    Reviewed-on: https://gerrit.libreoffice.org/37515
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/41137
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>

diff --git a/sc/qa/extras/testdocuments/AutoFilter.xls b/sc/qa/extras/testdocuments/AutoFilter.xls
index 75efd8ddc609..1a8e5e5e9904 100644
Binary files a/sc/qa/extras/testdocuments/AutoFilter.xls and b/sc/qa/extras/testdocuments/AutoFilter.xls differ
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 955d35a2c4e8..c5bade6e0dbb 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -4477,6 +4477,7 @@ ScVbaRange::AutoFilter( const uno::Any& aField, const uno::Any& Criteria1, const
     if ( ( Field >>= nField )  )
     {
         bool bAll = false;
+        bool bAcceptCriteria2 = true;
 
         uno::Reference< sheet::XSheetFilterDescriptor2 > xDesc(
                 xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY );
@@ -4491,11 +4492,35 @@ ScVbaRange::AutoFilter( const uno::Any& aField, const uno::Any& Criteria1, const
             if ( !bCritHasNumericValue )
             {
                 Criteria1 >>= sCriteria1;
-                sTabFilts[0].IsNumeric = bCritHasNumericValue;
-                if ( bHasCritValue && !sCriteria1.isEmpty() )
-                    lcl_setTableFieldsFromCriteria( sCriteria1, xDescProps, sTabFilts[0]  );
+                if ( sCriteria1.isEmpty() )
+                {
+                    uno::Sequence< OUString > aCriteria1;
+                    Criteria1 >>= aCriteria1;
+                    sal_uInt16 nLength = aCriteria1.getLength();
+                    if ( nLength )
+                    {
+                        // When sequence is provided for Criteria1 don't care about Criteria2
+                        bAcceptCriteria2 = false;
+
+                        sTabFilts.realloc( nLength );
+                        for ( sal_uInt16 i = 0; i < nLength; ++i )
+                        {
+                            lcl_setTableFieldsFromCriteria( aCriteria1[i], xDescProps, sTabFilts[i] );
+                            sTabFilts[i].Connection = sheet::FilterConnection_OR;
+                            sTabFilts[i].Field = (nField - 1);
+                        }
+                    }
+                    else
+                        bAll = true;
+                }
                 else
-                    bAll = true;
+                {
+                    sTabFilts[0].IsNumeric = bCritHasNumericValue;
+                    if ( bHasCritValue && !sCriteria1.isEmpty() )
+                        lcl_setTableFieldsFromCriteria( sCriteria1, xDescProps, sTabFilts[0]  );
+                    else
+                        bAll = true;
+                }
             }
             else // numeric
             {
@@ -4543,12 +4568,13 @@ ScVbaRange::AutoFilter( const uno::Any& aField, const uno::Any& Criteria1, const
             }
 
         }
-        if ( !bAll )
+        if ( !bAll && bAcceptCriteria2 )
         {
             sTabFilts[0].Connection = sheet::FilterConnection_AND;
             sTabFilts[0].Field = (nField - 1);
 
             OUString sCriteria2;
+            uno::Sequence< OUString > aCriteria2;
             if ( Criteria2.hasValue() ) // there is a Criteria2
             {
                 sTabFilts.realloc(2);
@@ -4564,6 +4590,15 @@ ScVbaRange::AutoFilter( const uno::Any& aField, const uno::Any& Criteria1, const
                         sTabFilts[1].IsNumeric = false;
                     }
                 }
+                else if ( Criteria2 >>= aCriteria2 )
+                {
+                    sal_uInt16 nLength = aCriteria2.getLength();
+                    if ( nLength )
+                    {
+                        // For compatibility use only the last value form the sequence
+                        lcl_setTableFieldsFromCriteria( aCriteria2[nLength - 1], xDescProps, sTabFilts[1] );
+                    }
+                }
                 else // numeric
                 {
                     Criteria2 >>= sTabFilts[1].NumericValue;


More information about the Libreoffice-commits mailing list