diff options
author | Eike Rathke <erack@redhat.com> | 2017-02-21 19:03:32 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-02-21 19:08:22 +0100 |
commit | b1abc8ef50ccea87f1bf03d2328354340120251f (patch) | |
tree | 9e63e48f18da2c124a23d58992d4feb288ae7d84 /sc | |
parent | 0d0102a8000202abb7c5a094da3221589adfe53e (diff) |
unit test for copying note from clipboard after closing orig doc, tdf#104967
Change-Id: I165363eecbb37561d8265638415e0f5f069878d7
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 2a9dc2175449..e6d9718a69af 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5343,6 +5343,42 @@ void Test::testNoteLifeCycle() const SdrCaptionObj* pUndoCaptionB4 = pUndoNoteB4->GetCaption(); CPPUNIT_ASSERT_MESSAGE("Captions not identical after Merge Undo.", pCaptionB4 == pUndoCaptionB4); + + // In a second document copy a note from B5 to clipboard, close the + // document and then paste the note into this document. + { + ScDocShellRef xDocSh2; + getNewDocShell(xDocSh2); + ScDocument* pDoc2 = &xDocSh2->GetDocument(); + pDoc2->InsertTab(0, "OtherSheet1"); + pDoc2->InitDrawLayer(xDocSh2.get()); + + ScAddress aPosB5(1,4,0); + ScPostIt* pOtherNoteB5 = pDoc2->GetOrCreateNote(aPosB5); + CPPUNIT_ASSERT_MESSAGE("Failed to insert cell comment at B5.", pOtherNoteB5); + const SdrCaptionObj* pOtherCaptionB5 = pOtherNoteB5->GetOrCreateCaption(aPosB5); + CPPUNIT_ASSERT_MESSAGE("No caption at B5.", pOtherCaptionB5); + + ScDocument aClipDoc2(SCDOCMODE_CLIP); + copyToClip( pDoc2, aPosB5, &aClipDoc2); + + // There's no ScTransferObject involved in the "fake" clipboard copy + // and ScDocument dtor asking IsClipboardSource() gets no, so emulate + // the part that normally is reponsible for forgetting the caption + // objects. Ugly. + aClipDoc2.ForgetNoteCaptions( ScRangeList( ScRange( 0,0,0, MAXCOL, MAXROW, aClipDoc2.GetTableCount()-1)), true); + + pDoc2->DeleteTab(0); + closeDocShell(xDocSh2); + + pasteFromClip( m_pDoc, aPosB5, &aClipDoc2); // should not crash ... tdf#104967 + ScPostIt* pNoteB5 = m_pDoc->GetNote(aPosB5); + CPPUNIT_ASSERT_MESSAGE("Failed to paste cell comment at B5.", pNoteB5); + const SdrCaptionObj* pCaptionB5 = pNoteB5->GetCaption(); + CPPUNIT_ASSERT_MESSAGE("No caption at pasted B5.", pCaptionB5); + CPPUNIT_ASSERT_MESSAGE("Captions not different after Paste.", pCaptionB5 != pOtherCaptionB5); + } + m_pDoc->DeleteTab(0); } |