diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-02 13:27:31 -0400 |
---|---|---|
committer | Petr Mladek <pmladek@suse.cz> | 2012-11-05 20:24:51 +0100 |
commit | 9736516e005f348554873b6310292daa05c0e328 (patch) | |
tree | e172f279351ce67b72ec0918c0ecd94d73ecdc21 /sc | |
parent | 11aa16b341dcb1022a0d86a8923a10a7ce12868c (diff) |
Correctly handle cell note shifting when immediate row/column is deleted.
Currently, having a note e.g. at D5, and deleting cell D4 and shifting
the cells below upward will remove the note at D5. But the correct behavior
is to shift that note up to D4. This change fixes it.
Change-Id: Ia37f1ce67a003deab424f2b805a2ce333fc10ed4
(cherry picked from commit d3344dd85ee31b195a3709d16e734245e1d0a4b6)
Signed-off-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/table2.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index afafa10457f8..e8df882e2af1 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -270,7 +270,8 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE if (nStartRow <= nRow && nStartCol <= nCol && nCol <= nEndCol) { - if(nRow - nStartRow > static_cast<SCROW>(nSize)) + SCROW nEndRow = nStartRow + nSize - 1; // last row of deleted region + if (nEndRow < nRow) { // This note will get shifted. aNotes.insert(nCol, nRow - nSize, pPostIt); @@ -377,6 +378,7 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE aCol[MAXCOL - nSize - i].MoveTo(nStartRow, nEndRow, aCol[MAXCOL - i]); } + // Transfer those notes that will get shifted into another container. ScNotes aNotes(pDocument); ScNotes::iterator itr = maNotes.begin(); while( itr != maNotes.end() ) @@ -386,13 +388,14 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE ScPostIt* pPostIt = itr->second; ++itr; - if (nCol >= nStartCol) + if (nStartCol <= nCol && nStartRow <= nRow && nRow <= nEndRow) { aNotes.insert(nCol + nSize, nRow, pPostIt); maNotes.ReleaseNote(nCol, nRow); } } + // Re-insert the shifted notes. itr = aNotes.begin(); while( itr != aNotes.end() ) { @@ -486,6 +489,7 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE aCol[nStartCol + nSize + i].MoveTo(nStartRow, nEndRow, aCol[nStartCol + i]); } + // Transfer those notes that will get shifted into another container. ScNotes aNotes(pDocument); ScNotes::iterator itr = maNotes.begin(); while( itr != maNotes.end() ) @@ -495,18 +499,22 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE ScPostIt* pPostIt = itr->second; ++itr; - if (nCol >= nStartCol) + if (nStartCol <= nCol && nStartRow <= nRow && nRow <= nEndRow) { - if(nCol - nStartCol > static_cast<SCCOL>(nSize)) + SCCOL nEndCol = nStartCol + nSize - 1; + if (nEndCol < nCol) { + // This note will get shifted. aNotes.insert(nCol - nSize, nRow, pPostIt); maNotes.ReleaseNote(nCol, nRow); } else + // The note is in the deleted region. Remove it. maNotes.erase(nCol, nRow); } } + // Re-insert the shifted notes. itr = aNotes.begin(); while( itr != aNotes.end() ) { |