tdf#86166: sc_uicalc: Add unittest

Change-Id: I7d7320e10c71e02606da192ee877f1df94d53c88
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132318
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/unit/uicalc/data/tdf86166.ods b/sc/qa/unit/uicalc/data/tdf86166.ods
new file mode 100644
index 0000000..21fb067
--- /dev/null
+++ b/sc/qa/unit/uicalc/data/tdf86166.ods
Binary files differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index ceaa63b..1da2c25 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1409,6 +1409,23 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf117706)
    CPPUNIT_ASSERT_EQUAL(OUString(""), pDoc->GetString(ScAddress(0, 2, 0)));
}

CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf86166)
{
    ScModelObj* pModelObj = createDoc("tdf86166.ods");
    ScDocument* pDoc = pModelObj->GetDocument();
    CPPUNIT_ASSERT(pDoc);

    CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount());

    uno::Sequence<beans::PropertyValue> aArgs(
        comphelper::InitPropertySequence({ { "Index", uno::Any(sal_uInt16(0)) } }));

    // Without the fix in place, this test would have crashed here
    dispatchCommand(mxComponent, ".uno:Remove", aArgs);

    CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(1), pDoc->GetTableCount());
}

CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf108292)
{
    ScModelObj* pModelObj = createDoc("tdf108292.ods");