sc/qa/uitest/autofilter2/tdf161457.py | 42 +++++++++++++++++++++++++++++ sc/qa/uitest/data/autofilter/tdf161457.ods |binary sc/source/core/tool/typedstrdata.cxx | 8 ++--- 3 files changed, 46 insertions(+), 4 deletions(-)
New commits: commit db153afbac7acc1ae46f78beef4221e9aad07305 Author: Balazs Varga <balazs.varga.ext...@allotropia.de> AuthorDate: Sun Jun 9 19:00:53 2024 +0200 Commit: Balazs Varga <balazs.varga.ext...@allotropia.de> CommitDate: Mon Jun 10 23:42:24 2024 +0200 tdf#161457 - Fix autofilter result is wrong when cells contain formatted rounded values. Filtered formatted values were not sorted with the rounded values but with the original values and the duplicated values caused wrong filter results. Regression from commit: 2d1df9f3dccc10f13b8585ad18afce1542ebc4d1 (tdf#117276 sc: Show hidden filter elements as inactive elements) Change-Id: I7540ba5fa98e6bbe0b014448bf2449432261d542 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168592 Tested-by: Jenkins Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de> diff --git a/sc/qa/uitest/autofilter2/tdf161457.py b/sc/qa/uitest/autofilter2/tdf161457.py new file mode 100644 index 000000000000..400f4df9b584 --- /dev/null +++ b/sc/qa/uitest/autofilter2/tdf161457.py @@ -0,0 +1,42 @@ +# -*- 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_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf161457(UITestCase): + + def test_tdf161457(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf161457.ods")) as calc_doc: + + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWin = xCalcDoc.getChild("grid_window") + + # Click the autofilter dropdown in column B + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("FilterDropDown") + xTreeList = xCheckListMenu.getChild("check_list_box") + + self.assertEqual(2, len(xTreeList.getChildren())) + + xEntry1 = xTreeList.getChild(0) + self.assertEqual("1.00", get_state_as_dict(xEntry1)['Text']) + self.assertEqual("true", get_state_as_dict(xEntry1)['IsChecked']) + self.assertEqual("false", get_state_as_dict(xEntry1)['IsSemiTransparent']) + + xEntry2 = xTreeList.getChild(1) + self.assertEqual("5.00", get_state_as_dict(xEntry2)['Text']) + self.assertEqual("true", get_state_as_dict(xEntry2)['IsChecked']) + # Without the fix in place, this test would have failed with + # AssertionError: 'true' != 'false' + self.assertEqual("false", get_state_as_dict(xEntry2)['IsSemiTransparent']) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/autofilter2/tdf46184.py b/sc/qa/uitest/autofilter2/tdf46184.py old mode 100755 new mode 100644 diff --git a/sc/qa/uitest/data/autofilter/tdf161457.ods b/sc/qa/uitest/data/autofilter/tdf161457.ods new file mode 100644 index 000000000000..6580b1d7daf6 Binary files /dev/null and b/sc/qa/uitest/data/autofilter/tdf161457.ods differ diff --git a/sc/source/core/tool/typedstrdata.cxx b/sc/source/core/tool/typedstrdata.cxx index 4e3f862ae3a4..14ea33ab9221 100644 --- a/sc/source/core/tool/typedstrdata.cxx +++ b/sc/source/core/tool/typedstrdata.cxx @@ -26,7 +26,7 @@ bool ScTypedStrData::LessCaseSensitive::operator() (const ScTypedStrData& left, if (left.meStrType == Value) { - if (left.mfValue == right.mfValue) + if (left.mfRoundedValue == right.mfRoundedValue) return left.mbIsHiddenByFilter < right.mbIsHiddenByFilter; return left.mfValue < right.mfValue; } @@ -50,7 +50,7 @@ bool ScTypedStrData::LessSortCaseSensitive::operator() (const ScTypedStrData& le if (left.meStrType == Value) { - if (left.mfValue == right.mfValue) + if (left.mfRoundedValue == right.mfRoundedValue) return left.mbIsHiddenByFilter < right.mbIsHiddenByFilter; return left.mfValue < right.mfValue; } @@ -73,7 +73,7 @@ bool ScTypedStrData::LessCaseInsensitive::operator() (const ScTypedStrData& left if (left.meStrType == Value) { - if (left.mfValue == right.mfValue) + if (left.mfRoundedValue == right.mfRoundedValue) return left.mbIsHiddenByFilter < right.mbIsHiddenByFilter; return left.mfValue < right.mfValue; } @@ -97,7 +97,7 @@ bool ScTypedStrData::LessSortCaseInsensitive::operator() (const ScTypedStrData& if (left.meStrType == Value) { - if (left.mfValue == right.mfValue) + if (left.mfRoundedValue == right.mfRoundedValue) return left.mbIsHiddenByFilter < right.mbIsHiddenByFilter; return left.mfValue < right.mfValue; }