sc/qa/uitest/autofilter/autofilter.py | 25 ++++++ sc/qa/uitest/data/autofilter/tdf138438.ods |binary sc/source/core/data/table3.cxx | 105 ++++++++++++++--------------- 3 files changed, 79 insertions(+), 51 deletions(-)
New commits: commit a890963f4fcd06859129901e54660d97fa26c362 Author: Balazs Varga <balazs.varga...@gmail.com> AuthorDate: Sun May 9 10:31:21 2021 +0200 Commit: Gabor Kelemen <kelemen.gab...@nisz.hu> CommitDate: Fri Jul 2 14:25:37 2021 +0200 tdf#138438 sc: fix "Top 10" autoFilter in multiple columns Check all QueryItems instead of just the first one. Now top 10 values are visible (except the values hidden by the filters of the previous columns). Change-Id: I317d0c6843e568f8645b744968352a0e895a42dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115267 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit fbfb57635b602b50cb22465047ae5bcdbef3dd0a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118292 Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu> diff --git a/sc/qa/uitest/autofilter/autofilter.py b/sc/qa/uitest/autofilter/autofilter.py index b3ddb4f6f8a8..1a9360a6031e 100644 --- a/sc/qa/uitest/autofilter/autofilter.py +++ b/sc/qa/uitest/autofilter/autofilter.py @@ -356,5 +356,30 @@ class AutofilterTest(UITestCase): xCloseButton = xFloatWindow.getChild("cancel") xCloseButton.executeAction("CLICK", tuple()) + self.ui_test.close_doc() + + def test_tdf138438(self): + doc = self.ui_test.load_file(get_url_for_data_file("tdf138438.ods")) + + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + + # Top 10 filer + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xMenu = xFloatWindow.getChild("menu") + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + self.assertFalse(is_row_hidden(doc, 0)) + self.assertTrue(is_row_hidden(doc, 1)) + self.assertTrue(is_row_hidden(doc, 2)) + self.assertFalse(is_row_hidden(doc, 3)) + self.assertFalse(is_row_hidden(doc, 4)) + self.assertFalse(is_row_hidden(doc, 5)) + self.assertFalse(is_row_hidden(doc, 6)) + self.assertTrue(is_row_hidden(doc, 7)) + self.assertFalse(is_row_hidden(doc, 8)) + self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/data/autofilter/tdf138438.ods b/sc/qa/uitest/data/autofilter/tdf138438.ods new file mode 100644 index 000000000000..1dbecc37fc80 Binary files /dev/null and b/sc/qa/uitest/data/autofilter/tdf138438.ods differ diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 58a0594f63b8..d94e6bf69703 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2869,48 +2869,50 @@ void ScTable::TopTenQuery( ScQueryParam& rParam ) for ( SCSIZE i=0; (i<nEntryCount) && (rParam.GetEntry(i).bDoQuery); i++ ) { ScQueryEntry& rEntry = rParam.GetEntry(i); - ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); + ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems(); - switch ( rEntry.eOp ) + for (ScQueryEntry::Item& rItem : rItems) { - case SC_TOPVAL: - case SC_BOTVAL: - case SC_TOPPERC: - case SC_BOTPERC: + switch (rEntry.eOp) { - ScSortParam aLocalSortParam( rParam, static_cast<SCCOL>(rEntry.nField) ); - aSortParam = aLocalSortParam; // used in CreateSortInfoArray, Compare - if ( !bSortCollatorInitialized ) - { - bSortCollatorInitialized = true; - InitSortCollator( aLocalSortParam ); - } - std::unique_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(aSortParam, nRow1, rParam.nRow2, bGlobalKeepQuery, false)); - DecoladeRow( pArray.get(), nRow1, rParam.nRow2 ); - QuickSort( pArray.get(), nRow1, rParam.nRow2 ); - std::unique_ptr<ScSortInfo[]> const & ppInfo = pArray->GetFirstArray(); - SCSIZE nValidCount = nCount; - // Don't count note or blank cells, they are sorted to the end - while (nValidCount > 0 && ppInfo[nValidCount-1].maCell.isEmpty()) - nValidCount--; - // Don't count Strings, they are between Value and blank - while (nValidCount > 0 && ppInfo[nValidCount-1].maCell.hasString()) - nValidCount--; - if ( nValidCount > 0 ) + case SC_TOPVAL: + case SC_BOTVAL: + case SC_TOPPERC: + case SC_BOTPERC: { - if ( rItem.meType == ScQueryEntry::ByString ) - { // by string ain't going to work - rItem.meType = ScQueryEntry::ByValue; - rItem.mfVal = 10; // 10 and 10% respectively + ScSortParam aLocalSortParam(rParam, static_cast<SCCOL>(rEntry.nField)); + aSortParam = aLocalSortParam; // used in CreateSortInfoArray, Compare + if (!bSortCollatorInitialized) + { + bSortCollatorInitialized = true; + InitSortCollator(aLocalSortParam); } - SCSIZE nVal = (rItem.mfVal >= 1 ? static_cast<SCSIZE>(rItem.mfVal) : 1); - SCSIZE nOffset = 0; - switch ( rEntry.eOp ) + std::unique_ptr<ScSortInfoArray> pArray(CreateSortInfoArray(aSortParam, nRow1, rParam.nRow2, bGlobalKeepQuery, false)); + DecoladeRow(pArray.get(), nRow1, rParam.nRow2); + QuickSort(pArray.get(), nRow1, rParam.nRow2); + std::unique_ptr<ScSortInfo[]> const& ppInfo = pArray->GetFirstArray(); + SCSIZE nValidCount = nCount; + // Don't count note or blank cells, they are sorted to the end + while (nValidCount > 0 && ppInfo[nValidCount - 1].maCell.isEmpty()) + nValidCount--; + // Don't count Strings, they are between Value and blank + while (nValidCount > 0 && ppInfo[nValidCount - 1].maCell.hasString()) + nValidCount--; + if (nValidCount > 0) { + if (rItem.meType == ScQueryEntry::ByString) + { // by string ain't going to work + rItem.meType = ScQueryEntry::ByValue; + rItem.mfVal = 10; // 10 and 10% respectively + } + SCSIZE nVal = (rItem.mfVal >= 1 ? static_cast<SCSIZE>(rItem.mfVal) : 1); + SCSIZE nOffset = 0; + switch (rEntry.eOp) + { case SC_TOPVAL: { rEntry.eOp = SC_GREATER_EQUAL; - if ( nVal > nValidCount ) + if (nVal > nValidCount) nVal = nValidCount; nOffset = nValidCount - nVal; // 1 <= nVal <= nValidCount } @@ -2918,7 +2920,7 @@ void ScTable::TopTenQuery( ScQueryParam& rParam ) case SC_BOTVAL: { rEntry.eOp = SC_LESS_EQUAL; - if ( nVal > nValidCount ) + if (nVal > nValidCount) nVal = nValidCount; nOffset = nVal - 1; // 1 <= nVal <= nValidCount } @@ -2926,20 +2928,20 @@ void ScTable::TopTenQuery( ScQueryParam& rParam ) case SC_TOPPERC: { rEntry.eOp = SC_GREATER_EQUAL; - if ( nVal > 100 ) + if (nVal > 100) nVal = 100; nOffset = nValidCount - (nValidCount * nVal / 100); - if ( nOffset >= nValidCount ) + if (nOffset >= nValidCount) nOffset = nValidCount - 1; } break; case SC_BOTPERC: { rEntry.eOp = SC_LESS_EQUAL; - if ( nVal > 100 ) + if (nVal > 100) nVal = 100; nOffset = (nValidCount * nVal / 100); - if ( nOffset >= nValidCount ) + if (nOffset >= nValidCount) nOffset = nValidCount - 1; } break; @@ -2947,29 +2949,30 @@ void ScTable::TopTenQuery( ScQueryParam& rParam ) { // added to avoid warnings } + } + ScRefCellValue aCell = ppInfo[nOffset].maCell; + if (aCell.hasNumeric()) + rItem.mfVal = aCell.getValue(); + else + { + OSL_FAIL("TopTenQuery: pCell no ValueData"); + rEntry.eOp = SC_GREATER_EQUAL; + rItem.mfVal = 0; + } } - ScRefCellValue aCell = ppInfo[nOffset].maCell; - if (aCell.hasNumeric()) - rItem.mfVal = aCell.getValue(); else { - OSL_FAIL( "TopTenQuery: pCell no ValueData" ); rEntry.eOp = SC_GREATER_EQUAL; + rItem.meType = ScQueryEntry::ByValue; rItem.mfVal = 0; } } - else + break; + default: { - rEntry.eOp = SC_GREATER_EQUAL; - rItem.meType = ScQueryEntry::ByValue; - rItem.mfVal = 0; + // added to avoid warnings } } - break; - default: - { - // added to avoid warnings - } } } if ( bSortCollatorInitialized ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits