summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sc/inc/clipcontext.hxx5
-rw-r--r--sc/source/core/data/clipcontext.cxx12
-rw-r--r--sc/source/core/data/column4.cxx23
-rw-r--r--sc/source/core/data/document10.cxx19
4 files changed, 50 insertions, 9 deletions
diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index c693c7f533a7..77abcf834618 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 764d66f6ccb0..35cde4e18161 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 48c38267f0d0..b70e52d1920f 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 1178ce703155..ee3e35d543a6 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();