sc/inc/clipcontext.hxx | 5 +++++ sc/source/core/data/clipcontext.cxx | 12 +++++++++++- sc/source/core/data/column4.cxx | 23 +++++++++++++++++++++++ sc/source/core/data/document10.cxx | 19 +++++++++++-------- 4 files changed, 50 insertions(+), 9 deletions(-)
New commits: commit c0deb50f8f7feecb7adb049e8253c9566232abde Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Mon Jan 27 14:26:23 2014 -0500 Handle note instances during copy-n-pasting of single cell. Change-Id: Ib258556414fd94b5156b65777478a8fd37abfd9e diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx index c693c7f..77abcf8 100644 --- a/sc/inc/clipcontext.hxx +++ b/sc/inc/clipcontext.hxx @@ -21,6 +21,7 @@ class ScDocument; class ScColumn; class ScPatternAttr; +class ScPostIt; namespace sc { @@ -49,6 +50,7 @@ class CopyFromClipContext : public ClipContextBase sal_uInt16 mnInsertFlag; ScCellValue maSingleCell; const ScPatternAttr* mpSinglePattern; + const ScPostIt* mpSingleNote; bool mbAsLink:1; bool mbSkipAttrForEmptyCells:1; bool mbCloneNotes:1; @@ -76,6 +78,9 @@ public: const ScPatternAttr* getSingleCellPattern() const; void setSingleCellPattern( const ScPatternAttr* pAttr ); + const ScPostIt* getSingleCellNote() const; + void setSingleCellNote( const ScPostIt* pNote ); + bool isAsLink() const; bool isSkipAttrForEmptyCells() const; bool isCloneNotes() const; diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx index 764d66f..35cde4e 100644 --- a/sc/source/core/data/clipcontext.cxx +++ b/sc/source/core/data/clipcontext.cxx @@ -33,7 +33,7 @@ CopyFromClipContext::CopyFromClipContext(ScDocument& rDoc, ClipContextBase(rDoc), mnTabStart(-1), mnTabEnd(-1), mpRefUndoDoc(pRefUndoDoc), mpClipDoc(pClipDoc), mnInsertFlag(nInsertFlag), - mpSinglePattern(NULL), + mpSinglePattern(NULL), mpSingleNote(NULL), mbAsLink(bAsLink), mbSkipAttrForEmptyCells(bSkipAttrForEmptyCells), mbCloneNotes (mnInsertFlag & (IDF_NOTE|IDF_ADDNOTES)) { @@ -89,6 +89,16 @@ void CopyFromClipContext::setSingleCellPattern( const ScPatternAttr* pAttr ) mpSinglePattern = pAttr; } +const ScPostIt* CopyFromClipContext::getSingleCellNote() const +{ + return mpSingleNote; +} + +void CopyFromClipContext::setSingleCellNote( const ScPostIt* pNote ) +{ + mpSingleNote = pNote; +} + bool CopyFromClipContext::isAsLink() const { return mbAsLink; diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 48c3826..b70e52d 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -9,6 +9,7 @@ #include <column.hxx> #include <clipcontext.hxx> +#include <clipparam.hxx> #include <cellvalue.hxx> #include <attarray.hxx> #include <document.hxx> @@ -119,6 +120,28 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, ; } } + + const ScPostIt* pNote = rCxt.getSingleCellNote(); + if (pNote && (nFlags & (IDF_NOTE | IDF_ADDNOTES)) != 0) + { + // Duplicate the cell note over the whole pasted range. + + ScDocument* pClipDoc = rCxt.getClipDoc(); + const ScAddress& rSrcPos = pClipDoc->GetClipParam().getWholeRange().aStart; + std::vector<ScPostIt*> aNotes; + ScAddress aDestPos(nCol, nRow1, nTab); + aNotes.reserve(nDestSize); + for (size_t i = 0; i < nDestSize; ++i) + { + bool bCloneCaption = (nFlags & IDF_NOCAPTIONS) == 0; + aNotes.push_back(pNote->Clone(rSrcPos, *pDocument, aDestPos, bCloneCaption)); + aDestPos.IncRow(); + } + + pBlockPos->miCellNotePos = + maCellNotes.set( + pBlockPos->miCellNotePos, nRow1, aNotes.begin(), aNotes.end()); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx index 1178ce70..ee3e35d 100644 --- a/sc/source/core/data/document10.cxx +++ b/sc/source/core/data/document10.cxx @@ -77,7 +77,7 @@ bool ScDocument::CopyOneCellFromClip( bool bPaste = rCxt.isDateCell(pSrcTab->aCol[aSrcPos.Col()], aSrcPos.Row()) ? bDateTime : bNumeric; if (!bPaste) // Don't paste this. - return true; + rSrcCell.clear(); } break; case CELLTYPE_STRING: @@ -85,7 +85,7 @@ bool ScDocument::CopyOneCellFromClip( { if (!bString) // Skip pasting. - return true; + rSrcCell.clear(); } break; case CELLTYPE_FORMULA: @@ -113,14 +113,14 @@ bool ScDocument::CopyOneCellFromClip( // error codes are cloned with values if (!bNumeric) // Error code is treated as numeric value. Don't paste it. - return true; + rSrcCell.clear(); } else if (rSrcCell.mpFormula->IsValue()) { bool bPaste = rCxt.isDateCell(pSrcTab->aCol[aSrcPos.Col()], aSrcPos.Row()) ? bDateTime : bNumeric; if (!bPaste) // Don't paste this. - return true; + rSrcCell.clear(); // Turn this into a numeric cell. rSrcCell.set(rSrcCell.mpFormula->GetValue()); @@ -130,7 +130,7 @@ bool ScDocument::CopyOneCellFromClip( svl::SharedString aStr = rSrcCell.mpFormula->GetString(); if (aStr.isEmpty()) // do not clone empty string - return true; + rSrcCell.clear(); // Turn this into a string or edit cell. if (rSrcCell.mpFormula->IsMultilineResult()) @@ -147,17 +147,20 @@ bool ScDocument::CopyOneCellFromClip( rSrcCell.set(rSrcCell.mpFormula->GetString()); } else - // We don't want to paste this. Bail out. - return true; + // We don't want to paste this. + rSrcCell.clear(); } break; case CELLTYPE_NONE: default: // There is nothing to paste. - return true; + rSrcCell.clear(); } } + if ((rCxt.getInsertFlag() & (IDF_NOTE | IDF_ADDNOTES)) != 0) + rCxt.setSingleCellNote(pClipDoc->GetNote(aSrcPos)); + // All good. Proceed with the pasting. SCTAB nTabEnd = rCxt.getTabEnd(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits