diff options
author | Laurent Balland <laurent.balland@mailo.fr> | 2023-07-26 17:58:00 +0200 |
---|---|---|
committer | Laurent Balland <laurent.balland@mailo.fr> | 2023-11-01 11:43:54 +0100 |
commit | 443027cd71aef3eb45bbf3631869ea63457f2c81 (patch) | |
tree | 4c8bcf044493e24de7077f48f0f77036fdd35a7a /svl | |
parent | 5d7d7eb55a3833ff12c61b1a03a296bb0bf4e640 (diff) |
tdf#156449 Preserve '0' or '?' in exponent
Exponent in scientific number may use '?' as blank like in format "0.00E+?0"
This change:
- adds interpreatation of '0' and '?' in exponent
- adds "blank-exponent-digits" attribute to scientific number for import
and export to ODF
- prevents using exponent with only '?'. There must be at least one '0'
in exponent
- adds QA test of such format and test import/export/import to ODF and OOXML
- corrects one basic test
Change-Id: If52edc632a161f842270bb2fd77af535e2b978d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154986
Tested-by: Jenkins
Reviewed-by: Laurent Balland <laurent.balland@mailo.fr>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/qa/unit/svl.cxx | 8 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 8 |
2 files changed, 13 insertions, 3 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index f43cfb9e437e..4fa56f4bccd4 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -1743,6 +1743,14 @@ void Test::testUserDefinedNumberFormats() sExpected = "271433.605"; checkPreviewString(aFormatter, sCode, M_PI, eLang, sExpected); } + { // tdf#156449 Use '?' in exponent of scientific number + sCode = "0.00E+?0"; + sExpected = "3.14E+ 0"; // before change it was "3.14E+00" + checkPreviewString(aFormatter, sCode, M_PI, eLang, sExpected); + // There should be at least one '0' in exponent + sCode = "0.00E+??"; + 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/zformat.cxx b/svl/source/numbers/zformat.cxx index 174ab1c15667..b5c8757ef2e6 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -2752,11 +2752,10 @@ bool SvNumberformat::ImpGetScientificOutput(double fNumber, } sal_uInt16 j = nCnt-1; // Last symbol - sal_Int32 k; // Position in ExpStr + sal_Int32 k = ExpStr.getLength() - 1; // Position in ExpStr sal_Int32 nZeros = 0; // Erase leading zeros - bRes |= ImpNumberFill(ExpStr, fNumber, k, j, nIx, NF_SYMBOLTYPE_EXP); - + // erase all leading zeros except last one while (nZeros < k && ExpStr[nZeros] == '0') { ++nZeros; @@ -2766,6 +2765,9 @@ bool SvNumberformat::ImpGetScientificOutput(double fNumber, ExpStr.remove( 0, nZeros); } + // restore leading zeros or blanks according to format '0' or '?' tdf#156449 + bRes |= ImpNumberFill(ExpStr, fNumber, k, j, nIx, NF_SYMBOLTYPE_EXP); + bool bCont = true; if (rInfo.nTypeArray[j] == NF_SYMBOLTYPE_EXP) |