summaryrefslogtreecommitdiff
path: root/sc/source/core/data/column.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-05-08 16:04:50 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-05-09 13:34:36 -0400
commit6cac65cc6e89f4f36dbcca3682f08b7b5ed5b750 (patch)
treeb5f9f3aeb0e50c43ab43c6a01805c05a064efc82 /sc/source/core/data/column.cxx
parentc264a7e7176da645698c770ac50a76ce5b632efa (diff)
Simplify this a bit.
By taking advantage of 1) cell array being std::vector, and 2) broadcasters are no longer stored with cells. Change-Id: I9ba1d3004e62d7bb7810d8fed0c4e8fd17605d0f
Diffstat (limited to 'sc/source/core/data/column.cxx')
-rw-r--r--sc/source/core/data/column.cxx31
1 files changed, 8 insertions, 23 deletions
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 97b361ee1801..af373d6eed80 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1194,29 +1194,14 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize )
if (bCountChanged)
{
- SCSIZE nDelCount = maItems.size() - nNewCount;
- ScBaseCell** ppDelCells = new ScBaseCell*[nDelCount];
- SCROW* pDelRows = new SCROW[nDelCount];
- for (i = 0; i < nDelCount; i++)
- {
- ppDelCells[i] = maItems[nNewCount+i].pCell;
- pDelRows[i] = maItems[nNewCount+i].nRow;
- }
- maItems.resize( nNewCount );
-
- for (i = 0; i < nDelCount; i++)
- {
- SCROW nDelRow = pDelRows[i];
- SvtBroadcaster* pBC = GetBroadcaster(nDelRow);
- if (pBC)
- {
- MoveListeners( *pBC, pDelRows[i] - nSize );
- ppDelCells[i]->Delete();
- }
- }
-
- delete [] pDelRows;
- delete [] ppDelCells;
+ // Some cells in the lower part of the cell array have been pushed out
+ // beyond MAXROW. Delete them.
+ std::vector<ColEntry>::iterator itBeg = maItems.begin();
+ std::advance(itBeg, nNewCount);
+ for (std::vector<ColEntry>::iterator it = itBeg; it != maItems.end(); ++it)
+ it->pCell->Delete();
+
+ maItems.erase(itBeg, maItems.end());
}
pDocument->SetAutoCalc( bOldAutoCalc );