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

New commits:
commit 3d4ee5ee34da11d3580f0b778406424556ed0ed6
Author:     Xisco Fauli <[email protected]>
AuthorDate: Mon Jan 15 13:39:56 2024 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Mon Jan 15 21:39:51 2024 +0100

    tdf#159174: sc_uicalc: Add unittest
    
    Change-Id: I5df0a4b4e0e9d0af5b9187def68e2971b2c86dff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162089
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 19571c064fed..53f4a7e2b2b5 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -2156,6 +2156,25 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf158551)
     CPPUNIT_ASSERT_EQUAL(OUString("10"), pDoc->GetString(ScAddress(1, 0, 0)));
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf159174)
+{
+    createScDoc();
+
+    dispatchCommand(mxComponent, ".uno:SelectUnprotectedCells", {});
+    dispatchCommand(mxComponent, ".uno:Copy", {});
+
+    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, ".uno:ClipboardFormatItems", 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>(0), xPage->getCount());
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testKeyboardMergeRef)
 {
     createScDoc();

Reply via email to