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 /sc | |
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 'sc')
-rw-r--r-- | sc/qa/unit/data/ods/tdf156449-Blank-In-Exponent.ods | bin | 0 -> 9458 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export_test4.cxx | 31 |
2 files changed, 31 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/tdf156449-Blank-In-Exponent.ods b/sc/qa/unit/data/ods/tdf156449-Blank-In-Exponent.ods Binary files differnew file mode 100644 index 000000000000..73647881e73d --- /dev/null +++ b/sc/qa/unit/data/ods/tdf156449-Blank-In-Exponent.ods diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index 2b4141425136..390783131733 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -1468,6 +1468,37 @@ void lcl_TestNumberFormat(ScDocument& rDoc, const OUString& rFormatStrOK) CPPUNIT_ASSERT_EQUAL(rFormatStrOK, rFormatStr); } + +void lcl_SetNumberFormat(ScDocument& rDoc, const OUString& rFormat) +{ + sal_Int32 nCheckPos; + SvNumFormatType nType; + sal_uInt32 nFormat; + OUString aNewFormat = rFormat; + SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); + if (pFormatter) + { + pFormatter->PutEntry(aNewFormat, nCheckPos, nType, nFormat); + rDoc.SetNumberFormat(ScAddress(0, 0, 0), nFormat); + } +} +} + +CPPUNIT_TEST_FIXTURE(ScExportTest4, testBlankInExponent) +{ + createScDoc("ods/tdf156449-Blank-In-Exponent.ods"); + + // save to ODS and reload + saveAndReload("calc8"); + lcl_TestNumberFormat(*getScDoc(), "0.00E+?0"); + lcl_SetNumberFormat(*getScDoc(), "0.00E+??"); + // at least one '0' in exponent + saveAndReload("calc8"); + lcl_TestNumberFormat(*getScDoc(), "0.00E+?0"); + + // save to XLSX and reload + saveAndReload("Calc Office Open XML"); + lcl_TestNumberFormat(*getScDoc(), "0.00E+?0"); } CPPUNIT_TEST_FIXTURE(ScExportTest4, testSecondsWithoutTruncateAndDecimals) |