sc/qa/unit/uicalc/uicalc.cxx |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

New commits:
commit d77a4927e34835160d64bf7249544a8ad6f43075
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu May 29 14:53:52 2025 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Jun 2 13:08:15 2025 +0200

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

diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index e2dd7940e7cf..c2b50d330089 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -2391,6 +2391,28 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf158551)
     CPPUNIT_ASSERT_EQUAL(u"10"_ustr, pDoc->GetString(ScAddress(1, 0, 0)));
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf166767)
+{
+    createScDoc();
+
+    insertStringToCell(u"A1"_ustr, u"Test");
+
+    goToCell(u"A1"_ustr);
+
+    dispatchCommand(mxComponent, u".uno:Copy"_ustr, {});
+
+    uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
+        { { "SelectedFormat", 
uno::Any(static_cast<sal_uInt32>(SotClipboardFormatId::BITMAP)) } });
+
+    // Without the fix in place, this test would have crashed
+    dispatchCommand(mxComponent, u".uno:ClipboardFormatItems"_ustr, 
aPropertyValues);
+
+    ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
+    uno::Reference<drawing::XDrawPage> 
xPage(pModelObj->getDrawPages()->getByIndex(0),
+                                             uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xPage->getCount());
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf159174)
 {
     createScDoc();

Reply via email to