sc/qa/uitest/autofilter/autofilterBugs.py | 27 ++++++++++ sc/qa/uitest/data/autofilter/tdf160018_use_on_database_range.ods |binary sc/source/core/data/documen3.cxx | 3 - 3 files changed, 29 insertions(+), 1 deletion(-)
New commits: commit 8ee1f52ff546ed8f307ae046ca7bfabf57067d56 Author: Regina Henschel <[email protected]> AuthorDate: Fri Feb 6 16:25:55 2026 +0100 Commit: Regina Henschel <[email protected]> CommitDate: Mon Feb 9 13:32:40 2026 +0100 tdf#160018 autofilter must not extend named database When an AutoFilter is launched, it determines the range it will work on. Thereby it extends the range to include adjacent empty cells that have a background set. This allows the AutoFilter to sort or filter by background color. This is useful behavior for anonymous database ranges. However, if the AutoFilter is part of a named range, this behavior is incorrect. The user has explicitly defined the range. Therefore, it must not be automatically changed simply by launching an AutoFilter associated to that range. The patch prevents named database ranges from being expanded. Change-Id: Ic60569e5e29fc67dc87f0282f837907b3f2858d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198849 Reviewed-by: Pranam Lashkari <[email protected]> Tested-by: Jenkins Reviewed-by: Henry Castro <[email protected]> diff --git a/sc/qa/uitest/autofilter/autofilterBugs.py b/sc/qa/uitest/autofilter/autofilterBugs.py index 5ebd0c923c13..c4659d586cab 100644 --- a/sc/qa/uitest/autofilter/autofilterBugs.py +++ b/sc/qa/uitest/autofilter/autofilterBugs.py @@ -294,4 +294,31 @@ class autofilter(UITestCase): xCancelBtn = xFloatWindow.getChild("cancel") xCancelBtn.executeAction("CLICK", tuple()) + #tdf1160018 + def test_tdf160018_use_on_database_range(self): + # Error was, that AutoFilter has extended the database range to which it is attached. + with self.ui_test.load_file(get_url_for_data_file("tdf160018_use_on_database_range.ods")): + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + + # select database range with name "upper". It has an AutoFilter. + propDbName = mkPropertyValues({"DbName": "upper"}) + self.xUITest.executeCommandWithParameters(".uno:SelectDB", propDbName) + + #verify size. + gridWinStateOrig = get_state_as_dict(xGridWin) + self.assertEqual(gridWinStateOrig["MarkedArea"], "Sheet1.A3:Sheet1.B11") + + # Open Autofilter and cancel immediately + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "2"})) + xFloatWindow = self.xUITest.getFloatWindow() + xButton = xFloatWindow.getChild("cancel") + xButton.executeAction("CLICK", tuple()) + + # select database range "upper" again. + self.xUITest.executeCommandWithParameters(".uno:SelectDB", propDbName) + + # Error was, that the range was extended to Sheet1.A3:Sheet1.B18 + gridWinState = get_state_as_dict(xGridWin) + self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A3:Sheet1.B11") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/data/autofilter/tdf160018_use_on_database_range.ods b/sc/qa/uitest/data/autofilter/tdf160018_use_on_database_range.ods new file mode 100644 index 000000000000..fa94a40fd0f4 Binary files /dev/null and b/sc/qa/uitest/data/autofilter/tdf160018_use_on_database_range.ods differ diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index cfd47b90b8e2..e1c637e18c56 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -1606,7 +1606,8 @@ void ScDocument::GetFilterEntries( if (!pDBData) return; // Do not extend DBArea automatically in case of Table Styles with Total row - if (!pDBData->HasTotals() || !pDBData->GetTableStyleInfo()) + if ((!pDBData->HasTotals() || !pDBData->GetTableStyleInfo()) + && (pDBData->GetName() == STR_DB_LOCAL_NONAME)) { pDBData->ExtendBackColorArea(*this); pDBData->ExtendDataArea(*this);
