[Libreoffice-commits] .: Branch 'feature/smaller-base-cell' - 3 commits - sc/inc sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Nov 6 13:14:33 PST 2012


 sc/inc/column.hxx               |   13 +++++++++++--
 sc/source/core/data/column.cxx  |   37 +++++++++++++++++++++++++++----------
 sc/source/core/data/column2.cxx |    4 ++++
 sc/source/core/data/column3.cxx |   25 ++++++++++++++++++++++---
 sc/source/core/data/table1.cxx  |    2 +-
 sc/source/core/data/table4.cxx  |    4 ++--
 6 files changed, 67 insertions(+), 18 deletions(-)

New commits:
commit b94272c6881ede678aef16bc330c611dbfef5cfa
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Nov 6 16:13:37 2012 -0500

    Identify all places that modify the cell array & call CellStorageModified().
    
    CellStorageModified() is empty at the moment.
    
    Change-Id: I9498b4d7819bba1778cbab644e7b46ce25d66ae4

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index eacfc68..b0c53cc 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -381,6 +381,8 @@ public:
     xub_StrLen  GetMaxNumberStringLen( sal_uInt16& nPrecision,
                                        SCROW nRowStart, SCROW nRowEnd ) const;
 
+    void SetTextWidth(SCROW nRow, sal_uInt16 nWidth);
+
 private:
     ScBaseCell* CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rDestDoc, const ScAddress& rDestPos) const;
 
