diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-03-16 11:43:23 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-03-16 12:44:50 +0100 |
commit | eae375a224b44cd5bb18e180732668668ee9178f (patch) | |
tree | 9a93c2e087b0bd995b470cb1d59d54899a5b908b /sc/qa | |
parent | 02f30509f8b19d862b569fab480617808f2be2a7 (diff) |
tdf#64639: sc_macros_test: Add unittest
Change-Id: I0679ae2d129cd5f1445d03a5932b83ec8779b203
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131650
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/extras/macros-test.cxx | 47 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/tdf64639.ods | bin | 0 -> 10569 bytes |
2 files changed, 47 insertions, 0 deletions
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 2516024442b6..0d1be3d710c7 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -46,6 +46,7 @@ public: void testTdf114427(); void testRowColumn(); void testTdf104902(); + void testTdf64639(); void testTdf142033(); void testPasswordProtectedUnicodeString(); void testPasswordProtectedArrayInUserType(); @@ -75,6 +76,7 @@ public: CPPUNIT_TEST(testTdf114427); CPPUNIT_TEST(testRowColumn); CPPUNIT_TEST(testTdf104902); + CPPUNIT_TEST(testTdf64639); CPPUNIT_TEST(testTdf142033); CPPUNIT_TEST(testPasswordProtectedUnicodeString); CPPUNIT_TEST(testPasswordProtectedArrayInUserType); @@ -367,6 +369,51 @@ void ScMacrosTest::testTdf104902() xCloseable->close(true); } +void ScMacrosTest::testTdf64639() +{ + OUString aFileName; + createFileURL(u"tdf64639.ods", aFileName); + uno::Reference<css::lang::XComponent> xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); + + SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); + + CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); + ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); + ScDocument& rDoc = pDocSh->GetDocument(); + + ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer(); + const SdrPage* pPage = pDrawLayer->GetPage(0); + + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pPage->GetObjCount()); + + Any aRet; + Sequence<sal_Int16> aOutParamIndex; + Sequence<Any> aOutParam; + Sequence<uno::Any> aParams; + + // Add and delete the chart a few times + // Without the fix in place, this test would have crashed here + for (size_t i = 0; i < 5; ++i) + { + SfxObjectShell::CallXScript( + xComponent, + "vnd.sun.Star.script:Standard.Module1.DrawGraph?language=Basic&location=document", + aParams, aRet, aOutParamIndex, aOutParam); + + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount()); + + SfxObjectShell::CallXScript( + xComponent, + "vnd.sun.Star.script:Standard.Module1.DeleteGraph?language=Basic&location=document", + aParams, aRet, aOutParamIndex, aOutParam); + + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pPage->GetObjCount()); + } + + css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW); + xCloseable->close(true); +} + void ScMacrosTest::testTdf142033() { OUString aFileName; diff --git a/sc/qa/extras/testdocuments/tdf64639.ods b/sc/qa/extras/testdocuments/tdf64639.ods Binary files differnew file mode 100644 index 000000000000..0b2e708d78f7 --- /dev/null +++ b/sc/qa/extras/testdocuments/tdf64639.ods |