[Libreoffice-commits] core.git: sc/qa sc/source
Szymon Kłos
szymon.klos at collabora.com
Fri May 12 09:22:27 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 8891472e1f9c5e452a4e8d55241eeba118274092
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>
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 4e3352b79edd..da37019e66a3 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -4482,6 +4482,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 );
@@ -4496,11 +4497,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
{
@@ -4548,12 +4573,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);
@@ -4569,6 +4595,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