summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-01-06 17:46:02 +0100
committerEike Rathke <erack@redhat.com>2017-01-06 18:31:06 +0000
commit4164596f43132e7769057170a228d74118ee63c6 (patch)
tree414da7f5adb726421bc1b7f4fb2ccd777c35082d /sc
parent03e5263dbedcf7650722f0b1bc18ce069e4ce244 (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 (cherry picked from commit 4fcbe16959c839bfacf745cfa554b234e639f794) Reviewed-on: https://gerrit.libreoffice.org/32792 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/formulacell.cxx4
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx23
-rw-r--r--sc/source/filter/xml/xmlimprt.cxx6
-rw-r--r--sc/source/filter/xml/xmlimprt.hxx2
4 files changed, 25 insertions, 10 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index a3f14b445c2d..bf6fc4ed20e4 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 d74f87147882..f1a81868992d 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -3407,12 +3407,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;