svl/qa/unit/svl.cxx | 5 +++++ svl/source/numbers/zformat.cxx | 6 ++++++ 2 files changed, 11 insertions(+)
New commits: commit bd2ffb6f33e549483b41f6235ba64fa735205d38 Author: Laurent Balland <laurent.ball...@mailo.fr> AuthorDate: Sat Jun 8 17:14:31 2024 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Thu Jun 13 15:34:33 2024 +0200 tdf#159930 Treat special case with no integer digit Number format with no integer digit, such as "+.##;-.##" was placing string with the decimal separator. This change insert string at the begining of the number string as expected. This format code is saved as "+#.##;-#.##" in ODF, but display is the same; so no change is made on this side. Add unit test for this format Change-Id: I74fbe0e9a5303672ac7927d37922c06a762feba6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168577 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 389195ec1728..3a8f5f51b43e 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -1823,6 +1823,11 @@ void Test::testUserDefinedNumberFormats() sExpected = "Value= 12,345.00"; checkPreviewString(aFormatter, sCode, 12345, LANGUAGE_ENGLISH_US, sExpected); } + { // tdf#159930 no digit in integer part + sCode = "+.000;-.000"; + sExpected = "+3.142"; // without the patch is would display "3+.142" + checkPreviewString(aFormatter, sCode, M_PI, LANGUAGE_ENGLISH_US, sExpected); + } } void Test::testNfEnglishKeywordsIntegrity() diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 855acc179d30..4975738df5c4 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -4682,6 +4682,12 @@ bool SvNumberformat::ImpNumberFillWithThousands( const NativeNumberWrapper& rNat aGrouping.reset(); [[fallthrough]]; case NF_SYMBOLTYPE_STRING: + if ( rInfo.nTypeArray[j] == NF_SYMBOLTYPE_STRING && nDigCnt == 0 ) + { + // tdf#159930 no integer in format ".###" + k = 0; // insert string at the beginning + } + [[fallthrough]]; case NF_SYMBOLTYPE_CURRENCY: case NF_SYMBOLTYPE_PERCENT: if ( rInfo.nTypeArray[j] != NF_SYMBOLTYPE_DECSEP || bAddDecSep )