@@ -388,8 +390,10 @@ private:
     SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const;
 
     /**
-     * Called whenever the state of cell array gets modified i.e. a new cell
-     * is inserted, a cell is moved or removed, cells are swapped, and so on.
+     * Called whenever the state of cell array gets modified i.e. new cell
+     * insertion, cell removal or relocation, cell value update and so on.
+     *
+     * Call this only from those methods where maItems is modified directly.
      */
     void CellStorageModified();
 };
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 3e7a0b2..bae732a 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -813,14 +813,14 @@ void lclTakeBroadcaster( ScBaseCell*& rpCell, SvtBroadcaster* pBC )
 
 void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
 {
+    if (nRow1 == nRow2)
+        // Nothing to swap.
+        return;
+
     /*  Simple swap of cell pointers does not work if broadcasters exist (crash
         if cell broadcasts directly or indirectly to itself). While swapping
         the cells, broadcasters have to remain at old positions! */
 
-    /*  While cloning cells, do not clone notes, but move note pointers to new
-        cells. This prevents creation of new caption drawing objects for every
-        swap operation while sorting. */
-
     ScBaseCell* pCell1 = 0;
     SCSIZE nIndex1;
     if ( Search( nRow1, nIndex1 ) )
@@ -870,6 +870,8 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
             SvtBroadcaster* pBC2 = pCell2->ReleaseBroadcaster();
             pCell1->TakeBroadcaster( pBC2 );
             pCell2->TakeBroadcaster( pBC1 );
+
+            CellStorageModified();
         }
         else
         {
@@ -878,11 +880,13 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
             {
                 // insert dummy note cell (without note) containing old broadcaster
                 maItems[nIndex1].pCell = pDummyCell;
+                CellStorageModified();
             }
             else
             {
                 // remove ColEntry at old position
                 maItems.erase( maItems.begin() + nIndex1 );
+                CellStorageModified();
             }
 
             // insert ColEntry at new position
@@ -930,8 +934,7 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
     }
 
     /*  Create clone of pCell1 at position of pCell2 (pCell1 exists always, see
-        variable swapping above). Do not clone the note, but move pointer of
-        old note to new cell. */
+        variable swapping above).*/
     ScBaseCell* pNew2 = pCell1->Clone( *pDocument, aPos2, SC_CLONECELL_ADJUST3DREL );
 
     /*  Create clone of pCell2 at position of pCell1. Do not clone the note,
@@ -991,7 +994,10 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn& rCol)
     {
         // Tauschen
         maItems[nIndex1].pCell = pCell2;
+        CellStorageModified();
         rCol.maItems[nIndex2].pCell = pCell1;
+        rCol.CellStorageModified();
+
         // Referenzen aktualisieren
         SCsCOL dx = rCol.nCol - nCol;
         if ( pFmlaCell1 )
@@ -1013,6 +1019,8 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn& rCol)
     {
         // Loeschen
         maItems.erase(maItems.begin() + nIndex1);
+        CellStorageModified();
+
         // Referenzen aktualisieren
         SCsCOL dx = rCol.nCol - nCol;
         if ( pFmlaCell1 )
@@ -1168,6 +1176,8 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
     }
 
     pDocument->SetAutoCalc( bOldAutoCalc );
+
+    CellStorageModified();
 }
 
 
@@ -1449,6 +1459,8 @@ void ScColumn::MarkScenarioIn( ScMarkData& rDestMark ) const
 void ScColumn::SwapCol(ScColumn& rCol)
 {
     maItems.swap(rCol.maItems);
+    CellStorageModified();
+    rCol.CellStorageModified();
 
     ScAttrArray* pTempAttr = rCol.pAttrArray;
     rCol.pAttrArray = pAttrArray;
@@ -1541,9 +1553,11 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol)
             }
             // Erase the slots containing pointers to the dummy cell instance.
             maItems.erase(maItems.begin() + nStartPos, maItems.begin() + nStopPos);
+            CellStorageModified();
         }
         pNoteCell->Delete(); // Delete the dummy cell instance.
     }
+
 }
 
 bool ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
@@ -1684,6 +1698,7 @@ void ScColumn::UpdateInsertTabOnlyCells(SCTAB nInsPos, SCTAB nNewSheets)
             {
                 ScEditCell* p = static_cast<ScEditCell*>(maItems[i].pCell);
                 p->UpdateFields(nTab);
+                SetTextWidth(maItems[i].nRow, TEXTWIDTH_DIRTY);
             }
             break;
             default:
@@ -1714,6 +1729,7 @@ void ScColumn::UpdateInsertTabAbs(SCTAB nNewPos)
             {
                 ScEditCell* p = static_cast<ScEditCell*>(maItems[i].pCell);
                 p->UpdateFields(nTab);
+                SetTextWidth(maItems[i].nRow, TEXTWIDTH_DIRTY);
             }
             break;
             default:
@@ -1763,6 +1779,7 @@ void ScColumn::UpdateDeleteTab(SCTAB nDelPos, bool bIsMove, ScColumn* pRefUndo,
             {
                 ScEditCell* p = static_cast<ScEditCell*>(maItems[i].pCell);
                 p->UpdateFields(nTab);
+                SetTextWidth(maItems[i].nRow, TEXTWIDTH_DIRTY);
             }
             break;
             default:
@@ -1795,6 +1812,7 @@ void ScColumn::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo )
             {
                 ScEditCell* p = static_cast<ScEditCell*>(maItems[i].pCell);
                 p->UpdateFields(nTab);
+                SetTextWidth(maItems[i].nRow, TEXTWIDTH_DIRTY);
             }
             break;
             default:
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index c7820ba..e9110cc 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -96,12 +96,14 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
             }
             pOldCell->Delete();
             maItems[nIndex].pCell = pNewCell;
+            CellStorageModified();
         }
         else
         {
             maItems.insert(maItems.begin() + nIndex, ColEntry());
             maItems[nIndex].pCell = pNewCell;
             maItems[nIndex].nRow  = nRow;
+            CellStorageModified();
         }
     }
     // Bei aus Clipboard sind hier noch falsche (alte) Referenzen!
@@ -145,6 +147,8 @@ void ScColumn::Append( SCROW nRow, ScBaseCell* pCell )
     maItems.push_back(ColEntry());
     maItems.back().pCell = pCell;
     maItems.back().nRow  = nRow;
+
+    CellStorageModified();
 }
 
 
@@ -171,6 +175,8 @@ void ScColumn::Delete( SCROW nRow )
         }
         pCell->EndListeningTo( pDocument );
         pCell->Delete();
+
+        CellStorageModified();
     }
 }
 
@@ -186,6 +192,8 @@ void ScColumn::DeleteAtIndex( SCSIZE nIndex )
     maItems.erase(maItems.begin() + nIndex);
     pCell->EndListeningTo( pDocument );
     pCell->Delete();
+
+    CellStorageModified();
 }
 
 
@@ -194,6 +202,8 @@ void ScColumn::FreeAll()
     for (SCSIZE i = 0; i < maItems.size(); i++)
         maItems[i].pCell->Delete();
     maItems.clear();
+
+    CellStorageModified();
 }
 
 
@@ -491,6 +501,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
         if (bRemoved)
             nShift += maItems.size() - nStartSegment;
         maItems.erase(maItems.end() - nShift, maItems.end());
+        CellStorageModified();
     }
 
     // *** delete all formula cells ***
@@ -1414,8 +1425,11 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
                     if ( i >= maItems.size() || maItems[i].nRow != nRow )
                         Search(nRow, i);
                 }
+
                 pOldCell->Delete();
                 maItems[i].pCell = pNewCell;         // ersetzen
+                CellStorageModified();
+
                 if ( pNewCell->GetCellType() == CELLTYPE_FORMULA )
                 {
                     pNewCell->StartListeningTo( pDocument );
@@ -1637,6 +1651,8 @@ void ScColumn::RemoveProtected( SCROW nStartRow, SCROW nEndRow )
                         maItems[nIndex].pCell = new ScStringCell( aString );
                     }
                     delete pFormula;
+
+                    CellStorageModified();
                 }
                 ++nIndex;
             }
@@ -1934,4 +1950,8 @@ xub_StrLen ScColumn::GetMaxNumberStringLen(
     return nStringLen;
 }
 
+void ScColumn::SetTextWidth(SCROW nRow, sal_uInt16 nWidth)
+{
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 593f17e086db4662de13b38223721bf4108802b3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Nov 6 14:00:54 2012 -0500

    Rename ScColumn::Resize() to ReserveSize().
    
    The new name is more aligned with what it actually does.
    
    Change-Id: I703e20253fe5957c775026d8d08f2906f2d7889c

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 1be1b1d..eacfc68 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -130,7 +130,7 @@ public:
     void        Delete( SCROW nRow );
     void        DeleteAtIndex( SCSIZE nIndex );
     void        FreeAll();
-    void        Resize( SCSIZE nSize );
+    void ReserveSize( SCSIZE nSize );
     void        SwapRow( SCROW nRow1, SCROW nRow2 );
     void        SwapCell( SCROW nRow, ScColumn& rCol);
 
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index c2b2c1d..3e7a0b2 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -783,8 +783,7 @@ ScBaseCell* ScColumn::GetCell( SCROW nRow ) const
     return NULL;
 }
 
-
-void ScColumn::Resize( SCSIZE nSize )
+void ScColumn::ReserveSize( SCSIZE nSize )
 {
     if (nSize > sal::static_int_cast<SCSIZE>(MAXROWCOUNT))
         nSize = MAXROWCOUNT;
@@ -1201,7 +1200,7 @@ void ScColumn::CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, bool bKee
 
     if (nBlockCount)
     {
-        rColumn.Resize( rColumn.GetCellCount() + nBlockCount );
+        rColumn.ReserveSize(rColumn.GetCellCount() + nBlockCount);
         ScAddress aOwnPos( nCol, 0, nTab );
         ScAddress aDestPos( rColumn.nCol, 0, rColumn.nTab );
         for (i = nStartIndex; i <= nEndIndex; i++)
@@ -1277,7 +1276,7 @@ void ScColumn::CopyToColumn(
 
         if (nBlockCount)
         {
-            rColumn.Resize( rColumn.GetCellCount() + nBlockCount );
+            rColumn.ReserveSize(rColumn.GetCellCount() + nBlockCount);
             ScAddress aDestPos( rColumn.nCol, 0, rColumn.nTab );
             for (i = nStartIndex; i <= nEndIndex; i++)
             {
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index c44de8e..c7820ba 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -687,7 +687,7 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy,
         //! IDF_ALL muss immer mehr Flags enthalten, als bei "Inhalte Einfuegen"
         //! einzeln ausgewaehlt werden koennen!
 
-        Resize( maItems.size() + static_cast<SCSIZE>(nRow2-nRow1+1) );
+        ReserveSize(maItems.size() + static_cast<SCSIZE>(nRow2-nRow1+1));
 
         ScAddress aDestPos( nCol, 0, nTab );        // Row wird angepasst
 
@@ -721,8 +721,7 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy,
         //! Always do the Resize from the outside, where the number of repetitions is known
         //! (then it can be removed here)
 
-        SCSIZE nNew = maItems.size() + nColCount;
-        Resize( nNew );
+        ReserveSize(maItems.size() + nColCount);
     }
 
     sal_Bool bAtEnd = false;
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 4da2595..3d28f54 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1877,7 +1877,7 @@ void ScTable::CopyPrintRange(const ScTable& rTable)
 void ScTable::DoColResize( SCCOL nCol1, SCCOL nCol2, SCSIZE nAdd )
 {
     for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++)
-        aCol[nCol].Resize(aCol[nCol].GetCellCount() + nAdd);
+        aCol[nCol].ReserveSize(aCol[nCol].GetCellCount() + nAdd);
 }
 
 void ScTable::SetRepeatColRange( const ScRange* pNew )
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index b1f86e0..a27063e 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -683,7 +683,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                     nInc,nMinDigits, pListData,nListIndex);
 
         if (bVertical)
-            aCol[nCol].Resize( aCol[nCol].GetCellCount() + nFillCount );
+            aCol[nCol].ReserveSize(aCol[nCol].GetCellCount() + nFillCount);
 
         if (pListData)
         {
@@ -1379,7 +1379,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
         ScBaseCell* pSrcCell = aCol[nCol].GetCell(static_cast<SCROW>(nRow));
 
         if (bVertical && bAttribs)
-            aCol[nCol].Resize( aCol[nCol].GetCellCount() + nFillCount );
+            aCol[nCol].ReserveSize(aCol[nCol].GetCellCount() + nFillCount);
 
         if (bAttribs)
         {
commit 2982d8d521c4a894750cc23b33606f9949e88b97
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Nov 6 13:53:57 2012 -0500

    Redundant use of 'public' modifier.
    
    Plus added a new method that will get called whenever cell array
    state changes.  It's not used yet.
    
    Change-Id: I96719db0460bfb72d8dbe98a80a3880d8f279c33

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 402d62f..1be1b1d 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -352,7 +352,6 @@ public:
         SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHeight, OutputDevice* pDev,
         double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY,
         bool bShrink, sal_uInt16 nMinHeight, SCROW nMinStart) const;
-public:
 
                 /// Including current, may return -1
     SCsROW      GetNextUnprotected( SCROW nRow, bool bUp ) const;
@@ -387,6 +386,12 @@ private:
 
     SCROW FindNextVisibleRowWithContent(SCROW nRow, bool bForward) const;
     SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const;
+
+    /**
+     * Called whenever the state of cell array gets modified i.e. a new cell
+     * is inserted, a cell is moved or removed, cells are swapped, and so on.
+     */
+    void CellStorageModified();
 };
 
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 036f00f..76f4d7a 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1396,6 +1396,10 @@ SCROW ScColumn::FindNextVisibleRowWithContent(SCROW nRow, bool bForward) const
     }
 }
 
+void ScColumn::CellStorageModified()
+{
+}
+
 void ScColumn::FindDataAreaPos(SCROW& rRow, bool bDown) const
 {
     // check if we are in a data area


More information about the Libreoffice-commits mailing list