From 89764e6a51b2c43992491a28870c69ee0e98ee9a Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Tue, 17 Dec 2024 20:50:31 +0100 Subject: tdf#163395 tdf#153057 - sc fix standard filter problem with formatted values ScQueryEntry::ByValue was removed unnecessarily in the original patch, but it is necessary for filtering number values correctly. Regression from commit: 1f755525189884e4b2824889a6b9dea8933402db Change-Id: Ib013d971ad0b0809fc55949a6a2d9bf02418b516 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178690 Tested-by: Jenkins Tested-by: Gabor Kelemen Reviewed-by: Balazs Varga Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178738 (cherry picked from commit 1250c1e0f3b424cf18c378f3b21a14f6e531cbf7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178794 --- sc/qa/uitest/autofilter2/tdf163395.py | 40 +++++++++++++++++++++++++++++ sc/qa/uitest/data/autofilter/tdf163395.ods | Bin 0 -> 12708 bytes sc/source/ui/dbgui/filtdlg.cxx | 6 ++++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 sc/qa/uitest/autofilter2/tdf163395.py create mode 100644 sc/qa/uitest/data/autofilter/tdf163395.ods (limited to 'sc') diff --git a/sc/qa/uitest/autofilter2/tdf163395.py b/sc/qa/uitest/autofilter2/tdf163395.py new file mode 100644 index 000000000000..fbf7aadef925 --- /dev/null +++ b/sc/qa/uitest/autofilter2/tdf163395.py @@ -0,0 +1,40 @@ +# -*- 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.common import get_url_for_data_file, select_by_text +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import is_row_hidden + +class tdf163395(UITestCase): + + def test_tdf163395(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf163395.ods")) as doc: + + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B7"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "Percent"/ Choose condition ">="/Enter value "23%"/Press OK button + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + select_by_text(xfield1, "Percent") + select_by_text(xcond1, ">=") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"23%"})) + + self.assertFalse(is_row_hidden(doc, 0)) + self.assertFalse(is_row_hidden(doc, 1)) + self.assertFalse(is_row_hidden(doc, 2)) + self.assertFalse(is_row_hidden(doc, 3)) + self.assertFalse(is_row_hidden(doc, 4)) + self.assertTrue(is_row_hidden(doc, 5)) + self.assertFalse(is_row_hidden(doc, 6)) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/data/autofilter/tdf163395.ods b/sc/qa/uitest/data/autofilter/tdf163395.ods new file mode 100644 index 000000000000..5d9a381057de Binary files /dev/null and b/sc/qa/uitest/data/autofilter/tdf163395.ods differ diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx index e238ff61a2ed..8e9995b07385 100644 --- a/sc/source/ui/dbgui/filtdlg.cxx +++ b/sc/source/ui/dbgui/filtdlg.cxx @@ -1304,7 +1304,11 @@ IMPL_LINK( ScFilterDlg, ValModifyHdl, weld::ComboBox&, rEd, void ) { rItem.maString = pDoc->GetSharedStringPool().intern(aStrVal); rItem.mfVal = 0.0; - rItem.meType = ScQueryEntry::ByString; + + sal_uInt32 nIndex = 0; + bool bNumber = pDoc->GetFormatTable()->IsNumberFormat( + rItem.maString.getString(), nIndex, rItem.mfVal); + rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString; } const sal_Int32 nField = pLbField->get_active(); -- cgit