diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-07-21 11:04:25 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-07-21 12:55:48 +0200 |
commit | 1994009b7d244a36314df56c6dafa6ce477c01ba (patch) | |
tree | 75ba318f1c9a16b4b5827ea1df7e1595c90b190c /sc | |
parent | 083fe09958658de8c3da87a28e0f8ff7b3b8a5e9 (diff) |
tdf#114427: sc_macros_test: Add unittest
Change-Id: Ic1474051ff389e155d07546ad820ae3bb1f4e6dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99124
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/extras/macros-test.cxx | 39 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/tdf114427.ods | bin | 0 -> 9173 bytes |
2 files changed, 39 insertions, 0 deletions
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index af619d12459c..7289dcc75888 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -20,6 +20,7 @@ #include <scitems.hxx> #include <com/sun/star/script/XLibraryContainerPassword.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -37,6 +38,7 @@ public: void testVba(); void testMSP(); void testPasswordProtectedStarBasic(); + void testTdf114427(); void testTdf107885(); void testRowColumn(); void testTdf131562(); @@ -50,6 +52,7 @@ public: CPPUNIT_TEST(testMSP); CPPUNIT_TEST(testVba); CPPUNIT_TEST(testPasswordProtectedStarBasic); + CPPUNIT_TEST(testTdf114427); CPPUNIT_TEST(testTdf107885); CPPUNIT_TEST(testRowColumn); CPPUNIT_TEST(testTdf131562); @@ -545,6 +548,42 @@ void ScMacrosTest::testPasswordProtectedUnicodeString() xCloseable->close(true); } +void ScMacrosTest::testTdf114427() +{ + OUString aFileName; + createFileURL("tdf114427.ods", aFileName); + uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); + + CPPUNIT_ASSERT_MESSAGE("Failed to load the doc", xComponent.is()); + + Any aRet; + Sequence< sal_Int16 > aOutParamIndex; + Sequence< Any > aOutParam; + Sequence< uno::Any > aParams; + + SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); + + CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); + ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); + + uno::Reference< frame::XModel > xModel = pDocSh->GetModel(); + uno::Reference< sheet::XSpreadsheetDocument > xDoc(xModel, UNO_QUERY_THROW); + uno::Reference< container::XIndexAccess > xIA(xDoc->getSheets(), UNO_QUERY_THROW); + uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xIA->getByIndex(0), UNO_QUERY_THROW); + uno::Reference< container::XIndexAccess > xDraws(xDrawPageSupplier->getDrawPage(), UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xDraws->getCount()); + + // Without the fix in place, it would have crashed here + SfxObjectShell::CallXScript( + xComponent, + "vnd.sun.Star.script:Standard.Module1.DeletingFrame?language=Basic&location=document", + aParams, aRet, aOutParamIndex, aOutParam); + + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDraws->getCount()); + + pDocSh->DoClose(); +} + void ScMacrosTest::testTdf107902() { OUString aFileName; diff --git a/sc/qa/extras/testdocuments/tdf114427.ods b/sc/qa/extras/testdocuments/tdf114427.ods Binary files differnew file mode 100644 index 000000000000..656398661b35 --- /dev/null +++ b/sc/qa/extras/testdocuments/tdf114427.ods |