aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2021-02-18 18:04:53 +0100
committerLászló Németh <nemeth@numbertext.org>2021-02-25 14:53:07 +0100
commit7ba76115b0e3baefae0ede66848f4340c7c7401b (patch)
tree701dea27eea5be1827485b74dfc05bcce84124a1
parent3421440bfbfff7c59caea881be64b684e601e04f (diff)
tdf#140469 XLSX import: apply more than 8 filters
in OOXML autofilter import by removing the artificial limit (which looked like the limit for conditions handled by the standard filter in LO, but not for the autofilter). Now the autofilter popup menu does not always select all items, if the document contained more than 8 selected items there. Change-Id: Iaa6ce15d4b1162ab78dd001734721ae859283d0d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111156 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sc/qa/uitest/autofilter/autofilter.py15
-rw-r--r--sc/qa/uitest/data/autofilter/tdf140469.xlsxbin0 -> 9297 bytes
-rw-r--r--sc/source/filter/inc/autofilterbuffer.hxx10
-rw-r--r--sc/source/filter/oox/autofilterbuffer.cxx51
4 files changed, 40 insertions, 36 deletions
diff --git a/sc/qa/uitest/autofilter/autofilter.py b/sc/qa/uitest/autofilter/autofilter.py
index ab295fa84dfe..1eedfe4b22a7 100644
--- a/sc/qa/uitest/autofilter/autofilter.py
+++ b/sc/qa/uitest/autofilter/autofilter.py
@@ -263,4 +263,19 @@ class AutofilterTest(UITestCase):
xOkBtn.executeAction("CLICK", tuple())
self.ui_test.close_doc()
+
+ def test_tdf140469(self):
+ doc = self.ui_test.load_file(get_url_for_data_file("tdf140469.xlsx"))
+
+ xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+
+ xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"}))
+ xFloatWindow = self.xUITest.getFloatWindow()
+ xCheckListMenu = xFloatWindow.getChild("check_list_menu")
+ xTreeList = xCheckListMenu.getChild("check_list_box")
+ self.assertEqual(9, len(xTreeList.getChildren()))
+ xOkBtn = xFloatWindow.getChild("cancel")
+ xOkBtn.executeAction("CLICK", tuple())
+
+ self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/autofilter/tdf140469.xlsx b/sc/qa/uitest/data/autofilter/tdf140469.xlsx
new file mode 100644
index 000000000000..3c90c7cfe1b1
--- /dev/null
+++ b/sc/qa/uitest/data/autofilter/tdf140469.xlsx
Binary files differ
diff --git a/sc/source/filter/inc/autofilterbuffer.hxx b/sc/source/filter/inc/autofilterbuffer.hxx
index e0270336a10e..3b512f4f98b9 100644
--- a/sc/source/filter/inc/autofilterbuffer.hxx
+++ b/sc/source/filter/inc/autofilterbuffer.hxx
@@ -64,7 +64,7 @@ public:
virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm );
/** Derived classes return converted UNO API filter settings representing all filter settings. */
- virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount );
+ virtual ApiFilterSettings finalizeImport();
};
@@ -82,7 +82,7 @@ public:
virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
/** Returns converted UNO API filter settings representing all filter settings. */
- virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount ) override;
+ virtual ApiFilterSettings finalizeImport() override;
private:
@@ -103,7 +103,7 @@ public:
virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
/** Returns converted UNO API filter settings representing all filter settings. */
- virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount ) override;
+ virtual ApiFilterSettings finalizeImport() override;
private:
double mfValue; /// Number of items or percentage.
@@ -141,7 +141,7 @@ public:
virtual void importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm ) override;
/** Returns converted UNO API filter settings representing all filter settings. */
- virtual ApiFilterSettings finalizeImport( sal_Int32 nMaxCount ) override;
+ virtual ApiFilterSettings finalizeImport() override;
private:
/** Appends the passed filter criterion, if it contains valid settings. */
@@ -174,7 +174,7 @@ public:
/** Returns converted UNO API filter settings representing all filter
settings of this column. */
- ApiFilterSettings finalizeImport( sal_Int32 nMaxCount );
+ ApiFilterSettings finalizeImport();
private:
std::shared_ptr< FilterSettingsBase >
diff --git a/sc/source/filter/oox/autofilterbuffer.cxx b/sc/source/filter/oox/autofilterbuffer.cxx
index 757981a66ee3..a9ec62c4e655 100644
--- a/sc/source/filter/oox/autofilterbuffer.cxx
+++ b/sc/source/filter/oox/autofilterbuffer.cxx
@@ -205,7 +205,7 @@ void FilterSettingsBase::importRecord( sal_Int32 /*nRecId*/, SequenceInputStream
{
}
-ApiFilterSettings FilterSettingsBase::finalizeImport( sal_Int32 /*nMaxCount*/ )
+ApiFilterSettings FilterSettingsBase::finalizeImport()
{
return ApiFilterSettings();
}
@@ -295,25 +295,23 @@ void DiscreteFilter::importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm
}
}
-ApiFilterSettings DiscreteFilter::finalizeImport( sal_Int32 nMaxCount )
+ApiFilterSettings DiscreteFilter::finalizeImport()
{
ApiFilterSettings aSettings;
- if( static_cast< sal_Int32 >( maValues.size() ) <= nMaxCount )
- {
- aSettings.maFilterFields.reserve( maValues.size() );
+ aSettings.maFilterFields.reserve( maValues.size() );
- // insert all filter values
- aSettings.appendField( true, maValues );
+ // insert all filter values
+ aSettings.appendField( true, maValues );
- // extra field for 'show empty'
- if( mbShowBlank )
- aSettings.appendField( false, FilterOperator2::EMPTY, OUString() );
+ // extra field for 'show empty'
+ if( mbShowBlank )
+ aSettings.appendField( false, FilterOperator2::EMPTY, OUString() );
+
+ /* Require disabled regular expressions, filter entries may contain
+ any RE meta characters. */
+ if( !maValues.empty() )
+ aSettings.mobNeedsRegExp = false;
- /* Require disabled regular expressions, filter entries may contain
- any RE meta characters. */
- if( !maValues.empty() )
- aSettings.mobNeedsRegExp = false;
- }
return aSettings;
}
@@ -347,7 +345,7 @@ void Top10Filter::importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm )
}
}
-ApiFilterSettings Top10Filter::finalizeImport( sal_Int32 /*nMaxCount*/ )
+ApiFilterSettings Top10Filter::finalizeImport()
{
sal_Int32 nOperator = mbTop ?
(mbPercent ? FilterOperator2::TOP_PERCENT : FilterOperator2::TOP_VALUES) :
@@ -455,7 +453,7 @@ void CustomFilter::importRecord( sal_Int32 nRecId, SequenceInputStream& rStrm )
}
}
-ApiFilterSettings CustomFilter::finalizeImport( sal_Int32 /*nMaxCount*/ )
+ApiFilterSettings CustomFilter::finalizeImport()
{
ApiFilterSettings aSettings;
OSL_ENSURE( maCriteria.size() <= 2, "CustomFilter::finalizeImport - too many filter criteria" );
@@ -552,13 +550,13 @@ void FilterColumn::importFilterColumn( SequenceInputStream& rStrm )
mbShowButton = getFlag( nFlags, BIFF12_FILTERCOLUMN_SHOWBUTTON );
}
-ApiFilterSettings FilterColumn::finalizeImport( sal_Int32 nMaxCount )
+ApiFilterSettings FilterColumn::finalizeImport()
{
ApiFilterSettings aSettings;
if( (0 <= mnColId) && mxSettings )
{
// filter settings object creates a sequence of filter fields
- aSettings = mxSettings->finalizeImport( nMaxCount );
+ aSettings = mxSettings->finalizeImport();
// add column index to all filter fields
for( auto& rFilterField : aSettings.maFilterFields )
rFilterField.Field = mnColId;
@@ -638,11 +636,6 @@ void AutoFilter::finalizeImport( const Reference< XDatabaseRange >& rxDatabaseRa
aDescProps.setProperty( PROP_ContainsHeader, true );
aDescProps.setProperty( PROP_CopyOutputData, false );
- // maximum number of UNO API filter fields
- sal_Int32 nMaxCount = 0;
- aDescProps.getProperty( nMaxCount, PROP_MaxFieldCount );
- OSL_ENSURE( nMaxCount > 0, "AutoFilter::finalizeImport - invalid maximum filter field count" );
-
// resulting list of all UNO API filter fields
::std::vector<TableFilterField3> aFilterFields;
@@ -662,12 +655,9 @@ void AutoFilter::finalizeImport( const Reference< XDatabaseRange >& rxDatabaseRa
for( const auto& rxFilterColumn : maFilterColumns )
{
// the filter settings object creates a list of filter fields
- ApiFilterSettings aSettings = rxFilterColumn->finalizeImport( nMaxCount );
+ ApiFilterSettings aSettings = rxFilterColumn->finalizeImport();
ApiFilterSettings::FilterFieldVector& rColumnFields = aSettings.maFilterFields;
- // new total number of filter fields
- sal_Int32 nNewCount = static_cast< sal_Int32 >( aFilterFields.size() + rColumnFields.size() );
-
/* Check whether mode for regular expressions is compatible with
the global mode in obNeedsRegExp. If either one is still in
don't-care state, all is fine. If both are set, they must be
@@ -680,10 +670,9 @@ void AutoFilter::finalizeImport( const Reference< XDatabaseRange >& rxDatabaseRa
[](const css::sheet::TableFilterField3& rColumnField) { return rColumnField.Connection == FilterConnection_OR; });
/* Skip the column filter, if no filter fields have been created,
- if the number of new filter fields would exceed the total limit
- of filter fields, or if the mode for regular expressions of the
+ and if the mode for regular expressions of the
filter column does not fit. */
- if( !rColumnFields.empty() && (nNewCount <= nMaxCount) && bRegExpCompatible )
+ if( !rColumnFields.empty() && bRegExpCompatible )
{
/* Add 'and' connection to the first filter field to connect
it to the existing filter fields of other columns. */