[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Thu Mar 21 09:48:54 PDT 2013


 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(-)

New commits:
commit 36b194405ee3509dccee33263a9c610aaaf16e93
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Mar 21 12:50:52 2013 -0400

    More on reducing use of ScDocument::PutCell().
    
    Change-Id: Ibcbb8690c96c176a31563e7b833fa66412888cb6

diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx
index 8668c9e..5ed2564 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<SCCOL>(nCol), nRow))
     {
-        ScValueCell*  pZelle = new ScValueCell( ( double ) nValue );
-        pDoc->PutCell( static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, pZelle, true );
+        pDoc->EnsureTable(nTab);
+        pDoc->SetValue(ScAddress(nCol,nRow,nTab), static_cast<double>(nValue));
 
         // 0 Stellen nach'm Komma!
         SetFormat( static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, nFormat, 0 );
@@ -114,8 +114,8 @@ void OP_Number( SvStream& r, sal_uInt16 /*n*/ )
     if (ValidColRow( static_cast<SCCOL>(nCol), nRow))
     {
         fValue = ::rtl::math::round( fValue, 15 );
-        ScValueCell*  pZelle = new ScValueCell( fValue );
-        pDoc->PutCell( static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, pZelle, true );
+        pDoc->EnsureTable(nTab);
+        pDoc->SetValue(ScAddress(nCol,nRow,nTab), fValue);
 
         SetFormat( static_cast<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, nFormat, nDezFloat );
     }
@@ -169,11 +169,10 @@ void OP_Formula( SvStream& r, sal_uInt16 /*n*/ )
 
     if (ValidColRow( static_cast<SCCOL>(nCol), nRow))
     {
-        ScFormulaCell*    pZelle = new ScFormulaCell( pLotusRoot->pDoc, aAddress, pErg );
-
-        pZelle->AddRecalcMode( RECALCMODE_ONLOAD_ONCE );
-
-        pDoc->PutCell( static_cast<SCCOL> (nCol), static_cast<SCROW> (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<SCCOL> (nCol), static_cast<SCROW> (nRow), nTab, nFormat, nDezFloat );
@@ -391,9 +390,8 @@ void OP_Number123( SvStream& r, sal_uInt16 /*n*/ )
     if (ValidColRow( static_cast<SCCOL>(nCol), nRow) && nTab <= pDoc->GetMaxTableNumber())
     {
         double fValue = Snum32ToDouble( nValue );
-
-        ScValueCell *pCell = new ScValueCell( fValue );
-        pDoc->PutCell( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), static_cast<SCTAB>(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<SCCOL>(nCol), nRow) && nTab <= pDoc->GetMaxTableNumber())
     {
         ScFormulaCell* pCell = new ScFormulaCell( pLotusRoot->pDoc, aAddress, pErg );
-
         pCell->AddRecalcMode( RECALCMODE_ONLOAD_ONCE );
-
-        pDoc->PutCell( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), static_cast<SCTAB>(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<SCCOL>(nCol), nRow) && nTab <= pDoc->GetMaxTableNumber())
     {
-        ScValueCell *pCell = new ScValueCell(dValue);
-        pDoc->PutCell( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), static_cast<SCTAB>(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 e292871..231f1e0 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<double>(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 26811c3..445962d 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<SCROW> (Row), Tab ) );
                     pCell->SetHybridFormula( SC10TOSTRING( s ),formula::FormulaGrammar::GRAM_NATIVE );
-                    pDoc->PutCell( Col, static_cast<SCROW> (Row), Tab, pCell, true );
+                    pDoc->EnsureTable(Tab);
+                    pDoc->SetFormulaCell(ScAddress(Col,Row,Tab), pCell);
                     break;
                 }
                 case ctNote :


More information about the Libreoffice-commits mailing list