summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/core/data/formulacell.cxx7
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx45
2 files changed, 16 insertions, 36 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 400671830c8f..5750aa3409e4 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1308,10 +1308,11 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr
OUStringBuffer aShouldBeBuf;
aBackComp.CreateStringFromTokenArray( aShouldBeBuf );
- assert( aFormula[0] == '=' );
+ // The initial '=' is optional in ODFF.
+ const sal_Int32 nLeadingEqual = (aFormula.getLength() > 0 && aFormula[0] == '=') ? 1 : 0;
OUString aShouldBe = aShouldBeBuf.makeStringAndClear();
- if( aFormula.getLength() == aShouldBe.getLength() + 1 &&
- aFormula.match( aShouldBe, 1 ) ) // initial '='
+ if (aFormula.getLength() == aShouldBe.getLength() + nLeadingEqual &&
+ aFormula.match( aShouldBe, nLeadingEqual))
{
// Put them in the same formula group.
ScFormulaCellGroupRef xGroup = pPreviousCell->GetCellGroup();
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index abc69871804e..f224852edbc6 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1360,42 +1360,21 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos )
if ( !aText.isEmpty() )
{
- if ( aText[0] == '=' && aText.getLength() > 1 )
- {
- // temporary formula string as string tokens
- ScTokenArray *pCode = new ScTokenArray();
+ // 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 );
+ 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);
- SetFormulaCell(pNewCell);
- rDoc.setFormulaCell(rCellPos, pNewCell);
+ rDoc.getDoc().IncXMLImportedFormulaCount( aText.getLength() );
+ ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, pCode, eGrammar, MM_NONE);
+ SetFormulaCell(pNewCell);
+ rDoc.setFormulaCell(rCellPos, pNewCell);
- // Re-calculate to get number format only when style is not set.
- pNewCell->SetNeedNumberFormat(!mbHasStyle);
- }
- else if ( aText[0] == '\'' && aText.getLength() > 1 )
- {
- // for bEnglish, "'" at the beginning is always interpreted as text
- // marker and stripped
- rDoc.setStringCell(rCellPos, aText.copy(1));
- }
- else
- {
- SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
- sal_uInt32 nEnglish = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
- double fVal;
- if ( pFormatter->IsNumberFormat( aText, nEnglish, fVal ) )
- rDoc.setNumericCell(rCellPos, fVal);
- //the (english) number format will not be set
- //search matching local format and apply it
- else
- rDoc.setStringCell(rCellPos, aText);
- }
+ // Re-calculate to get number format only when style is not set.
+ pNewCell->SetNeedNumberFormat(!mbHasStyle);
}
}