diff options
author | Balazs Varga <balazs.varga.extern@allotropia.de> | 2024-12-17 17:39:43 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2024-12-19 11:34:31 +0100 |
commit | 97bab05d04393bf4f04ff4df17aac8b6843f1a85 (patch) | |
tree | 4cd60436365e803afab4afeb6cf5b561b9f4efc0 | |
parent | a02f3eeffececfec5b43c4e5c4aa617fe4096176 (diff) |
tdf#157476 tdf#150861 - sc fix autoFilter is filtering incorrectly
caused by rounding problem with duplicated values.
We need to store the rounded values, based on the numberformat
precision, otherwise later can cause problems at removing the duplicated
values.
Regression from: f6b143a57d9bd8f5d7b29febcb4e01ee1eb2ff1d
Change-Id: I19f5248122ffca1e52adb96714df79dd9c64b23c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178683
Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Tested-by: Jenkins
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178737
-rw-r--r-- | sc/qa/uitest/autofilter2/tdf157476.py | 54 | ||||
-rw-r--r-- | sc/qa/uitest/data/autofilter/tdf157476.ods | bin | 0 -> 12365 bytes | |||
-rw-r--r-- | sc/source/core/data/documen4.cxx | 6 |
3 files changed, 55 insertions, 5 deletions
diff --git a/sc/qa/uitest/autofilter2/tdf157476.py b/sc/qa/uitest/autofilter2/tdf157476.py new file mode 100644 index 000000000000..557d9a73ab83 --- /dev/null +++ b/sc/qa/uitest/autofilter2/tdf157476.py @@ -0,0 +1,54 @@ +# -*- 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 +from libreoffice.calc.document import is_row_hidden + +class tdf157476(UITestCase): + + def test_tdf157476(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf157476.ods")) as doc: + + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + + xCheckListMenu = xFloatWindow.getChild("FilterDropDown") + xTreeList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(6, len(xTreeList.getChildren())) + + self.assertEqual("(empty)", get_state_as_dict(xTreeList.getChild('0'))['Text']) + self.assertEqual("0.32", get_state_as_dict(xTreeList.getChild('1'))['Text']) + self.assertEqual("0.65", get_state_as_dict(xTreeList.getChild('2'))['Text']) + self.assertEqual("1.33", get_state_as_dict(xTreeList.getChild('3'))['Text']) + self.assertEqual("2.00", get_state_as_dict(xTreeList.getChild('4'))['Text']) + self.assertEqual("3.00", get_state_as_dict(xTreeList.getChild('5'))['Text']) + + xFirstEntry = xTreeList.getChild("0") + xFirstEntry.executeAction("CLICK", tuple()) + xFirstEntry = xTreeList.getChild("2") + xFirstEntry.executeAction("CLICK", tuple()) + + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + 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.assertTrue(is_row_hidden(doc, 4)) + self.assertFalse(is_row_hidden(doc, 5)) + self.assertFalse(is_row_hidden(doc, 6)) + self.assertTrue(is_row_hidden(doc, 7)) + self.assertTrue(is_row_hidden(doc, 8)) + self.assertTrue(is_row_hidden(doc, 9)) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/data/autofilter/tdf157476.ods b/sc/qa/uitest/data/autofilter/tdf157476.ods Binary files differnew file mode 100644 index 000000000000..5b0a62a3fba2 --- /dev/null +++ b/sc/qa/uitest/data/autofilter/tdf157476.ods diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 1a2cdeeaf2f4..f86fedc4b472 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -687,11 +687,7 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScI if (nPrecision == static_cast<short>(SvNumberFormatter::UNLIMITED_PRECISION)) return fVal; } - double fRound = ::rtl::math::round( fVal, nPrecision ); - if ( ::rtl::math::approxEqual( fVal, fRound ) ) - return fVal; // rounding might introduce some error - else - return fRound; + return ::rtl::math::round( fVal, nPrecision ); } else return fVal; |