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

Kohei Yoshida kohei.yoshida at gmail.com
Fri May 3 19:24:07 PDT 2013


 sc/inc/cell.hxx                 |    4 --
 sc/source/core/data/cell.cxx    |    5 --
 sc/source/core/data/column.cxx  |    3 -
 sc/source/core/data/column2.cxx |   75 +++++++++++-----------------------------
 4 files changed, 22 insertions(+), 65 deletions(-)

New commits:
commit 530016c7cc7b557f4be481ea09360abd10a531e3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri May 3 22:24:31 2013 -0400

    With the removal of CELLTYPE_NOTE, IsBlank() is now always false.
    
    Let's remove this.
    
    Change-Id: Ica92ea41e104a3f0e97b717ff2e4e115682ce33f

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index ef7c2f7..909c89d 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -65,10 +65,6 @@ public:
 
     inline CellType GetCellType() const { return (CellType)eCellType; }
 
-    /** Returns true, if the cell is empty (neither value nor formula nor cell note).
-        Returns false for formula cells returning nothing, use HasEmptyData() for that. */
-    bool            IsBlank() const;
-
     /** ScFormulaCell with formula::svEmptyCell result, or ScNoteCell (may have been
         created due to reference to empty cell). */
     bool            HasEmptyData() const;
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index b5c8d33..6ccc80a 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -106,11 +106,6 @@ void ScBaseCell::Delete()
     }
 }
 
-bool ScBaseCell::IsBlank() const
-{
-    return false;
-}
-
 bool ScBaseCell::HasEmptyData() const
 {
     switch ( eCellType )
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index e20521a..6f4aff8 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1089,8 +1089,7 @@ bool ScColumn::TestInsertCol( SCROW nStartRow, SCROW nEndRow) const
         bool bTest = true;
         if ( !maItems.empty() )
             for (SCSIZE i=0; (i<maItems.size()) && bTest; i++)
-                bTest = (maItems[i].nRow < nStartRow) || (maItems[i].nRow > nEndRow)
-                        || maItems[i].pCell->IsBlank();
+                bTest = (maItems[i].nRow < nStartRow) || (maItems[i].nRow > nEndRow);
 
         //  AttrArray only looks for merged cells
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index db9a3e8..40fcf2c 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1113,19 +1113,7 @@ bool ScColumn::IsEmptyData() const
 
 bool ScColumn::IsEmptyVisData() const
 {
-    if ( maItems.empty() )
-        return true;
-    else
-    {
-        bool bVisData = false;
-        SCSIZE i;
-        for (i=0; i<maItems.size() && !bVisData; i++)
-        {
-            if(!maItems[i].pCell->IsBlank())
-                bVisData = true;
-        }
-        return !bVisData;
-    }
+    return maItems.empty();
 }
 
 SCSIZE ScColumn::VisibleCount( SCROW nStartRow, SCROW nEndRow ) const
@@ -1148,22 +1136,10 @@ SCSIZE ScColumn::VisibleCount( SCROW nStartRow, SCROW nEndRow ) const
 
 SCROW ScColumn::GetLastVisDataPos() const
 {
-    SCROW nRet = 0;
-    if ( !maItems.empty() )
-    {
-        SCSIZE i;
-        bool bFound = false;
-        for (i=maItems.size(); i>0 && !bFound; )
-        {
-            --i;
-            if(!maItems[i].pCell->IsBlank())
-            {
-                bFound = true;
-                nRet = maItems[i].nRow;
-            }
-        }
-    }
-    return nRet;
+    if (maItems.empty())
+        return 0;
+
+    return maItems.back().nRow;
 }
 
 SCROW ScColumn::GetFirstVisDataPos() const
@@ -1184,12 +1160,11 @@ SCROW ScColumn::GetFirstVisDataPos() const
 
 bool ScColumn::HasVisibleDataAt(SCROW nRow) const
 {
-    SCSIZE nIndex;
-    if (Search(nRow, nIndex))
-        if (!maItems[nIndex].pCell->IsBlank())
-            return true;
+    std::vector<ColEntry>::const_iterator it = Search(nRow);
+    if (it == maItems.end())
+        return false;
 
-    return false;
+    return it->nRow == nRow;
 }
 
 bool ScColumn::IsEmptyAttr() const
@@ -1210,15 +1185,12 @@ bool ScColumn::IsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const
     if ( maItems.empty() )
         return true;
 
-    SCSIZE nIndex;
-    Search( nStartRow, nIndex );
-    while ( nIndex < maItems.size() && maItems[nIndex].nRow <= nEndRow )
-    {
-        if ( !maItems[nIndex].pCell->IsBlank() )   // found a cell
-            return false;                           // not empty
-        ++nIndex;
-    }
-    return true;                                    // no cell found
+    std::vector<ColEntry>::const_iterator it = Search(nStartRow);
+    if (it == maItems.end())
+        // All non-empty cells are before nStartRow.
+        return true;
+
+    return (it->nRow > nEndRow);
 }
 
 SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const
