sc/qa/unit/uicalc/data/tdf147744.ods |binary
 sc/qa/unit/uicalc/uicalc.cxx         |   42 +++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

New commits:
commit 9c5a32c6cf072473ea28e2e9eca76ffd10c2aefa
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Mar 11 11:58:27 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Sat Mar 12 12:43:43 2022 +0100

    tdf#147744: sc_uicalc: Add unittest
    
    Change-Id: Ica8f971ca12569cc299910a20b5a7a5bcfd49bd6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131345
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/unit/uicalc/data/tdf147744.ods 
b/sc/qa/unit/uicalc/data/tdf147744.ods
new file mode 100644
index 000000000000..cd8904c6570d
Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf147744.ods differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 3248dc1ac732..2922521a97b5 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -593,6 +593,48 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf146795)
     pMod->SetInputOptions(aInputOption);
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf147744)
+{
+    ScModelObj* pModelObj = createDoc("tdf147744.ods");
+    ScDocument* pDoc = pModelObj->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+
+    // Disable replace cell warning
+    ScModule* pMod = SC_MOD();
+    ScInputOptions aInputOption = pMod->GetInputOptions();
+    bool bOldStatus = aInputOption.GetReplaceCellsWarn();
+    aInputOption.SetReplaceCellsWarn(false);
+    pMod->SetInputOptions(aInputOption);
+
+    goToCell("A2");
+
+    dispatchCommand(mxComponent, ".uno:Copy", {});
+    Scheduler::ProcessEventsToIdle();
+
+    // Move to A3
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN);
+    Scheduler::ProcessEventsToIdle();
+
+    // Select the following cell
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_SHIFT | KEY_DOWN);
+    Scheduler::ProcessEventsToIdle();
+
+    // Without the fix in place, this test would have crashed here
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(0, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(ScAddress(0, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(0, 3, 0)));
+    CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(ScAddress(0, 4, 0)));
+    CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(0, 5, 0)));
+    CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(ScAddress(0, 6, 0)));
+
+    // Restore previous status
+    aInputOption.SetReplaceCellsWarn(bOldStatus);
+    pMod->SetInputOptions(aInputOption);
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf138432)
 {
     ScModelObj* pModelObj = createDoc("tdf138432.ods");

Reply via email to