sc/source/core/data/column.cxx | 128 +++++++--------------------------------- sc/source/core/data/column3.cxx | 5 - 2 files changed, 27 insertions(+), 106 deletions(-)
New commits: commit 9c085920fdaf3b9dd7769ec2816d5caa6d44a818 Author: Laurent Godard <lgodard.li...@laposte.net> Date: Wed Sep 18 16:31:11 2013 +0200 copy a sheet now transfers notes + minor changes Change-Id: Ib7cff176f5b4fe12a8edb4ccc5cb65acf6054338 diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 2d67b27..4cdcf9a 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1603,10 +1603,6 @@ void ScColumn::CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDes bSet = false; } - // copy notes even on empty cells -// ScPostIt* pPostIt = maCellNotes.get<ScPostIt*>(nSrcRow); -// rDestCol.maCellNotes.set(nDestRow, pPostIt); - if (bSet) { rDestCol.maCellTextAttrs.set(nDestRow, maCellTextAttrs.get<sc::CellTextAttr>(nSrcRow)); @@ -1856,6 +1852,27 @@ class CopyByCloneHandler } } + void duplicateNotes(SCROW nStartRow, size_t nOffset, size_t nDataSize ) // TODO : notes suboptimal + { + sc::CellNoteStoreType maSrcCellNotes = mrSrcCol.GetCellNoteStore(); + + for (SCROW nRow = nStartRow; nRow < nStartRow + nDataSize; ++nRow) + { + ScPostIt* pSrcNote = maSrcCellNotes.get<ScPostIt*>(nRow); + ScPostIt* pClonedNote; + if (pSrcNote) + { + ScAddress aDestPos = ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab()); + pClonedNote = pSrcNote->Clone( ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab() ), + mrDestCol.GetDoc(), + aDestPos, true ); + mrDestCol.GetDoc().ReleaseNote(aDestPos); + mrDestCol.GetDoc().SetNote(aDestPos, pClonedNote); + } + } + + } + public: CopyByCloneHandler(const ScColumn& rSrcCol, ScColumn& rDestCol, sc::ColumnBlockPosition* pDestPos, sal_uInt16 nCopyFlags) : mrSrcCol(rSrcCol), mrDestCol(rDestCol), mpDestPos(pDestPos), mnCopyFlags(nCopyFlags) @@ -1874,6 +1891,9 @@ public: { size_t nRow = aNode.position + nOffset; + if (mnCopyFlags & (IDF_NOTE|IDF_ADDNOTES)) + duplicateNotes(nRow, nOffset, nDataSize ); + switch (aNode.type) { case sc::element_type_numeric: @@ -1894,31 +1914,6 @@ public: maDestPos.miCellPos = mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, *it); setDefaultAttrToDest(nRow); - - // TODO : notes - copy notes - bool mbCopyNotes = true; - if (mbCopyNotes) - { - //maDestPos.miCellNotePos = mrDestCol.GetCellNoteStore().set(maDestPos.miCellNotePos, nTopRow, it, itEnd); - sc::CellNoteStoreType maSrcCellNotes = mrSrcCol.GetCellNoteStore(); - sc::CellNoteStoreType::position_type aPosNotes = maSrcCellNotes.position(nRow); - sc::CellNoteStoreType::iterator itNotes = aPosNotes.first; - if (itNotes->type == sc::element_type_cellnote) - { - ScPostIt* pSrcNote = maSrcCellNotes.get<ScPostIt*>(nRow); - if (pSrcNote) - { - ScAddress aDestPos = ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab()); - ScPostIt* pClonedNote = pSrcNote->Clone( ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab() ), - mrDestCol.GetDoc(), - aDestPos, true ); - mrDestCol.GetDoc().ReleaseNote(aDestPos); - mrDestCol.GetDoc().SetNote(aDestPos, pClonedNote); - } - } - } - - } } break; @@ -1949,30 +1944,6 @@ public: mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, rStr); setDefaultAttrToDest(nRow); } - - // TODO : notes - copy notes - bool mbCopyNotes = true; - if (mbCopyNotes) - { - //maDestPos.miCellNotePos = mrDestCol.GetCellNoteStore().set(maDestPos.miCellNotePos, nTopRow, it, itEnd); - sc::CellNoteStoreType maSrcCellNotes = mrSrcCol.GetCellNoteStore(); - sc::CellNoteStoreType::position_type aPosNotes = maSrcCellNotes.position(nRow); - sc::CellNoteStoreType::iterator itNotes = aPosNotes.first; - if (itNotes->type == sc::element_type_cellnote) - { - ScPostIt* pSrcNote = maSrcCellNotes.get<ScPostIt*>(nRow); - if (pSrcNote) - { - ScAddress aDestPos = ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab()); - ScPostIt* pClonedNote = pSrcNote->Clone( ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab() ), - mrDestCol.GetDoc(), - aDestPos, true ); - mrDestCol.GetDoc().ReleaseNote(aDestPos); - mrDestCol.GetDoc().SetNote(aDestPos, pClonedNote); - } - } - } - } } break; @@ -1989,38 +1960,12 @@ public: std::vector<EditTextObject*> aCloned; aCloned.reserve(nDataSize); for (; it != itEnd; ++it, ++nRow) - { aCloned.push_back(ScEditUtil::Clone(**it, mrDestCol.GetDoc())); - // TODO : notes - copy notes - bool mbCopyNotes = true; - if (mbCopyNotes) - { - //maDestPos.miCellNotePos = mrDestCol.GetCellNoteStore().set(maDestPos.miCellNotePos, nTopRow, it, itEnd); - sc::CellNoteStoreType maSrcCellNotes = mrSrcCol.GetCellNoteStore(); - sc::CellNoteStoreType::position_type aPosNotes = maSrcCellNotes.position(nRow); - sc::CellNoteStoreType::iterator itNotes = aPosNotes.first; - if (itNotes->type == sc::element_type_cellnote) - { - ScPostIt* pSrcNote = maSrcCellNotes.get<ScPostIt*>(nRow); - if (pSrcNote) - { - ScAddress aDestPos = ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab()); - ScPostIt* pClonedNote = pSrcNote->Clone( ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab() ), - mrDestCol.GetDoc(), - aDestPos, true ); - mrDestCol.GetDoc().ReleaseNote(aDestPos); - mrDestCol.GetDoc().SetNote(aDestPos, pClonedNote); - } - } - } - } maDestPos.miCellPos = mrDestCol.GetCellStore().set( maDestPos.miCellPos, nRow, aCloned.begin(), aCloned.end()); setDefaultAttrsToDest(nRow, nDataSize); - - } break; case sc::element_type_formula: @@ -2031,35 +1976,10 @@ public: std::advance(itEnd, nDataSize); for (; it != itEnd; ++it, ++nRow) - { cloneFormulaCell(nRow, const_cast<ScFormulaCell&>(**it)); - // TODO : notes - copy notes - bool mbCopyNotes = true; - if (mbCopyNotes) - { - //maDestPos.miCellNotePos = mrDestCol.GetCellNoteStore().set(maDestPos.miCellNotePos, nTopRow, it, itEnd); - sc::CellNoteStoreType maSrcCellNotes = mrSrcCol.GetCellNoteStore(); - sc::CellNoteStoreType::position_type aPosNotes = maSrcCellNotes.position(nRow); - sc::CellNoteStoreType::iterator itNotes = aPosNotes.first; - if (itNotes->type == sc::element_type_cellnote) - { - ScPostIt* pSrcNote = maSrcCellNotes.get<ScPostIt*>(nRow); - if (pSrcNote) - { - ScAddress aDestPos = ScAddress(mrDestCol.GetCol(), nRow, mrDestCol.GetTab()); - ScPostIt* pClonedNote = pSrcNote->Clone( ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab() ), - mrDestCol.GetDoc(), - aDestPos, true ); - mrDestCol.GetDoc().ReleaseNote(aDestPos); - mrDestCol.GetDoc().SetNote(aDestPos, pClonedNote); - } - } - } - } } break; default: - // TODO : notes - copy notes from empty cells ; } } diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 4112ed5..31a4ff3 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -712,14 +712,15 @@ class CopyCellsFromClipHandler for (; itNote != itNoteEnd; ++itNote, ++nRow) { ScPostIt* pSrcNote = maSrcCellNotes.get<ScPostIt*>(nRow); + ScPostIt* pClonedNote; if (pSrcNote) { ScAddress aDestPos = ScAddress(mrDestCol.GetCol(), nRow+mnRowOffset, mrDestCol.GetTab()); - ScPostIt* pClonedNote = pSrcNote->Clone( ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab() ), + pClonedNote = pSrcNote->Clone( ScAddress(mrSrcCol.GetCol(), nRow, mrSrcCol.GetTab() ), mrDestCol.GetDoc(), aDestPos, true ); - aNotes.push_back(pClonedNote); } + aNotes.push_back(pClonedNote); } maDestBlockPos.miCellNotePos = mrDestCol.GetCellNoteStore().set( _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits