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 <xiscofauli@libreoffice.org>
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 19571c0..53f4a7e 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();