summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-11-02 11:01:15 -0400
committerPetr Mladek <pmladek@suse.cz>2012-11-05 20:24:26 +0100
commit11aa16b341dcb1022a0d86a8923a10a7ce12868c (patch)
treea0b24563efe86271e68629fadc12e924e49cb4ed /sc/source
parentb450586b83922578beb58f790fdc0f0a66d761d2 (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/source')
-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() )
{