diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-07-10 14:59:43 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-07-10 17:35:21 +0200 |
commit | 88424a4adca388c8708b164751a4144a62814224 (patch) | |
tree | 84e188a227c09586406e42a1a09e3b3df691f350 | |
parent | 2333dfd69c2933004834a572c981ca20a0537422 (diff) |
tdf#107902: sc_macros_test: Add unittest
Change-Id: I6fb494944c51a06ffec955e900f146e748f8f2f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98522
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sc/qa/extras/macros-test.cxx | 46 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/tdf107902.xlsm | bin | 0 -> 13948 bytes |
2 files changed, 46 insertions, 0 deletions
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 502b9ba6d8ee..2630484e4122 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -16,6 +16,8 @@ #include <docsh.hxx> #include <document.hxx> +#include <attrib.hxx> +#include <scitems.hxx> #include <com/sun/star/script/XLibraryContainerPassword.hpp> @@ -39,6 +41,7 @@ public: void testRowColumn(); void testTdf131562(); void testPasswordProtectedUnicodeString(); + void testTdf107902(); void testTdf131296_legacy(); void testTdf131296_new(); @@ -51,6 +54,7 @@ public: CPPUNIT_TEST(testRowColumn); CPPUNIT_TEST(testTdf131562); CPPUNIT_TEST(testPasswordProtectedUnicodeString); + CPPUNIT_TEST(testTdf107902); CPPUNIT_TEST(testTdf131296_legacy); CPPUNIT_TEST(testTdf131296_new); @@ -529,6 +533,48 @@ void ScMacrosTest::testPasswordProtectedUnicodeString() xCloseable->close(true); } +void ScMacrosTest::testTdf107902() +{ + OUString aFileName; + createFileURL("tdf107902.xlsm", 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); + ScDocument& rDoc = pDocSh->GetDocument(); + + //Without the fix in place, it would have failed with 'Unexpected dialog: Error: BASIC runtime error.' + SfxObjectShell::CallXScript( + xComponent, + "vnd.sun.Star.script:VBAProject.Module1.AF?language=Basic&location=document", + aParams, aRet, aOutParamIndex, aOutParam); + + //Check the autofilter was created + const ScPatternAttr* pPattern = rDoc.GetPattern(0, 0, 0); + CPPUNIT_ASSERT(pPattern); + + const ScMergeFlagAttr& rAttr = pPattern->GetItem(ATTR_MERGE_FLAG); + CPPUNIT_ASSERT_MESSAGE("Autofilter was not created", rAttr.HasAutoFilter()); + + //Check the last row is hidden + CPPUNIT_ASSERT(!rDoc.RowHidden(0,0)); + CPPUNIT_ASSERT(!rDoc.RowHidden(1,0)); + CPPUNIT_ASSERT(!rDoc.RowHidden(2,0)); + CPPUNIT_ASSERT(!rDoc.RowHidden(3,0)); + CPPUNIT_ASSERT(rDoc.RowHidden(4,0)); + + pDocSh->DoClose(); +} + void ScMacrosTest::testTdf131296_legacy() { // For legacy password-protected library images, we must correctly get the constants' values, diff --git a/sc/qa/extras/testdocuments/tdf107902.xlsm b/sc/qa/extras/testdocuments/tdf107902.xlsm Binary files differnew file mode 100644 index 000000000000..f5333959b0e5 --- /dev/null +++ b/sc/qa/extras/testdocuments/tdf107902.xlsm |