[Libreoffice-commits] core.git: sc/qa

Eike Rathke erack at redhat.com
Tue Feb 21 13:38:57 UTC 2017


 sc/qa/unit/ucalc.cxx |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

New commits:
commit 45fd903d5ed6007271485ce3fa7c2e78bdc286f8
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Feb 21 14:37:59 2017 +0100

    unit test for cell merge with note caption undo, tdf#105667
    
    Change-Id: Ib49e0f35aa554025634c8496fbb80d87dbc86d89

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 4ce4c7c..f09a0a4 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);
 }
 


More information about the Libreoffice-commits mailing list