summaryrefslogtreecommitdiff
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-02-21 14:37:59 +0100
committerHenry Castro <hcastro@collabora.com>2017-05-03 11:12:15 -0400
commite6c0fbc9e98dbef3fca9f8d37e097b1f4de7ed6d (patch)
treefebe1cb3ea2cbe069d5a81d59c03dd5c425235ec /sc/qa/unit
parent98722be9d6b1940174c309a08e41944b0ef908e4 (diff)
unit test for cell merge with note caption undo, tdf#105667
Change-Id: Ib49e0f35aa554025634c8496fbb80d87dbc86d89
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/ucalc.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ea44ff7d4f3d..8cf5a59fadd9 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5124,6 +5124,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);
}