summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2021-09-01 15:35:11 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-09-02 16:47:14 +0200
commit3879accdfbee52b3bbecbe20fd1cf4d391189b70 (patch)
treeea95b25c41d7d6b4018cb8ec6add332a32b98d51 /svl
parent132603eb108a4e028ec0f41ada6defe777079ded (diff)
Resolves: tdf#144209 Handle General containing formats in RoundValueAsShown()
Calling SvNumberformat::GetThousandDivisorPrecision() for a "AA "General format resulted in 3000 as that was implemented for tdf#106253 without taking into account that ImpSvNumberformatInfo::nThousand may be abused under some conditions, which here is having FLAG_STANDARD_IN_FORMAT = 1000 as nThousand, multiplied by 3 gives 3000. Subtracted from the 0 precision gave -3000 decimals for which of course the new rounding produced 0 where it previously simply ignored the decimals and returned the original value. Change-Id: I66afaf1e2d8b2654d9f7cc8cfb66389357fb742d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121447 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit 71b003a12f8afdff42a25786ad0a12ddd6609d59) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121459 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zformat.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 255bfb09b5f7..bf95fd717cb1 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -5946,6 +5946,22 @@ OUString SvNumberformat::GetFormatStringForTimePrecision( int nPrecision ) const
return sString.makeStringAndClear();
}
+sal_uInt16 SvNumberformat::GetThousandDivisorPrecision( sal_uInt16 nIx ) const
+{
+ if (nIx >= 4)
+ return 0;
+
+ const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
+
+ if (rInfo.eScannedType != SvNumFormatType::NUMBER && rInfo.eScannedType != SvNumFormatType::CURRENCY)
+ return 0;
+
+ if (rInfo.nThousand == FLAG_STANDARD_IN_FORMAT)
+ return SvNumberFormatter::UNLIMITED_PRECISION;
+
+ return rInfo.nThousand * 3;
+}
+
const CharClass& SvNumberformat::rChrCls() const
{
return rScan.GetChrCls();