From 38df6bbbbe23444732b07e438887b6863a8ad1e8 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 21 Mar 2013 12:50:52 -0400 Subject: More on reducing use of ScDocument::PutCell(). Change-Id: Ibcbb8690c96c176a31563e7b833fa66412888cb6 --- sc/source/filter/lotus/op.cxx | 31 ++++++++++++++----------------- sc/source/filter/qpro/qpro.cxx | 11 ++++++----- sc/source/filter/starcalc/scflt.cxx | 3 ++- 3 files changed, 22 insertions(+), 23 deletions(-) (limited to 'sc') diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx index 8668c9e17612..5ed25643f682 100644 --- a/sc/source/filter/lotus/op.cxx +++ b/sc/source/filter/lotus/op.cxx @@ -93,8 +93,8 @@ void OP_Integer( SvStream& r, sal_uInt16 /*n*/ ) if (ValidColRow( static_cast(nCol), nRow)) { - ScValueCell* pZelle = new ScValueCell( ( double ) nValue ); - pDoc->PutCell( static_cast (nCol), static_cast (nRow), nTab, pZelle, true ); + pDoc->EnsureTable(nTab); + pDoc->SetValue(ScAddress(nCol,nRow,nTab), static_cast(nValue)); // 0 Stellen nach'm Komma! SetFormat( static_cast (nCol), static_cast (nRow), nTab, nFormat, 0 ); @@ -114,8 +114,8 @@ void OP_Number( SvStream& r, sal_uInt16 /*n*/ ) if (ValidColRow( static_cast(nCol), nRow)) { fValue = ::rtl::math::round( fValue, 15 ); - ScValueCell* pZelle = new ScValueCell( fValue ); - pDoc->PutCell( static_cast (nCol), static_cast (nRow), nTab, pZelle, true ); + pDoc->EnsureTable(nTab); + pDoc->SetValue(ScAddress(nCol,nRow,nTab), fValue); SetFormat( static_cast (nCol), static_cast (nRow), nTab, nFormat, nDezFloat ); } @@ -169,11 +169,10 @@ void OP_Formula( SvStream& r, sal_uInt16 /*n*/ ) if (ValidColRow( static_cast(nCol), nRow)) { - ScFormulaCell* pZelle = new ScFormulaCell( pLotusRoot->pDoc, aAddress, pErg ); - - pZelle->AddRecalcMode( RECALCMODE_ONLOAD_ONCE ); - - pDoc->PutCell( static_cast (nCol), static_cast (nRow), nTab, pZelle, true ); + ScFormulaCell* pCell = new ScFormulaCell( pLotusRoot->pDoc, aAddress, pErg ); + pCell->AddRecalcMode( RECALCMODE_ONLOAD_ONCE ); + pDoc->EnsureTable(nTab); + pDoc->SetFormulaCell(ScAddress(nCol,nRow,nTab), pCell); // nFormat = Standard -> Nachkommastellen wie Float SetFormat( static_cast (nCol), static_cast (nRow), nTab, nFormat, nDezFloat ); @@ -391,9 +390,8 @@ void OP_Number123( SvStream& r, sal_uInt16 /*n*/ ) if (ValidColRow( static_cast(nCol), nRow) && nTab <= pDoc->GetMaxTableNumber()) { double fValue = Snum32ToDouble( nValue ); - - ScValueCell *pCell = new ScValueCell( fValue ); - pDoc->PutCell( static_cast(nCol), static_cast(nRow), static_cast(nTab), pCell, true ); + pDoc->EnsureTable(nTab); + pDoc->SetValue(ScAddress(nCol,nRow,nTab), fValue); } } @@ -416,10 +414,9 @@ void OP_Formula123( SvStream& r, sal_uInt16 n ) if (ValidColRow( static_cast(nCol), nRow) && nTab <= pDoc->GetMaxTableNumber()) { ScFormulaCell* pCell = new ScFormulaCell( pLotusRoot->pDoc, aAddress, pErg ); - pCell->AddRecalcMode( RECALCMODE_ONLOAD_ONCE ); - - pDoc->PutCell( static_cast(nCol), static_cast(nRow), static_cast(nTab), pCell, true ); + pDoc->EnsureTable(nTab); + pDoc->SetFormulaCell(ScAddress(nCol,nRow,nTab), pCell); } } @@ -433,8 +430,8 @@ void OP_IEEENumber123( SvStream& r, sal_uInt16 /*n*/ ) if (ValidColRow( static_cast(nCol), nRow) && nTab <= pDoc->GetMaxTableNumber()) { - ScValueCell *pCell = new ScValueCell(dValue); - pDoc->PutCell( static_cast(nCol), static_cast(nRow), static_cast(nTab), pCell, true ); + pDoc->EnsureTable(nTab); + pDoc->SetValue(ScAddress(nCol,nRow,nTab), dValue); } } diff --git a/sc/source/filter/qpro/qpro.cxx b/sc/source/filter/qpro/qpro.cxx index e292871833db..231f1e0752ae 100644 --- a/sc/source/filter/qpro/qpro.cxx +++ b/sc/source/filter/qpro/qpro.cxx @@ -82,20 +82,20 @@ FltError ScQProReader::readSheet( SCTAB nTab, ScDocument* pDoc, ScQProStyle *pSt case 0x000d:{ // Integer cell sal_Int16 nValue; *mpStream >> nCol >> nDummy >> nRow >> nStyle >> nValue; - ScValueCell* pInteger = new ScValueCell( ( double ) nValue ); nStyle = nStyle >> 3; pStyle->SetFormat( pDoc, nCol, nRow, nTab, nStyle ); - pDoc->PutCell(nCol ,nRow, nTab ,pInteger,true); + pDoc->EnsureTable(nTab); + pDoc->SetValue(ScAddress(nCol,nRow,nTab), static_cast(nValue)); } break; case 0x000e:{ // Floating point cell double nValue; *mpStream >> nCol >> nDummy >> nRow >> nStyle >> nValue; - ScValueCell* pFloat = new ScValueCell( nValue ); nStyle = nStyle >> 3; pStyle->SetFormat( pDoc, nCol, nRow, nTab, nStyle ); - pDoc->PutCell( nCol, nRow, nTab, pFloat, true ); + pDoc->EnsureTable(nTab); + pDoc->SetValue(ScAddress(nCol,nRow,nTab), nValue); } break; @@ -114,7 +114,8 @@ FltError ScQProReader::readSheet( SCTAB nTab, ScDocument* pDoc, ScQProStyle *pSt nStyle = nStyle >> 3; pFormula->AddRecalcMode( RECALCMODE_ONLOAD_ONCE ); pStyle->SetFormat( pDoc, nCol, nRow, nTab, nStyle ); - pDoc->PutCell( nCol, nRow, nTab, pFormula, true ); + pDoc->EnsureTable(nTab); + pDoc->SetFormulaCell(ScAddress(nCol,nRow,nTab), pFormula); } } break; diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx index 26811c3a84d7..445962dc8f0a 100644 --- a/sc/source/filter/starcalc/scflt.cxx +++ b/sc/source/filter/starcalc/scflt.cxx @@ -1672,7 +1672,8 @@ void Sc10Import::LoadCol(SCCOL Col, SCTAB Tab) s[Len + 1] = 0; ScFormulaCell* pCell = new ScFormulaCell( pDoc, ScAddress( Col, static_cast (Row), Tab ) ); pCell->SetHybridFormula( SC10TOSTRING( s ),formula::FormulaGrammar::GRAM_NATIVE ); - pDoc->PutCell( Col, static_cast (Row), Tab, pCell, true ); + pDoc->EnsureTable(Tab); + pDoc->SetFormulaCell(ScAddress(Col,Row,Tab), pCell); break; } case ctNote : -- cgit