sc/qa/unit/ucalc_copypaste.cxx |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

New commits:
commit 629d2db54bd9f97d2c494b85637a83229275a1a6
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Jun 14 10:37:26 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jun 14 21:22:00 2022 +0200

    tdf#149554: sc_ucalc_copypaste: Add unittest
    
    Change-Id: Iba3cf497cdfaca64b75303d40bb062869bf3a50e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135816
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx
index 0fe6eb03f161..148accac85f9 100644
--- a/sc/qa/unit/ucalc_copypaste.cxx
+++ b/sc/qa/unit/ucalc_copypaste.cxx
@@ -113,6 +113,7 @@ public:
     void testCopyPasteReferencesExternalDoc(); // tdf#106456
     void testTdf68976();
     void testTdf71058();
+    void testTdf149554();
 
     void testCutPasteSpecial();
     void testCutPasteSpecialTranspose();
@@ -217,6 +218,7 @@ public:
 
     CPPUNIT_TEST(testTdf68976);
     CPPUNIT_TEST(testTdf71058);
+    CPPUNIT_TEST(testTdf149554);
 
     CPPUNIT_TEST(testCutPasteSpecial);
     CPPUNIT_TEST(testCutPasteSpecialTranspose);
@@ -10351,6 +10353,34 @@ void TestCopyPaste::testTdf71058()
     CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(3, 2, nTab));
 }
 
+void TestCopyPaste::testTdf149554()
+{
+    const SCTAB nTab = 0;
+    m_pDoc->InsertTab(nTab, "Test");
+
+    // Cut C4:C5 to the clip document.
+    ScDocument aClipDoc(SCDOCMODE_CLIP);
+    ScRange aSrcRange(2, 3, nTab, 3, 3, nTab);
+    cutToClip(*m_xDocShell, aSrcRange, &aClipDoc, false);
+
+    // To E6:E7
+    ScRange aDestRange(4, 5, nTab, 4, 6, nTab);
+    ScMarkData aDestMark(m_pDoc->GetSheetLimits());
+
+    // Transpose
+    ScDocument* pOrigClipDoc = &aClipDoc;
+    ScDocumentUniquePtr pTransClip(new ScDocument(SCDOCMODE_CLIP));
+    aClipDoc.TransposeClip(pTransClip.get(), InsertDeleteFlags::ALL, false, 
true);
+    aDestMark.SetMarkArea(aDestRange);
+    // Paste. Without the fix in place, this test would have crashed here
+    m_pDoc->CopyFromClip(aDestRange, aDestMark, InsertDeleteFlags::ALL, 
nullptr, pTransClip.get(),
+                         true, false, true, false);
+    m_pDoc->UpdateTranspose(aDestRange.aStart, pOrigClipDoc, aDestMark, 
nullptr);
+    pTransClip.reset();
+
+    m_pDoc->DeleteTab(0);
+}
+
 void TestCopyPaste::testMixData()
 {
     m_pDoc->InsertTab(0, "Test");

Reply via email to