diff options
author | Eike Rathke <erack@redhat.com> | 2017-02-21 14:37:59 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-02-21 14:38:32 +0100 |
commit | 45fd903d5ed6007271485ce3fa7c2e78bdc286f8 (patch) | |
tree | 48ec8c09253fdaf6c8e9e6417aa7ddff0d09908b | |
parent | 7bc1c438008517cc9d475a21cdc4a06c6d25eb8f (diff) |
unit test for cell merge with note caption undo, tdf#105667
Change-Id: Ib49e0f35aa554025634c8496fbb80d87dbc86d89
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 4ce4c7c93146..f09a0a4e12dd 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5311,6 +5311,27 @@ void Test::testNoteLifeCycle() pOrigCaption = pOrigNote->GetOrCreateCaption(aOrigPos); CPPUNIT_ASSERT_MESSAGE("Captions identical after move undo.", pOrigCaption != pMoveCaption); + + // Create a note at B4, merge B4 and B5 with ScUndoMerge, and Undo. + + ScAddress aPosB4(1,3,0); + ScPostIt* pNoteB4 = m_pDoc->GetOrCreateNote(aPosB4); + CPPUNIT_ASSERT_MESSAGE("Failed to insert cell comment at B4.", pNoteB4); + const SdrCaptionObj* pCaptionB4 = pNoteB4->GetOrCreateCaption(aPosB4); + ScCellMergeOption aCellMergeOption(1,3,2,3); + rDocFunc.MergeCells( aCellMergeOption, true /*bContents*/, bRecord, bApi, false /*bEmptyMergedCells*/ ); + + SfxUndoManager* pMergeUndoManager = m_pDoc->GetUndoManager(); + CPPUNIT_ASSERT(pMergeUndoManager); + pMergeUndoManager->Undo(); // this should not crash ... tdf#105667 + + // Undo contained the original caption object pointer which was still alive + // at B4 after the merge and not cloned nor recreated during Undo. + ScPostIt* pUndoNoteB4 = m_pDoc->GetOrCreateNote(aPosB4); + CPPUNIT_ASSERT_MESSAGE("No cell comment at B4 after Undo.", pUndoNoteB4); + const SdrCaptionObj* pUndoCaptionB4 = pUndoNoteB4->GetOrCreateCaption(aPosB4); + CPPUNIT_ASSERT_MESSAGE("Captions not identical after Merge Undo.", pCaptionB4 == pUndoCaptionB4); + m_pDoc->DeleteTab(0); } |