diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 05:03:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 05:03:24 +0000 |
commit | e3cf16e6fbf8d39cad8762f002b6db1d4f61ed36 (patch) | |
tree | 3c1753125149dcf36ba42a57f1574369e8524225 /svl | |
parent | Adding debian version 4:24.2.2-3. (diff) | |
download | libreoffice-e3cf16e6fbf8d39cad8762f002b6db1d4f61ed36.tar.xz libreoffice-e3cf16e6fbf8d39cad8762f002b6db1d4f61ed36.zip |
Merging upstream version 4:24.2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/qa/unit/svl.cxx | 20 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 4fa56f4bcc..969dfa166b 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -1993,6 +1993,26 @@ CPPUNIT_TEST_FIXTURE(Test, testLanguageNone) CPPUNIT_ASSERT_EQUAL(OUString("dd.mm.yyyy"), pFormat->GetMappedFormatstring(keywords, ldw)); } +CPPUNIT_TEST_FIXTURE(Test, testTdf160306) +{ + // Check some cases, where the output of ROUND and of number formatter differed + SvNumberFormatter aFormatter(m_xContext, LANGUAGE_ENGLISH_US); + sal_uInt32 format = aFormatter.GetEntryKey(u"0.00", LANGUAGE_ENGLISH_US); + CPPUNIT_ASSERT(format != NUMBERFORMAT_ENTRY_NOT_FOUND); + OUString output; + const Color* color; + aFormatter.GetOutputString(2697.0649999999996, format, output, &color); + // Without the fix in place, this would fail with + // - Expected: 2697.07 + // - Actual : 2697.06 + CPPUNIT_ASSERT_EQUAL(u"2697.07"_ustr, output); + aFormatter.GetOutputString(57.374999999999993, format, output, &color); + // Without the fix in place, this would fail with + // - Expected: 57.38 + // - Actual : 57.37 + CPPUNIT_ASSERT_EQUAL(u"57.38"_ustr, output); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index b5c8757ef2..313a598279 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -4407,6 +4407,8 @@ bool SvNumberformat::ImpGetNumberOutput(double fNumber, { nPrecExp = 0; } + // Make sure that Calc's ROUND and formatted output agree + fNumber = rtl_math_round(fNumber, rInfo.nCntPost, rtl_math_RoundingMode_Corrected); if (rInfo.nCntPost) // Decimal places { if ((rInfo.nCntPost + nPrecExp) > 15 && nPrecExp < 15) |