sc/qa/uitest/autofilter2/tdf163395.py      |   40 +++++++++++++++++++++++++++++
 sc/qa/uitest/data/autofilter/tdf163395.ods |binary
 sc/source/ui/dbgui/filtdlg.cxx             |    6 +++-
 3 files changed, 45 insertions(+), 1 deletion(-)
New commits:
commit aee655940b5a19d5f54750a8c40eded10672622f
Author:     Balazs Varga <balazs.varga.ext...@allotropia.de>
AuthorDate: Tue Dec 17 20:50:31 2024 +0100
Commit:     Balazs Varga <balazs.varga.ext...@allotropia.de>
CommitDate: Wed Dec 18 17:52:19 2024 +0100

    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 <gabor.kelemen.ext...@allotropia.de>
    Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de>

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 9735b15c711e..0470d00e9291 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();

Reply via email to