diff options
author | Eike Rathke <erack@redhat.com> | 2017-01-06 17:46:02 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-01-06 18:29:16 +0100 |
commit | 4fcbe16959c839bfacf745cfa554b234e639f794 (patch) | |
tree | 36033a312f8dfb829d2923a9bfcc200a3e3760f7 | |
parent | b36bf9f567f5b531f526dad6776c84e06203396f (diff) |
read single error constant formula as such, tdf#105024 related
... without creating a token so when writing again no leading '=' is prepended,
with which we can enable 5.2 to read such thing correctly, and when re-reading
in 5.3 it also doesn't lead to a "real" formula.
Change-Id: I26fbd20536436b49b781e2bbb5bba1dc6bafbb37
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 23 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.hxx | 2 |
4 files changed, 25 insertions, 10 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 9398159fa463..9ad3731398af 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1282,6 +1282,10 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr return ; } + // Error constant formula cell stays as is. + if (!pCode->GetLen() && pCode->GetCodeError() != FormulaError::NONE) + return; + // Compilation changes RPN count, remove and reinsert to FormulaTree if it // was in to update its count. bool bWasInFormulaTree = pDocument->IsInFormulaTree( this); diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index ddd85435d8f8..3b38ac44d3c4 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -1348,12 +1348,22 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos ) // temporary formula string as string tokens ScTokenArray *pCode = new ScTokenArray(); - OUString aFormulaNmsp = maFormula->second; - if( eGrammar != formula::FormulaGrammar::GRAM_EXTERNAL ) - aFormulaNmsp.clear(); - pCode->AssignXMLString( aText, aFormulaNmsp ); + // Check the special case of a single error constant without leading + // '=' and create an error formula cell without tokens. + FormulaError nError = GetScImport().GetFormulaErrorConstant(aText); + if (nError != 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() ); + } - rDoc.getDoc().IncXMLImportedFormulaCount( aText.getLength() ); ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, pCode, eGrammar, MM_NONE); SetFormulaCell(pNewCell); rDoc.setFormulaCell(rCellPos, pNewCell); @@ -1466,7 +1476,8 @@ bool ScXMLTableRowCellContext::IsPossibleErrorString() const return false; else if(mbNewValueType && mbErrorValue) return true; - return mbPossibleErrorCell || ( mbCheckWithCompilerForError && GetScImport().IsFormulaErrorConstant(*maStringValue) ); + return mbPossibleErrorCell || (mbCheckWithCompilerForError && + GetScImport().GetFormulaErrorConstant(*maStringValue) != FormulaError::NONE); } void ScXMLTableRowCellContext::EndElement() diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 6b8e31b30a25..c798e19d25d2 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -3393,12 +3393,12 @@ void ScXMLImport::ExtractFormulaNamespaceGrammar( reGrammar = eDefaultGrammar; } -bool ScXMLImport::IsFormulaErrorConstant( const OUString& rStr ) const +FormulaError ScXMLImport::GetFormulaErrorConstant( const OUString& rStr ) const { if (!mpComp) - return false; + return FormulaError::NONE; - return mpComp->GetErrorConstant(rStr) > FormulaError::NONE; + return mpComp->GetErrorConstant(rStr); } ScEditEngineDefaulter* ScXMLImport::GetEditEngine() diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx index 317fad71959d..28f9ae99d144 100644 --- a/sc/source/filter/xml/xmlimprt.hxx +++ b/sc/source/filter/xml/xmlimprt.hxx @@ -1223,7 +1223,7 @@ public: const OUString& rAttrValue, bool bRestrictToExternalNmsp = false ) const; - bool IsFormulaErrorConstant( const OUString& rStr ) const; + FormulaError GetFormulaErrorConstant( const OUString& rStr ) const; ScEditEngineDefaulter* GetEditEngine(); const ScXMLEditAttributeMap& GetEditAttributeMap() const; |