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

Kohei Yoshida kohei.yoshida at gmail.com
Tue Jun 18 12:09:14 PDT 2013


 sc/inc/cell.hxx                     |    4 ----
 sc/inc/formulacell.hxx              |    6 ++----
 sc/source/core/data/attarray.cxx    |    1 +
 sc/source/core/data/cell.cxx        |   26 --------------------------
 sc/source/core/data/cellvalue.cxx   |    2 +-
 sc/source/core/data/colorscale.cxx  |    4 ++--
 sc/source/core/data/documen2.cxx    |    2 +-
 sc/source/core/data/formulacell.cxx |    6 +-----
 sc/source/core/data/table2.cxx      |    2 +-
 sc/source/core/data/validat.cxx     |    2 +-
 sc/source/ui/undo/undoblk3.cxx      |    1 +
 sc/source/ui/unoobj/chart2uno.cxx   |    2 +-
 12 files changed, 12 insertions(+), 46 deletions(-)

New commits:
commit 2bd775d61e3cf0b7cc68004cd4ff6807b5edb8c2
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jun 18 15:11:30 2013 -0400

    ScFormulaCell is no longer a child class of ScBaseCell.
    
    Change-Id: Id33072f193045e2eaf51373b47dac803f9a5d52c

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 597feb8..860104b 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -55,10 +55,6 @@ public:
         broadcaster will not be cloned. */
     ScBaseCell*     Clone( ScDocument& rDestDoc, const ScAddress& rDestPos, int nCloneFlags = SC_CLONECELL_DEFAULT ) const;
 
-    /** Due to the fact that ScBaseCell does not have a vtable, this function
-        deletes the cell by calling the appropriate d'tor of the derived class. */
-    void            Delete();
-
     inline CellType GetCellType() const { return (CellType)eCellType; }
 
     /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may have been
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index af9067e..196e6bf 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -20,7 +20,6 @@
 #ifndef SC_FORMULACELL_HXX
 #define SC_FORMULACELL_HXX
 
-#include "cell.hxx"
 #include "formularesult.hxx"
 
 #include "formula/tokenarray.hxx"
@@ -35,6 +34,7 @@ class EndListeningContext;
 
 }
 
+class ScProgress;
 class ScTokenArray;
 struct ScSimilarFormulaDelta;
 
@@ -65,7 +65,7 @@ enum ScMatrixMode {
     MM_FAKE      = 3                    // Interpret "as-if" matrix formula (legacy)
 };
 
