sc/source/filter/oox/numberformatsbuffer.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
New commits: commit bda60888cdae9922ea933190e391628ba2e3e3b9 Author: Eike Rathke <er...@redhat.com> AuthorDate: Wed May 29 19:37:22 2024 +0200 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Sat Jun 1 06:03:49 2024 +0200 Related: tdf#161301 strip single stray leading "[$]" garbage from formatCode Which is the case if the actual format code is in an x16r2:formatCode16 attribute that isn't handled yet. Change-Id: Id35e774f8ccb167af2a46a8cc0f7611da76d708c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168232 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins (cherry picked from commit b3f6d4f0d380b26fb88ff586a09b4525ed6585b9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168311 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx index 5fa701b3f19c..11807e11e7eb 100644 --- a/sc/source/filter/oox/numberformatsbuffer.cxx +++ b/sc/source/filter/oox/numberformatsbuffer.cxx @@ -1933,6 +1933,16 @@ void NumberFormat::setFormatCode( std::u16string_view aFmtCode ) } // tdf#81939 preserve other escape characters nPosEscape = lclPosToken( aFmtCode, u";", nPosEscape ); // skip to next format } + + // tdf#161301 There may be a lone single stray leading "[$]" garbage, strip it. + if (sFormat.getLength() >= 3 && sFormat[0] == '[' && sFormat[1] == '$' && sFormat[2] == ']') + { + SAL_WARN("sc.filter", + "NumberFormat::setFormatCode: stripping leading [$] maybe due to x16r2:formatCode16 also being present: " + << sFormat.toString()); + sFormat.remove(0, 3); + } + maModel.maFmtCode = sFormat.makeStringAndClear(); } @@ -2005,6 +2015,12 @@ NumberFormatRef NumberFormatsBuffer::importNumFmt( const AttributeList& rAttribs { sal_Int32 nNumFmtId = rAttribs.getInteger( XML_numFmtId, -1 ); OUString aFmtCode = rAttribs.getXString( XML_formatCode, OUString() ); + /* TODO: there may be a x16r2:formatCode16 attribute that would take + * precedence over the formatCode attribute, see + * https://learn.microsoft.com/en-us/openspecs/office_standards/ms-xlsx/8c82391e-f128-499a-80a1-734b8504f60e + * The number format scanner would have to handle the + * [$<currency string>-<culture info>[,<calendar type and numeral system>]] + * part.*/ return createNumFmt( nNumFmtId, aFmtCode ); }