diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-02 11:01:15 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-02 11:04:18 -0400 |
commit | e8487c8a3f3ece74143928352e1e8a7dfb72d424 (patch) | |
tree | b94da75de036db31cc5b5fa8c1d527f383dbcb13 /sc | |
parent | e127cb937698938e233e7b469a10e35585ddb88f (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
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/table2.cxx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 193e7f086e05..8bfb0e607f21 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -171,6 +171,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() ) @@ -180,13 +181,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() ) { @@ -247,6 +249,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() ) @@ -256,18 +259,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() ) { |