From 75d963bc7bb87429f304d29138c27178880c039a Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Fri, 6 Jan 2017 18:28:42 +0100 Subject: recognize the broken "Err:xxx" written by 5.2 and earlier, tdf#105024 related ... and handle same as "#ERRxxx!" if present. Change-Id: I1ebb31d628b080c52b450a8fe624c20e9e1188b7 --- sc/source/filter/xml/xmlcelli.cxx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'sc') diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 3b38ac44d3c4..8fd7edae9d15 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -1357,11 +1357,22 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos ) } else { - OUString aFormulaNmsp = maFormula->second; - if( eGrammar != formula::FormulaGrammar::GRAM_EXTERNAL ) - aFormulaNmsp.clear(); - pCode->AssignXMLString( aText, aFormulaNmsp ); - rDoc.getDoc().IncXMLImportedFormulaCount( aText.getLength() ); + // 5.2 and earlier wrote broken "Err:xxx" as formula to designate + // an error formula cell. + if (aText.startsWithIgnoreAsciiCase("Err:") && aText.getLength() <= 9 && + ((nError = + GetScImport().GetFormulaErrorConstant( "#ERR" + aText.copy(4) + "!")) != FormulaError::NONE)) + { + pCode->SetCodeError(nError); + } + else + { + OUString aFormulaNmsp = maFormula->second; + if( eGrammar != formula::FormulaGrammar::GRAM_EXTERNAL ) + aFormulaNmsp.clear(); + pCode->AssignXMLString( aText, aFormulaNmsp ); + rDoc.getDoc().IncXMLImportedFormulaCount( aText.getLength() ); + } } ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, pCode, eGrammar, MM_NONE); -- cgit