@@ -1236,7 +1208,7 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti
                 i--;
                 if ( maItems[i].nRow < nStartRow )
                     break;
-                bFound = maItems[i].nRow <= nEndRow && !maItems[i].pCell->IsBlank();
+                bFound = maItems[i].nRow <= nEndRow;
             }
             if (bFound)
                 nLines = static_cast<SCSIZE>(nEndRow - maItems[i].nRow);
@@ -1250,7 +1222,7 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti
             {
                 if ( maItems[i].nRow > nEndRow )
                     break;
-                bFound = maItems[i].nRow >= nStartRow && !maItems[i].pCell->IsBlank();
+                bFound = maItems[i].nRow >= nStartRow;
                 i++;
             }
             if (bFound)
@@ -1348,7 +1320,7 @@ SCROW ScColumn::FindNextVisibleRowWithContent(SCROW nRow, bool bForward) const
 
             SCSIZE nIndex;
             bool bThere = Search( nRow, nIndex );
-            if( bThere && !maItems[nIndex].pCell->IsBlank())
+            if (bThere)
                 return nRow;
             else if((bThere ? nIndex+1 : nIndex) >= maItems.size())
                 return MAXROW;
@@ -1380,7 +1352,7 @@ SCROW ScColumn::FindNextVisibleRowWithContent(SCROW nRow, bool bForward) const
 
             SCSIZE nIndex;
             bool bThere = Search( nRow, nIndex );
-            if(bThere && !maItems[nIndex].pCell->IsBlank())
+            if (bThere)
                 return nRow;
             else if(nIndex == 0)
                 return 0;
@@ -1761,8 +1733,6 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, bool bDown) const
     // check if we are in a data area
     SCSIZE nIndex;
     bool bThere = Search(rRow, nIndex);
-    if (bThere && maItems[nIndex].pCell->IsBlank())
-        bThere = false;
 
     size_t nLastIndex = maItems.size() - 1;
     if (bThere)
@@ -1770,8 +1740,6 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, bool bDown) const
         SCROW nNextRow = FindNextVisibleRow(rRow, bDown);
         SCSIZE nNewIndex;
         bool bNextThere = Search(nNextRow, nNewIndex);
-        if(bNextThere && maItems[nNewIndex].pCell->IsBlank())
-            bNextThere = false;
 
         if(bNextThere)
         {
@@ -1781,7 +1749,7 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, bool bDown) const
             {
                 nNextRow = FindNextVisibleRow(nLastRow, bDown);
                 bNextThere = Search(nNextRow, nNewIndex);
-                if(!bNextThere || maItems[nNewIndex].pCell->IsBlank())
+                if (!bNextThere)
                     bNextThere = false;
                 else
                     nLastRow = nNextRow;
@@ -1808,8 +1776,7 @@ bool ScColumn::HasDataAt(SCROW nRow) const
 
     SCSIZE nIndex;
     if (Search(nRow, nIndex))
-        if (!maItems[nIndex].pCell->IsBlank())
-            return true;
+        return true;
 
     return false;
 


More information about the Libreoffice-commits mailing list