Kaydet (Commit) 71cd1ca5 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

fdo#77379: Write test for this.

Change-Id: Iccc0b499abae90f5b780aebab17ff6315b5690ec
üst 49752842
......@@ -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();
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment