sc/source/core/data/table3.cxx | 65 +++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 8 deletions(-)
New commits: commit d7db93f5f4972a94ab3157578e9c8795dc089caa Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Mar 2 04:49:27 2012 +0100 implement SwapCol and SwapRow for note handling again diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index db0c249..da43fbc 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -580,14 +580,39 @@ void ScTable::SwapCol(SCCOL nCol1, SCCOL nCol2) } } } - for (ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr) + + ScNotes aNoteMap(pDocument); + ScNotes::iterator itr = maNotes.begin(); + while(itr != maNotes.end()) { - if (itr->first.first == nCol1 || itr->first.first == nCol2) + SCCOL nCol = itr->first.first; + SCROW nRow = itr->first.second; + ScPostIt* pPostIt = itr->second; + ++itr; + + if (nCol == nCol1) { - //only then we need to swap - //TODO: implement it + aNoteMap.insert(nCol, nRow, pPostIt); + maNotes.ReleaseNote(nCol2, nRow); + } + else if (nCol == nCol2) + { + aNoteMap.insert(nCol, nRow, pPostIt); + maNotes.ReleaseNote(nCol1, nRow); + } } + + itr = aNoteMap.begin(); + { + //we can here assume that there is no note in the target location + SCCOL nCol = itr->first.first; + SCROW nRow = itr->first.second; + ScPostIt* pPostIt = itr->second; + + maNotes.insert(nCol, nRow, pPostIt); + aNoteMap.ReleaseNote(nCol, nRow); + } } void ScTable::SwapRow(SCROW nRow1, SCROW nRow2) @@ -619,14 +644,38 @@ void ScTable::SwapRow(SCROW nRow1, SCROW nRow2) SetRowFiltered(nRow2, nRow2, bRow1Filtered); } - for (ScNotes::iterator itr = maNotes.begin(); itr != maNotes.end(); ++itr) + ScNotes aNoteMap(pDocument); + ScNotes::iterator itr = maNotes.begin(); + while(itr != maNotes.end()) { - if (itr->first.second == nRow1 || itr->first.second == nRow2) + SCCOL nCol = itr->first.first; + SCROW nRow = itr->first.second; + ScPostIt* pPostIt = itr->second; + ++itr; + + if (nRow == nRow1) + { + aNoteMap.insert(nCol, nRow, pPostIt); + maNotes.ReleaseNote(nCol, nRow2); + } + else if (nRow == nRow2) { - //only then we need to swap - //TODO:implement it + aNoteMap.insert(nCol, nRow, pPostIt); + maNotes.ReleaseNote(nCol, nRow1); + } } + + itr = aNoteMap.begin(); + { + //we can here assume that there is no note in the target location + SCCOL nCol = itr->first.first; + SCROW nRow = itr->first.second; + ScPostIt* pPostIt = itr->second; + + maNotes.insert(nCol, nRow, pPostIt); + aNoteMap.ReleaseNote(nCol, nRow); + } } short ScTable::Compare(SCCOLROW nIndex1, SCCOLROW nIndex2) _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits