summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2021-09-01 15:35:11 +0200
committerEike Rathke <erack@redhat.com>2021-09-01 22:53:55 +0200
commit71b003a12f8afdff42a25786ad0a12ddd6609d59 (patch)
treea989b5b02a697f623e1dd8f63cf2211a09e00212 /svl
parentf560a3a296871084801ced75fae20fb5f1b5d7ce (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
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 6b68e79f1517..22a377a6cc69 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -5947,6 +5947,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();