summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/qa/uitest/autofilter/autofilter.py25
-rw-r--r--sc/qa/uitest/data/autofilter/tdf138438.odsbin0 -> 9281 bytes
-rw-r--r--sc/source/core/data/table3.cxx105
3 files changed, 79 insertions, 51 deletions
diff --git a/sc/qa/uitest/autofilter/autofilter.py b/sc/qa/uitest/autofilter/autofilter.py
index 3f20175ef618..334f7a90b3dd 100644
--- a/sc/qa/uitest/autofilter/autofilter.py
+++ b/sc/qa/uitest/autofilter/autofilter.py
@@ -431,4 +431,29 @@ class AutofilterTest(UITestCase):
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
--- /dev/null
+++ b/sc/qa/uitest/data/autofilter/tdf138438.ods
Binary files differ
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index e8837f6ca95a..216aa98e978a 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2906,48 +2906,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
}
@@ -2955,7 +2957,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
}
@@ -2963,20 +2965,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;
@@ -2984,29 +2986,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 )