summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorLaurent Godard <lgodard.libre@laposte.net>2011-12-02 12:28:40 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-12-03 20:15:02 +0100
commit62ec7f9e824ed1c17f01beaf8f4cec3b76b3aae9 (patch)
treef667799cecdcbf93a315099f0e5bd8a03a2db719 /sc/source
parent3b0d01a8cb6f9230db400c92a59bf805bcd5bc05 (diff)
cells creation : do not use uno calls at loading time
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx66
1 files changed, 58 insertions, 8 deletions
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index e16a262756bf..8fd3de4ef5c6 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1078,16 +1078,66 @@ void ScXMLTableRowCellContext::EndElement()
if (!bIsMatrix)
{
LockSolarMutex();
- ScCellObj* pCellObj =
- static_cast<ScCellObj*>(ScCellRangesBase::getImplementation(
- xCell));
- if (pCellObj)
+
+ ScAddress aScAddress;
+ ScUnoConversion::FillScAddress( aScAddress, aCellPos );
+
+ ScDocument* pDoc = rXMLImport.GetDocument();
+
+ rtl::OUString aText = pOUFormula->first;
+ rtl::OUString aFormulaNmsp = pOUFormula->second;
+
+ ::boost::scoped_ptr<ScExternalRefManager::ApiGuard> pExtRefGuard;
+ pExtRefGuard.reset(new ScExternalRefManager::ApiGuard(pDoc));
+
+ ScBaseCell* pNewCell = NULL;
+
+ if ( !aText.isEmpty() )
{
- pCellObj->SetFormulaWithGrammar( pOUFormula->first, pOUFormula->second, eGrammar);
- if (bFormulaTextResult && pOUTextValue && pOUTextValue->getLength())
- pCellObj->SetFormulaResultString( *pOUTextValue);
+ if ( aText[0] == '=' && aText.getLength() > 1 )
+ {
+ // temporary formula string as string tokens
+ ScTokenArray* pCode = new ScTokenArray;
+ pCode->AddStringXML( aText );
+ if( (eGrammar == formula::FormulaGrammar::GRAM_EXTERNAL) && (aFormulaNmsp.getLength() > 0) )
+ pCode->AddStringXML( aFormulaNmsp );
+
+ pDoc->IncXMLImportedFormulaCount( aText.getLength() );
+ pNewCell = new ScFormulaCell( pDoc, aScAddress, pCode, eGrammar, MM_NONE );
+ delete pCode;
+ }
+ else if ( aText[0] == '\'' )
+ {
+ // for bEnglish, "'" at the beginning is always interpreted as text
+ // marker and stripped
+ pNewCell = ScBaseCell::CreateTextCell( aText.copy( 1 ), pDoc );
+ }
else
- pCellObj->SetFormulaResultDouble( fValue);
+ {
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ sal_uInt32 nEnglish = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
+ double fVal;
+ if ( pFormatter->IsNumberFormat( aText, nEnglish, fVal ) )
+ {
+ pNewCell = new ScValueCell( fVal );
+ }
+ else
+ pNewCell = ScBaseCell::CreateTextCell( aText, pDoc );
+ // das (englische) Zahlformat wird nicht gesetzt
+ //! passendes lokales Format suchen und setzen???
+ }
+
+ if (pNewCell)
+ pDoc->PutCell( aScAddress, pNewCell );
+
+ ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( aScAddress );
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ {
+ if (bFormulaTextResult && pOUTextValue && pOUTextValue->getLength())
+ static_cast<ScFormulaCell*>(pCell)->SetHybridString( *pOUTextValue );
+ else
+ static_cast<ScFormulaCell*>(pCell)->SetHybridDouble( fValue );
+ }
}
}
else