sc/qa/uitest/autofilter2/tdf151152.py | 52 ++++++++++++++++++++++++++++++++++ sc/source/ui/view/gridwin.cxx | 14 +++++++-- 2 files changed, 63 insertions(+), 3 deletions(-)
New commits: commit 6faac931869ad06ce38216148da2450652c1091b Author: Tünde Tóth <toth.tu...@nisz.hu> AuthorDate: Wed Dec 7 13:34:37 2022 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Dec 19 15:14:40 2022 +0000 tdf#151152 sc filter: fix string entry checking When a column was filtered for values that included 0, the all string entries were always checked in the Autofilter dropdown (because their conversion to number, i.e. value 0 was used to check their existence in the filtered values instead of their string value). Regression from commit f6b143a57d9bd8f5d7b29febcb4e01ee1eb2ff1d "tdf#142910 sc filter: fix "greater than" or "smaller than" etc". Change-Id: Ib659aba9d6f3d6bc3557547b1a27963f51e3eca3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143777 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 2298087db28ee1b4251cac6e12c1d4806b395a1e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144480 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/uitest/autofilter2/tdf151152.py b/sc/qa/uitest/autofilter2/tdf151152.py new file mode 100644 index 000000000000..6971096e9844 --- /dev/null +++ b/sc/qa/uitest/autofilter2/tdf151152.py @@ -0,0 +1,52 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 151152 - Autofilter checkbox status is wrong when I deselect one item, click OK, then click on the dropdown again (2nd case) + +class tdf151152(UITestCase): + def test_tdf151152(self): + with self.ui_test.create_doc_in_start_center("calc"): + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "A2", "0") + enter_text_to_cell(gridwin, "A3", "a") + enter_text_to_cell(gridwin, "A4", "b") + + 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") + xList = xCheckListMenu.getChild("check_list_box") + xEntry = xList.getChild("1") + xEntry.executeAction("CLICK", tuple()) + + xOkButton = xFloatWindow.getChild("ok") + xOkButton.executeAction("CLICK", tuple()) + + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("FilterDropDown") + xList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(3, len(xList.getChildren())) + self.assertEqual('true', get_state_as_dict(xList.getChild('0'))['IsChecked']) + self.assertEqual('false', get_state_as_dict(xList.getChild('1'))['IsChecked']) + self.assertEqual('true', get_state_as_dict(xList.getChild('2'))['IsChecked']) + xCloseBtn = xFloatWindow.getChild("cancel") + xCloseBtn.executeAction("CLICK", tuple()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 8a7dd8b82bdc..0c471e4c53e3 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -963,10 +963,18 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow) if (!aSelectedValue.empty() || !aSelectedString.empty()) { - if (aDoubleVal == aRDoubleVal) - bSelected = aSelectedValue.count(aDoubleVal) > 0 || aSelectedString.count(aStringVal) > 0; + if (rEntry.GetStringType() == ScTypedStrData::Value) + { + if (aDoubleVal == aRDoubleVal) + bSelected = aSelectedValue.count(aDoubleVal) > 0 + || aSelectedString.count(aStringVal) > 0; + else + bSelected = aSelectedValue.count(aDoubleVal) > 0 + || aSelectedValue.count(aRDoubleVal) > 0 + || aSelectedString.count(aStringVal) > 0; + } else - bSelected = aSelectedValue.count(aDoubleVal) > 0 || aSelectedValue.count(aRDoubleVal) > 0 || aSelectedString.count(aStringVal) > 0; + bSelected = aSelectedString.count(aStringVal) > 0; } if ( rEntry.IsDate() )