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

Kohei Yoshida kohei.yoshida at gmail.com
Thu Mar 28 07:56:49 PDT 2013


 sc/inc/cell.hxx                  |    2 
 sc/source/core/data/cell.cxx     |   80 ---------------------------------------
 sc/source/core/data/documen4.cxx |   24 +++++------
 3 files changed, 12 insertions(+), 94 deletions(-)

New commits:
commit 620fdad868ab90cb6733bf83ab0ac5450d1ce3e8
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Mar 28 10:59:07 2013 -0400

    ScBaseCell::CellEqual is no more.
    
    Change-Id: I9a2923ec85ce116662d66a38b61a5258ff113168

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index b0919a6..166649d 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -100,8 +100,6 @@ public:
     bool            HasStringData() const;
     rtl::OUString   GetStringData() const;          // only real strings
 
-    static bool     CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 );
-
 private:
     ScBaseCell&     operator=( const ScBaseCell& );
 
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index cee5df3..66032a8 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -345,86 +345,6 @@ rtl::OUString ScBaseCell::GetStringData() const
     return aStr;
 }
 
-bool ScBaseCell::CellEqual( const ScBaseCell* pCell1, const ScBaseCell* pCell2 )
-{
-    CellType eType1 = CELLTYPE_NONE;
-    CellType eType2 = CELLTYPE_NONE;
-    if ( pCell1 )
-    {
-        eType1 = pCell1->GetCellType();
-        if (eType1 == CELLTYPE_EDIT)
-            eType1 = CELLTYPE_STRING;
-        else if (eType1 == CELLTYPE_NOTE)
-            eType1 = CELLTYPE_NONE;
-    }
-    if ( pCell2 )
-    {
-        eType2 = pCell2->GetCellType();
-        if (eType2 == CELLTYPE_EDIT)
-            eType2 = CELLTYPE_STRING;
-        else if (eType2 == CELLTYPE_NOTE)
-            eType2 = CELLTYPE_NONE;
-    }
-    if ( eType1 != eType2 )
-        return false;
-
-    switch ( eType1 )               // Both Types are the same
-    {
-        case CELLTYPE_NONE:         // Both Empty
-            return true;
-        case CELLTYPE_VALUE:        // Really Value-Cells
-            return ( ((const ScValueCell*)pCell1)->GetValue() ==
-                     ((const ScValueCell*)pCell2)->GetValue() );
-        case CELLTYPE_STRING:       // String or Edit
-            {
-                rtl::OUString aText1;
-                if ( pCell1->GetCellType() == CELLTYPE_STRING )
-                    aText1 = ((const ScStringCell*)pCell1)->GetString();
-                else
-                    aText1 = ((const ScEditCell*)pCell1)->GetString();
-                rtl::OUString aText2;
-                if ( pCell2->GetCellType() == CELLTYPE_STRING )
-                    aText2 = ((const ScStringCell*)pCell2)->GetString();
-                else
-                    aText2 = ((const ScEditCell*)pCell2)->GetString();
-                return ( aText1 == aText2 );
-            }
-        case CELLTYPE_FORMULA:
-            {
-                //! pasted Lines / allow Slots!!!!!
-                //! Comparsion Function of the Formula Cell???
-                //! To request with ScColumn::SwapRow to catch together!
-
-                ScTokenArray* pCode1 = ((ScFormulaCell*)pCell1)->GetCode();
-                ScTokenArray* pCode2 = ((ScFormulaCell*)pCell2)->GetCode();
-
-                if (pCode1->GetLen() == pCode2->GetLen())       // nicht-UPN
-                {
-                    bool bEqual = true;
-                    sal_uInt16 nLen = pCode1->GetLen();
-                    FormulaToken** ppToken1 = pCode1->GetArray();
-                    FormulaToken** ppToken2 = pCode2->GetArray();
-                    for (sal_uInt16 i=0; i<nLen; i++)
-                        if ( !ppToken1[i]->TextEqual(*(ppToken2[i])) )
-                        {
-                            bEqual = false;
-                            break;
-                        }
-
-                    if (bEqual)
-                        return true;
-                }
-
-                return false;       // varying long or varying Tokens
-            }
-        default:
-            OSL_FAIL("oops, something for the Cells???");
-    }
-    return false;
-}
-
-// ============================================================================
-
 ScNoteCell::ScNoteCell( SvtBroadcaster* pBC ) :
     ScBaseCell( CELLTYPE_NOTE )
 {
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 3df2fbc..27fd9fa 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -790,18 +790,18 @@ sal_uInt16 ScDocument::RowDifferences( SCROW nThisRow, SCTAB nThisTab,
 
         if (ValidCol(nOtherCol))    // nur Spalten vergleichen, die in beiden Dateien sind
         {
-            const ScBaseCell* pThisCell = GetCell( ScAddress( nThisCol, nThisRow, nThisTab ) );
-            const ScBaseCell* pOtherCell = rOtherDoc.GetCell( ScAddress( nOtherCol, nOtherRow, nOtherTab ) );
-            if (!ScBaseCell::CellEqual( pThisCell, pOtherCell ))
+            ScRefCellValue aThisCell, aOtherCell;
+            aThisCell.assign(*this, ScAddress(nThisCol, nThisRow, nThisTab));
+            aOtherCell.assign(rOtherDoc, ScAddress(nOtherCol, nOtherRow, nOtherTab));
+            if (!aThisCell.equalsWithoutFormat(aOtherCell))
             {
-                if ( pThisCell && pOtherCell )
+                if (!aThisCell.isEmpty() && !aOtherCell.isEmpty())
                     nDif += 3;
                 else
                     nDif += 4;      // Inhalt <-> leer zaehlt mehr
             }
 
-            if ( ( pThisCell  && pThisCell->GetCellType()!=CELLTYPE_NOTE ) ||
-                 ( pOtherCell && pOtherCell->GetCellType()!=CELLTYPE_NOTE ) )
+            if (!aThisCell.isEmpty() || !aOtherCell.isEmpty())
                 ++nUsed;
         }
     }
@@ -831,18 +831,18 @@ sal_uInt16 ScDocument::ColDifferences( SCCOL nThisCol, SCTAB nThisTab,
 
         if (ValidRow(nOtherRow))    // nur Zeilen vergleichen, die in beiden Dateien sind
         {
-            const ScBaseCell* pThisCell = GetCell( ScAddress( nThisCol, nThisRow, nThisTab ) );
-            const ScBaseCell* pOtherCell = rOtherDoc.GetCell( ScAddress( nOtherCol, nOtherRow, nOtherTab ) );
-            if (!ScBaseCell::CellEqual( pThisCell, pOtherCell ))
+            ScRefCellValue aThisCell, aOtherCell;
+            aThisCell.assign(*this, ScAddress(nThisCol, nThisRow, nThisTab));
+            aOtherCell.assign(rOtherDoc, ScAddress(nOtherCol, nOtherRow, nOtherTab));
+            if (!aThisCell.equalsWithoutFormat(aOtherCell))
             {
-                if ( pThisCell && pOtherCell )
+                if (!aThisCell.isEmpty() && !aOtherCell.isEmpty())
                     nDif += 3;
                 else
                     nDif += 4;      // Inhalt <-> leer zaehlt mehr
             }
 
-            if ( ( pThisCell  && pThisCell->GetCellType()!=CELLTYPE_NOTE ) ||
-                 ( pOtherCell && pOtherCell->GetCellType()!=CELLTYPE_NOTE ) )
+            if (!aThisCell.isEmpty() || !aOtherCell.isEmpty())
                 ++nUsed;
         }
     }


More information about the Libreoffice-commits mailing list