From 7a8331eb7f4e782cd9febc9923b99d4c02cd2945 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Wed, 4 May 2016 19:49:18 +0200 Subject: fix export crash test due to assert hit, tdf#61996 follow-up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fallout of 88a79589843efc24f8af99bd511a1fff0f7bebef Cause was a crappy number format that now is parsed differently and results in UNDEFINED type, hence XMLTokenEnum was XML_TOKEN_INVALID which later made assert(XML_TOKEN_INVALID < eToken) in xmloff/source/core/xmltoken.cxx GetXMLToken() bail out. Handle that during export and map to number-style. An example of fdo82933-1.ods that triggered this is [>0]" $"\"#"٬##0٫"00"٬"\";[<0]" $("\"#"٬##0٫"00);" $-"\"#"٬"\";@ Already import massively complained about xmloff/source/style/xmlnumfi.cxx:1710: invalid number format but not only for this format, the document contains a pile of crappy stuff. Possibly number format code scanning could be improved to type that NUMBER instead, which it could be as only the #...00 and #...00) are actually digit related, everything else are string constants. However, that likely was not the intention of the document author.. Change-Id: I7c2b202b0b87e1a7fa7a9f56862a6bb7618ad9ff --- xmloff/source/style/xmlnumfe.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'xmloff') diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index e449133d5c75..9494439bd69b 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -1008,7 +1008,14 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt XMLTokenEnum eType = XML_TOKEN_INVALID; switch ( nFmtType ) { - // type is 0 if a format contains no recognized elements + // Type UNDEFINED likely is a crappy format string for that we could + // not decide on any format type (and maybe could try harder?), but the + // resulting XMLTokenEnum should be something valid, so make that + // number-style. + case css::util::NumberFormat::UNDEFINED: + SAL_WARN("xmloff.style","UNDEFINED number format: '" << rFormat.GetFormatstring() << "'"); + // fallthru + // Type is 0 if a format contains no recognized elements // (like text only) - this is handled as a number-style. case 0: case css::util::NumberFormat::EMPTY: -- cgit