-class SC_DLLPUBLIC ScFormulaCell : public ScBaseCell, public SvtListener
+class SC_DLLPUBLIC ScFormulaCell : public SvtListener
 {
 private:
     ScFormulaResult aResult;
@@ -113,8 +113,6 @@ public:
 
                     ~ScFormulaCell();
 
-    using ScBaseCell::Clone;
-
     ScFormulaCell* Clone() const;
 
     /** Empty formula cell, or with a preconstructed token array. */
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 7ef3103..9447bb9 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -40,6 +40,7 @@
 #include "rechead.hxx"
 #include "globstr.hrc"
 #include "segmenttree.hxx"
+#include "cell.hxx"
 #include "formulacell.hxx"
 #include "cellvalue.hxx"
 #include "editutil.hxx"
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 6ccc80a..9010752 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -60,8 +60,6 @@ ScBaseCell* lclCloneCell( const ScBaseCell& rSrcCell, ScDocument& rDestDoc, cons
             return new ScStringCell( static_cast< const ScStringCell& >( rSrcCell ) );
         case CELLTYPE_EDIT:
             return new ScEditCell(static_cast<const ScEditCell&>(rSrcCell), rDestDoc, rDestPos);
-        case CELLTYPE_FORMULA:
-            return new ScFormulaCell( static_cast< const ScFormulaCell& >( rSrcCell ), rDestDoc, rDestPos, nCloneFlags );
         default:;
     }
     OSL_FAIL( "lclCloneCell - unknown cell type" );
@@ -74,8 +72,6 @@ ScBaseCell* ScBaseCell::Clone( ScDocument& rDestDoc, int nCloneFlags ) const
 {
     // notes will not be cloned -> cell address only needed for formula cells
     ScAddress aDestPos;
-    if( eCellType == CELLTYPE_FORMULA )
-        aDestPos = static_cast< const ScFormulaCell* >( this )->aPos;
     return lclCloneCell( *this, rDestDoc, aDestPos, nCloneFlags );
 }
 
@@ -84,28 +80,6 @@ ScBaseCell* ScBaseCell::Clone( ScDocument& rDestDoc, const ScAddress& rDestPos,
     return lclCloneCell( *this, rDestDoc, rDestPos, nCloneFlags );
 }
 
-void ScBaseCell::Delete()
-{
-    switch (eCellType)
-    {
-        case CELLTYPE_VALUE:
-            delete (ScValueCell*) this;
-            break;
-        case CELLTYPE_STRING:
-            delete (ScStringCell*) this;
-            break;
-        case CELLTYPE_EDIT:
-            delete (ScEditCell*) this;
-            break;
-        case CELLTYPE_FORMULA:
-            delete (ScFormulaCell*) this;
-            break;
-        default:
-            OSL_FAIL("Attempt to Delete() an unknown CELLTYPE");
-            break;
-    }
-}
-
 bool ScBaseCell::HasEmptyData() const
 {
     switch ( eCellType )
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index 169d2f7..abc1bbc 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -172,7 +172,7 @@ void ScCellValue::clear()
             delete mpEditText;
         break;
         case CELLTYPE_FORMULA:
-            mpFormula->Delete();
+            delete mpFormula;
         break;
         default:
             ;
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 2eca97c..70865be 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -39,7 +39,7 @@ ScColorScaleEntry::ScColorScaleEntry(const ScColorScaleEntry& rEntry):
 {
     if(rEntry.mpCell)
     {
-        mpCell.reset(static_cast<ScFormulaCell*>(rEntry.mpCell->Clone(*rEntry.mpCell->GetDocument(), SC_CLONECELL_NOMAKEABS_EXTERNAL)));
+        mpCell.reset(new ScFormulaCell(*rEntry.mpCell, *rEntry.mpCell->GetDocument(), rEntry.mpCell->aPos, SC_CLONECELL_NOMAKEABS_EXTERNAL));
         mpCell->StartListeningTo( mpCell->GetDocument() );
     }
 }
@@ -52,7 +52,7 @@ ScColorScaleEntry::ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry&
 {
     if(rEntry.mpCell)
     {
-        mpCell.reset(static_cast<ScFormulaCell*>(rEntry.mpCell->Clone(*pDoc, SC_CLONECELL_NOMAKEABS_EXTERNAL)));
+        mpCell.reset(new ScFormulaCell(*rEntry.mpCell, *rEntry.mpCell->GetDocument(), rEntry.mpCell->aPos, SC_CLONECELL_NOMAKEABS_EXTERNAL));
         mpCell->StartListeningTo( pDoc );
     }
 }
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index d9c3f09..2fcf8f5 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1060,7 +1060,7 @@ void ScDocument::SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell )
 {
     if (!TableExists(rPos.Tab()))
     {
-        pCell->Delete();
+        delete pCell;
         return;
     }
 
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index b19a1ca..ddbe216 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -394,7 +394,6 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
                               const OUString& rFormula,
                               const FormulaGrammar::Grammar eGrammar,
                               sal_uInt8 cMatInd ) :
-    ScBaseCell( CELLTYPE_FORMULA ),
     eTempGrammar( eGrammar),
     pCode( NULL ),
     pDocument( pDoc ),
@@ -428,7 +427,6 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
 ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
                               const ScTokenArray* pArr,
                               const FormulaGrammar::Grammar eGrammar, sal_uInt8 cInd ) :
-    ScBaseCell( CELLTYPE_FORMULA ),
     eTempGrammar( eGrammar),
     pCode( pArr ? new ScTokenArray( *pArr ) : new ScTokenArray ),
     pDocument( pDoc ),
@@ -473,7 +471,6 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
 }
 
 ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, const ScAddress& rPos, int nCloneFlags ) :
-    ScBaseCell( rCell ),
     SvtListener(),
     aResult( rCell.aResult ),
     eTempGrammar( rCell.eTempGrammar),
@@ -1841,8 +1838,7 @@ sal_uInt16 ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) const
                 else
                     pFCell = this;      // this MM_FORMULA
                 // There's only one this, don't compare pFCell==this.
-                if ( pFCell && pFCell->GetCellType() == CELLTYPE_FORMULA
-                  && pFCell->cMatrixFlag == MM_FORMULA )
+                if (pFCell && pFCell->cMatrixFlag == MM_FORMULA)
                 {
                     pFCell->GetMatColsRows( nC, nR );
                     if ( nC == 0 || nR == 0 )
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index f519824..6b80609 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1445,7 +1445,7 @@ void ScTable::SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell )
 {
     if (!ValidColRow(nCol, nRow))
     {
-        pCell->Delete();
+        delete pCell;
         return;
     }
 
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 258e7e0..f910083 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -657,7 +657,7 @@ bool ScValidationData::GetSelectionFromFormula(
             xMatRef->PutError( nErrCode, 0, 0);
             bOk = false;
         }
-        else if (aValidationSrc.HasValueData())
+        else if (aValidationSrc.IsValue())
             xMatRef->PutDouble( aValidationSrc.GetValue(), 0);
         else
         {
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 6066984..e380106 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -50,6 +50,7 @@
 #include "docuno.hxx"
 #include "progress.hxx"
 #include "editutil.hxx"
+#include "cell.hxx"
 
 // STATIC DATA ---------------------------------------------------------------
 
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index c6363a4..778d562 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -2612,7 +2612,7 @@ void ScChart2DataSequence::BuildDataCache()
                                 if (nErr)
                                     break;
 
-                                if (pFCell->HasValueData())
+                                if (pFCell->IsValue())
                                 {
                                     rItem.mfValue = pFCell->GetValue();
                                     rItem.mbIsValue = true;


More information about the Libreoffice-commits mailing list