summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-11-02 11:01:15 -0400
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-11-04 16:53:40 +0100
commit9a328cc53ccae9a7d0c0770dd7072f18e66592b0 (patch)
tree2d30728073b5bb440aa00c952b769696ada4ed4c /sc
parentf28d71c29b83a0899922c8f32da0fa05458882e2 (diff)
Fix incorrect shifting of cell notes upon cell insertion / deletion.
Steps to reproduce: 1) Insert a comment at D5. 2) Move cursor to C4. 3) Right-click and select Insert. 4) Choose shift cells down. 5) The comment gets shifted down but it shouldn't. The same thing happens when deleting a cell and shifting content. Change-Id: I5a71845cca6abde6b7c940e152e155da26343cef Signed-off-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/table2.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index cd193c142009..afafa10457f8 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -176,6 +176,7 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
for (SCCOL j=nStartCol; j<=nEndCol; j++)
aCol[j].InsertRow( nStartRow, nSize );
+ // Transfer those notes that will get shifted into another container.
ScNotes aNotes(pDocument);
ScNotes::iterator itr = maNotes.begin();
while( itr != maNotes.end() )
@@ -185,13 +186,14 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
ScPostIt* pPostIt = itr->second;
++itr;
- if (nRow >= nStartRow)
+ if (nStartRow <= nRow && nStartCol <= nCol && nCol <= nEndCol)
{
aNotes.insert(nCol, nRow + nSize, pPostIt);
maNotes.ReleaseNote(nCol, nRow);
}
}
+ // Re-insert the shifted notes.
itr = aNotes.begin();
while( itr != aNotes.end() )
{
@@ -256,6 +258,7 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
}
}
+ // Transfer those notes that will get shifted into another container.
ScNotes aNotes(pDocument);
ScNotes::iterator itr = maNotes.begin();
while( itr != maNotes.end() )
@@ -265,18 +268,21 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
ScPostIt* pPostIt = itr->second;
++itr;
- if (nRow >= nStartRow)
+ if (nStartRow <= nRow && nStartCol <= nCol && nCol <= nEndCol)
{
if(nRow - nStartRow > static_cast<SCROW>(nSize))
{
+ // This note will get shifted.
aNotes.insert(nCol, nRow - nSize, pPostIt);
maNotes.ReleaseNote(nCol, nRow);
}
else
+ // Note is in the deleted area. Remove it.
maNotes.erase(nCol, nRow);
}
}
+ // Re-insert the shifted notes.
itr = aNotes.begin();
while( itr != aNotes.end() )
{