sc/qa/uitest/autofilter/autofilter.py | 39 ++++++++++++++++++++++++++++++++++ sc/source/ui/view/viewfunc.cxx | 28 +++++++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-)
New commits: commit 3394e8746c505a8dae112f555cb2bb3e4596cbba Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Tue Sep 13 22:18:09 2022 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Wed Oct 5 17:30:46 2022 +0200 tdf#36383 - sc AutoFilter: fix changing row height Changing row height showed the rows hidden by AutoFilter, removing the result of the filtering. Change-Id: Iecc8eb03ed563de126e7a376dad41a4ab2434f0e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139883 Tested-by: Jenkins Reviewed-by: Eike Rathke <er...@redhat.com> diff --git a/sc/qa/uitest/autofilter/autofilter.py b/sc/qa/uitest/autofilter/autofilter.py index 8f6db292230e..f792c0fdad33 100644 --- a/sc/qa/uitest/autofilter/autofilter.py +++ b/sc/qa/uitest/autofilter/autofilter.py @@ -376,6 +376,45 @@ class AutofilterTest(UITestCase): self.assertFalse(is_row_hidden(doc, 6)) self.assertFalse(is_row_hidden(doc, 7)) + def test_tdf36383_row_height(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "A2", "1") + enter_text_to_cell(gridwin, "A3", "2") + enter_text_to_cell(gridwin, "A4", "3") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + + self.xUITest.executeCommand(".uno:DataFilterAutoFilter") + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("FilterDropDown") + xTreeList = xCheckListMenu.getChild("check_list_box") + xEntry = xTreeList.getChild("1") + xEntry.executeAction("CLICK", tuple()) + + xOkButton = xFloatWindow.getChild("ok") + xOkButton.executeAction("CLICK", tuple()) + + self.assertTrue(is_row_hidden(document, 2)) + + # row height + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + + self.assertTrue(is_row_hidden(document, 2)) + + # optimal row height + with self.ui_test.execute_dialog_through_command(".uno:SetOptimalRowHeight"): + pass + + self.assertTrue(is_row_hidden(document, 2)) + def test_tdf142350(self): with self.ui_test.create_doc_in_start_center("calc") as document: calcDoc = self.xUITest.getTopFocusWindow() diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index c5341aadfa65..423c66abef2b 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -80,6 +80,19 @@ #include <memory> +static void ShowFilteredRows(ScDocument& rDoc, SCTAB nTab, SCCOLROW nStartNo, SCCOLROW nEndNo, + bool bShow) +{ + SCROW nFirstRow = nStartNo; + SCROW nLastRow = nStartNo; + do + { + if (!rDoc.RowFiltered(nFirstRow, nTab, nullptr, &nLastRow)) + rDoc.ShowRows(nFirstRow, nLastRow < nEndNo ? nLastRow : nEndNo, nTab, bShow); + nFirstRow = nLastRow + 1; + } while (nFirstRow <= nEndNo); +} + static void lcl_PostRepaintCondFormat( const ScConditionalFormat *pCondFmt, ScDocShell *pDocSh ) { if( pCondFmt ) @@ -2202,6 +2215,7 @@ void ScViewFunc::SetWidthOrHeight( if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT ) { bool bAll = ( eMode==SC_SIZE_OPTIMAL ); + bool bFiltered = false; if (!bAll) { // delete CRFlags::ManualSize for all in range, @@ -2220,6 +2234,14 @@ void ScViewFunc::SetWidthOrHeight( rDoc.SetRowFlags(nRow, nTab, nOld & ~CRFlags::ManualSize); } } + else + { + SCROW nLastRow = nStartNo; + if (rDoc.RowFiltered(nStartNo, nTab, nullptr, &nLastRow) + || nLastRow < nEndNo) + bFiltered = true; + } + double nPPTX = GetViewData().GetPPTX(); double nPPTY = GetViewData().GetPPTY(); @@ -2239,6 +2261,9 @@ void ScViewFunc::SetWidthOrHeight( aCxt.setExtraHeight(nSizeTwips); rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab, true); + if (bFiltered) + ShowFilteredRows(rDoc, nTab, nStartNo, nEndNo, bShow); + // Manual-Flag already (re)set in SetOptimalHeight in case of bAll=sal_True // (set for Extra-Height, else reset). } @@ -2250,7 +2275,8 @@ void ScViewFunc::SetWidthOrHeight( rDoc.SetManualHeight( nStartNo, nEndNo, nTab, true ); // height was set manually } - rDoc.ShowRows( nStartNo, nEndNo, nTab, nSizeTwips != 0 ); + // tdf#36383 - Skip consecutive rows hidden by AutoFilter + ShowFilteredRows(rDoc, nTab, nStartNo, nEndNo, nSizeTwips != 0); if (!bShow && nStartNo <= nCurY && nCurY <= nEndNo && nTab == nCurTab) {