diff options
author | Laurent Balland <laurent.balland@mailo.fr> | 2023-05-16 09:24:55 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2023-05-26 18:20:26 +0200 |
commit | 6dd2ebbba23b20864d3cf74322540c628088375c (patch) | |
tree | a9ef5d80497da93f010cc026ea420be2aa1478c9 /svl | |
parent | 31f2de053d89fc782f98f74785643dbd6e19ba73 (diff) |
tdf#150028 Treat decimal separator after [SS]
Only decimal separator after S or SS was treated
This change adds [S] and [SS] to treat formats like
[SS].00
Update: correct export to XML
Add QA unit tests
Change-Id: I97ce4084d3caab2fcd18f1c70cd4221596290563
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151823
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/qa/unit/svl.cxx | 17 | ||||
-rw-r--r-- | svl/source/numbers/zforscan.cxx | 6 |
2 files changed, 23 insertions, 0 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 06d018f3b624..8f5070c934bb 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -1728,6 +1728,23 @@ void Test::testUserDefinedNumberFormats() sExpected = "1900-01-02 23:53.605"; checkPreviewString(aFormatter, sCode, M_PI, eLang, sExpected); } + { // tdf#150028 decimals of seconds fraction withtout truncate on overflow + sCode = "[SS]"; + sExpected = "271434"; + checkPreviewString(aFormatter, sCode, M_PI, eLang, sExpected); + // One decimal. + sCode = "[SS].0"; + sExpected = "271433.6"; + checkPreviewString(aFormatter, sCode, M_PI, eLang, sExpected); + // Two decimals. + sCode = "[SS].00"; + sExpected = "271433.61"; + checkPreviewString(aFormatter, sCode, M_PI, eLang, sExpected); + // Three decimals. + sCode = "[SS].000"; + sExpected = "271433.605"; + checkPreviewString(aFormatter, sCode, M_PI, eLang, sExpected); + } { // tdf#33689 use English NfKeywords in non-English language eLang = LANGUAGE_DUTCH; sExpected = "Dutch: 1900/01/02 03:23:53"; diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx index 10ff6a591b35..537c19415ff7 100644 --- a/svl/source/numbers/zforscan.cxx +++ b/svl/source/numbers/zforscan.cxx @@ -1467,6 +1467,11 @@ sal_Int32 ImpSvNumberformatScan::ScanType() } else if (pLoc->getTime100SecSep() == sStrArray[i]) bDecSep = true; + else if ( sStrArray[i][0] == ']' && i < nStringsCnt - 1 && pLoc->getTime100SecSep() == sStrArray[i+1] ) + { + bDecSep = true; + i++; + } } eNewType = SvNumFormatType::UNDEFINED; break; @@ -2592,6 +2597,7 @@ sal_Int32 ImpSvNumberformatScan::FinalScan( OUString& rString ) bDecSep = true; nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; OUString& rStr = sStrArray[i]; + nCounter++; i++; while (i < nStringsCnt && |