summaryrefslogtreecommitdiff
path: root/sc/source/core/data/table2.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-11-02 13:27:31 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-11-02 13:42:12 -0400
commitd3344dd85ee31b195a3709d16e734245e1d0a4b6 (patch)
treef5e1738415bb144a816ab38c2c362e7f9b7b575e /sc/source/core/data/table2.cxx
parent6bac39f309e11a515a2b2ecdf43a4b49ccd53502 (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
Diffstat (limited to 'sc/source/core/data/table2.cxx')
-rw-r--r--sc/source/core/data/table2.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 8bfb0e607f21..69e2f0243a55 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -261,7 +261,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);
@@ -365,6 +366,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() )
@@ -374,13 +376,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() )
{
@@ -471,6 +474,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() )
@@ -480,18 +484,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() )
{