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

New commits:
commit d2d0bbbc2bd3a2ad1e73acc03d2183e74ca4a410
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Jan 8 14:46:12 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jan 9 12:33:19 2024 +0100

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

diff --git a/sc/qa/unit/uicalc/data/tdf159046.ods 
b/sc/qa/unit/uicalc/data/tdf159046.ods
new file mode 100644
index 000000000000..f9fc556c0bef
Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf159046.ods differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 930ad6ee7dcb..e3d526fbd53d 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -964,6 +964,38 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf154125)
     CPPUNIT_ASSERT_EQUAL(OUString("21"), pDoc->GetString(ScAddress(0, 1, 0)));
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf159046)
+{
+    createScDoc("tdf159046.ods");
+    ScDocument* pDoc = getScDoc();
+    ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+
+    std::map<SCROW, std::vector<SdrObject*>> aObjects
+        = pDrawLayer->GetObjectsAnchoredToRange(0, 0, 6, 8);
+    CPPUNIT_ASSERT_EQUAL(size_t(1), aObjects.size());
+
+    aObjects = pDrawLayer->GetObjectsAnchoredToRange(0, 1, 6, 8);
+    CPPUNIT_ASSERT_EQUAL(size_t(0), aObjects.size());
+
+    goToCell("A2:F10");
+    dispatchCommand(mxComponent, ".uno:Cut", {});
+
+    goToCell("B2");
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+
+    // Without the fix in place, this test would have crashed here
+    saveAndReload("calc8");
+
+    pDoc = getScDoc();
+    pDrawLayer = pDoc->GetDrawLayer();
+
+    aObjects = pDrawLayer->GetObjectsAnchoredToRange(0, 0, 6, 8);
+    CPPUNIT_ASSERT_EQUAL(size_t(0), aObjects.size());
+
+    aObjects = pDrawLayer->GetObjectsAnchoredToRange(0, 1, 6, 8);
+    CPPUNIT_ASSERT_EQUAL(size_t(1), aObjects.size());
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf148863)
 {
     createScDoc();

Reply via email to