fix some iterator misuse in the new notes handling

This commit is contained in:
Markus Mohrhard
2012-03-01 11:07:16 +01:00
parent 373394c887
commit 58272b9831

View File

@@ -175,18 +175,31 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
aCol[j].InsertRow( nStartRow, nSize ); aCol[j].InsertRow( nStartRow, nSize );
ScNotes aNotes(pDocument); ScNotes aNotes(pDocument);
for ( ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr) ScNotes::iterator itr = maNotes.begin();
while( itr != maNotes.end() )
{ {
if (itr->first.second >= nStartRow) SCCOL nCol = itr->first.first;
SCROW nRow = itr->first.second;
ScPostIt* pPostIt = itr->second;
++itr;
if (nCol >= nStartRow)
{ {
aNotes.insert(itr->first.first, itr->first.second + nSize, itr->second); aNotes.insert(nCol, nRow + nSize, pPostIt);
maNotes.ReleaseNote(itr->first.first, itr->first.second); maNotes.ReleaseNote(nCol, nRow);
} }
} }
for ( ScNotes::iterator itr = aNotes.begin(); itr != aNotes.end(); ++itr)
itr = aNotes.begin();
while( itr != aNotes.end() )
{ {
maNotes.insert( itr->first.first, itr->first.second, itr->second); SCCOL nCol = itr->first.first;
aNotes.ReleaseNote(itr->first.first, itr->first.second); SCROW nRow = itr->first.second;
ScPostIt* pPostIt = itr->second;
++itr;
maNotes.insert( nCol, nRow, pPostIt);
aNotes.ReleaseNote( nCol, nRow);
} }
DecRecalcLevel( false ); DecRecalcLevel( false );
@@ -242,18 +255,31 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
} }
ScNotes aNotes(pDocument); ScNotes aNotes(pDocument);
for ( ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr) ScNotes::iterator itr = maNotes.begin();
while( itr != maNotes.end() )
{ {
if (itr->first.second >= nStartRow) SCCOL nCol = itr->first.first;
SCROW nRow = itr->first.second;
ScPostIt* pPostIt = itr->second;
++itr;
if (nCol >= nStartRow)
{ {
aNotes.insert(itr->first.first, itr->first.second - nSize, itr->second); aNotes.insert(nCol, nRow - nSize, pPostIt);
maNotes.ReleaseNote(itr->first.first, itr->first.second); maNotes.ReleaseNote(nCol, nRow);
} }
} }
for ( ScNotes::iterator itr = aNotes.begin(); itr != aNotes.end(); ++itr)
itr = aNotes.begin();
while( itr != aNotes.end() )
{ {
maNotes.insert( itr->first.first, itr->first.second, itr->second); SCCOL nCol = itr->first.first;
aNotes.ReleaseNote(itr->first.first, itr->first.second); SCROW nRow = itr->first.second;
ScPostIt* pPostIt = itr->second;
++itr;
maNotes.insert( nCol, nRow, pPostIt);
aNotes.ReleaseNote( nCol, nRow);
} }
{ // scope for bulk broadcast { // scope for bulk broadcast
@@ -339,20 +365,31 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
} }
ScNotes aNotes(pDocument); ScNotes aNotes(pDocument);
for ( ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr) ScNotes::iterator itr = maNotes.begin();
while( itr != maNotes.end() )
{ {
if (itr->first.first > nStartCol) SCCOL nCol = itr->first.first;
SCROW nRow = itr->first.second;
ScPostIt* pPostIt = itr->second;
++itr;
if (nCol >= nStartRow)
{ {
aNotes.insert(itr->first.first + nSize, itr->first.second, itr->second); aNotes.insert(nCol + nSize, nRow, pPostIt);
maNotes.ReleaseNote(itr->first.first, itr->first.second); maNotes.ReleaseNote(nCol, nRow);
} }
else
aNotes.insert( itr->first.first, itr->first.second, itr->second);
} }
for ( ScNotes::iterator itr = aNotes.begin(); itr != aNotes.end(); ++itr)
itr = aNotes.begin();
while( itr != aNotes.end() )
{ {
maNotes.insert( itr->first.first, itr->first.second, itr->second); SCCOL nCol = itr->first.first;
aNotes.ReleaseNote(itr->first.first, itr->first.second); SCROW nRow = itr->first.second;
ScPostIt* pPostIt = itr->second;
++itr;
maNotes.insert( nCol, nRow, pPostIt);
aNotes.ReleaseNote( nCol, nRow);
} }
if (nStartCol>0) // copy old attributes if (nStartCol>0) // copy old attributes
@@ -437,20 +474,31 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
} }
ScNotes aNotes(pDocument); ScNotes aNotes(pDocument);
for ( ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr) ScNotes::iterator itr = maNotes.begin();
while( itr != maNotes.end() )
{ {
if (itr->first.first > nStartCol) SCCOL nCol = itr->first.first;
SCROW nRow = itr->first.second;
ScPostIt* pPostIt = itr->second;
++itr;
if (nCol >= nStartRow)
{ {
aNotes.insert(itr->first.first - nSize, itr->first.second, itr->second); aNotes.insert(nCol - nSize, nRow, pPostIt);
maNotes.ReleaseNote(itr->first.first, itr->first.second); maNotes.ReleaseNote(nCol, nRow);
} }
else
aNotes.insert( itr->first.first, itr->first.second, itr->second);
} }
for ( ScNotes::iterator itr = aNotes.begin(); itr != aNotes.end(); ++itr)
itr = aNotes.begin();
while( itr != aNotes.end() )
{ {
maNotes.insert( itr->first.first, itr->first.second, itr->second); SCCOL nCol = itr->first.first;
aNotes.ReleaseNote(itr->first.first, itr->first.second); SCROW nRow = itr->first.second;
ScPostIt* pPostIt = itr->second;
++itr;
maNotes.insert( nCol, nRow, pPostIt);
aNotes.ReleaseNote( nCol, nRow);
} }
DecRecalcLevel(); DecRecalcLevel();