summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-05-09 13:50:31 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-05-09 14:06:11 -0400
commit71cd1ca57faf423fb607fab64914719238bc1e4f (patch)
treea9446c5519cbafce4e2a662a0f8cbc4835a0caa5
parent497528425499bca634c13ed5eb834559c86d948f (diff)
fdo#77379: Write test for this.
Change-Id: Iccc0b499abae90f5b780aebab17ff6315b5690ec
-rw-r--r--sc/qa/unit/ucalc.cxx55
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 57 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 1ca19b8f5457..4cf444f75255 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5400,6 +5400,61 @@ void Test::testNoteLifeCycle()
m_pDoc->DeleteTab(0);
}
+void Test::testNoteCopyPaste()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ // We need a drawing layer in order to create caption objects.
+ m_pDoc->InitDrawLayer(&getDocShell());
+
+ // Insert in B2 a text and cell comment.
+ ScAddress aPos(1,1,0);
+ m_pDoc->SetString(aPos, "Text");
+ ScPostIt* pNote = m_pDoc->GetOrCreateNote(aPos);
+ CPPUNIT_ASSERT(pNote);
+ pNote->SetText(aPos, "Note1");
+
+ // Insert in B4 a number and cell comment.
+ aPos.SetRow(3);
+ m_pDoc->SetValue(aPos, 1.1);
+ pNote = m_pDoc->GetOrCreateNote(aPos);
+ CPPUNIT_ASSERT(pNote);
+ pNote->SetText(aPos, "Note2");
+
+ // Copy B2:B4 to clipboard.
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ ScRange aCopyRange(1,1,0,1,3,0);
+ ScDocument aClipDoc(SCDOCMODE_CLIP);
+ aClipDoc.ResetClip(m_pDoc, &aMark);
+ ScClipParam aClipParam(aCopyRange, false);
+ m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false, false, true, false);
+
+ // Make sure the notes are in the clipboard.
+ pNote = aClipDoc.GetNote(ScAddress(1,1,0));
+ CPPUNIT_ASSERT(pNote);
+ CPPUNIT_ASSERT_EQUAL(OUString("Note1"), pNote->GetText());
+
+ pNote = aClipDoc.GetNote(ScAddress(1,3,0));
+ CPPUNIT_ASSERT(pNote);
+ CPPUNIT_ASSERT_EQUAL(OUString("Note2"), pNote->GetText());
+
+ // Paste to B6:B8 but only cell notes.
+ ScRange aDestRange(1,5,0,1,7,0);
+ m_pDoc->CopyFromClip(aDestRange, aMark, IDF_NOTE, NULL, &aClipDoc);
+
+ // Make sure the notes are there.
+ pNote = m_pDoc->GetNote(ScAddress(1,5,0));
+ CPPUNIT_ASSERT(pNote);
+ CPPUNIT_ASSERT_EQUAL(OUString("Note1"), pNote->GetText());
+
+ pNote = m_pDoc->GetNote(ScAddress(1,7,0));
+ CPPUNIT_ASSERT(pNote);
+ CPPUNIT_ASSERT_EQUAL(OUString("Note2"), pNote->GetText());
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testAreasWithNotes()
{
ScDocument* pDoc = getDocShell().GetDocument();
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index dbe84e71b28d..76c74cc06a09 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -341,6 +341,7 @@ public:
void testNoteDeleteRow();
void testNoteDeleteCol();
void testNoteLifeCycle();
+ void testNoteCopyPaste();
void testAreasWithNotes();
void testAnchoredRotatedShape();
void testCellTextWidth();
@@ -499,6 +500,7 @@ public:
CPPUNIT_TEST(testNoteDeleteRow);
CPPUNIT_TEST(testNoteDeleteCol);
CPPUNIT_TEST(testNoteLifeCycle);
+ CPPUNIT_TEST(testNoteCopyPaste);
CPPUNIT_TEST(testAreasWithNotes);
CPPUNIT_TEST(testAnchoredRotatedShape);
CPPUNIT_TEST(testCellTextWidth);