summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2022-02-09 20:17:53 +0200
committerEike Rathke <erack@redhat.com>2022-02-10 16:02:11 +0100
commit35302c773ab352f2a9681839c6c11c67d765fbe8 (patch)
treef73717fc326c4ea36041600221e12343e56d0eb9
parent5c0497337cb2cc34091d1ae58dab288a8a9a5454 (diff)
tdf#113785 sc: IsDataFiltered must be normalized
I can't believe this hasn't caused major issues and has survived as a bug for so long. Due to the way IsDataFiltered is coded, it is required that the range is normalized in order to get any kind of meaningful result, so lets ensure that. Change-Id: I2ede77f738fbaeb05a0f1425a2e88e59fca08e9e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129735 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> (cherry picked from commit bda200a5e9c4592bd61b7924fa171ec3265bfd24) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129761 Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/qa/uitest/calc_tests/autofill.py30
-rw-r--r--sc/qa/uitest/data/autofill.odsbin9873 -> 24109 bytes
-rw-r--r--sc/source/core/data/table2.cxx7
3 files changed, 35 insertions, 2 deletions
diff --git a/sc/qa/uitest/calc_tests/autofill.py b/sc/qa/uitest/calc_tests/autofill.py
index cdd92ea30947..594d29872a47 100644
--- a/sc/qa/uitest/calc_tests/autofill.py
+++ b/sc/qa/uitest/calc_tests/autofill.py
@@ -47,6 +47,36 @@ class CalcAutofill(UITestCase):
self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getValue(), 17.34)
self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 11).getValue(), 18.34)
+ #Test that hidden cells are not affected / skipped in the increment process.
+ #Simulate selecting cell A26 and dragging the fill handle in the bottom right corner of the cell down to A32
+ gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A26:A32"}))
+ with self.ui_test.execute_dialog_through_command(".uno:FillSeries"):
+ pass
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 25).getValue(), 18.34)
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 26).getValue(), 19.34)
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 27).getValue(), 5.0) #hidden
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 28).getValue(), 5.0) #hidden
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 29).getString(), "hiddenA30")
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 30).getValue(), 20.34) #overwrite "rows"
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 31).getValue(), 21.34)
+ #Simulate selecting cell A26 and dragging the fill handle in the bottom right corner of the cell up to A19
+ # Note: start at empty cell A19 so Sheet - Fill Cells - Fill Series has good defaults
+ gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A19:A26"}))
+ with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog:
+ xup = xDialog.getChild("up")
+ xincrement = xDialog.getChild("increment")
+ xup.executeAction("CLICK", tuple())
+ xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"}))
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 19).getString(), "hiddenA20")
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 20).getValue(), 15.34)
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 21).getValue(), 5.0) #hidden
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 22).getValue(), 16.34) #overwrite "testing"
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 23).getValue(), 5.0) #hidden
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 24).getValue(), 17.34) #overwrite "hidden"
+ self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 25).getValue(), 18.34)
+
#Continue with the next cells with grey background
gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "M12:M18"}))
with self.ui_test.execute_dialog_through_command(".uno:FillSeries"):
diff --git a/sc/qa/uitest/data/autofill.ods b/sc/qa/uitest/data/autofill.ods
index 4456e33338c8..90bf933c0c26 100644
--- a/sc/qa/uitest/data/autofill.ods
+++ b/sc/qa/uitest/data/autofill.ods
Binary files differ
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 40c515b9b10b..f78a17fe3eed 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -3671,6 +3671,8 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow)
bool ScTable::IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SCROW nRowEnd) const
{
+ assert(nColStart <= nColEnd && nRowStart <= nRowEnd
+ && "range must be normalized to obtain a valid result");
for (SCROW i = nRowStart; i <= nRowEnd; ++i)
{
if (RowHidden(i))
@@ -3686,8 +3688,9 @@ bool ScTable::IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SC
bool ScTable::IsDataFiltered(const ScRange& rRange) const
{
- return IsDataFiltered(rRange.aStart.Col(), rRange.aStart.Row(),
- rRange.aEnd.Col(), rRange.aEnd.Row());
+ ScRange aNormalized(rRange.aStart, rRange.aEnd);
+ return IsDataFiltered(aNormalized.aStart.Col(), aNormalized.aStart.Row(),
+ aNormalized.aEnd.Col(), aNormalized.aEnd.Row());
}
void ScTable::SetRowFlags( SCROW nRow, CRFlags nNewFlags )