include/test/calc_unoapi_test.hxx | 3 sc/qa/extras/macros-test.cxx | 253 ++++---------------------------------- sc/qa/extras/vba-macro-test.cxx | 215 ++++++-------------------------- test/Library_subsequenttest.mk | 1 test/source/calc_unoapi_test.cxx | 14 ++ 5 files changed, 91 insertions(+), 395 deletions(-)
New commits: commit f3a82a8ba51195cf31b0f78164735acc7ebbcd2f Author: Xisco Fauli <[email protected]> AuthorDate: Wed Oct 19 14:14:02 2022 +0200 Commit: Xisco Fauli <[email protected]> CommitDate: Wed Oct 19 15:19:02 2022 +0200 sc: factor out common code in tests Change-Id: I58558dd87f235bf3699f3f65271522bb1e7a2ea0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141529 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/include/test/calc_unoapi_test.hxx b/include/test/calc_unoapi_test.hxx index 7d1bb0521115..369e48b877f2 100644 --- a/include/test/calc_unoapi_test.hxx +++ b/include/test/calc_unoapi_test.hxx @@ -22,6 +22,9 @@ public: virtual void setUp() override; virtual void tearDown() override; + css::uno::Any executeMacro(const OUString& rScriptURL, + const css::uno::Sequence<css::uno::Any>& rParams = {}); + protected: // reference to document component that we are testing css::uno::Reference<css::lang::XComponent> mxComponent; diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 1690b4f00824..2df09b8626af 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -144,15 +144,7 @@ void ScMacrosTest::testMSP() mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - Any aRet; - Sequence< sal_Int16 > aOutParamIndex; - Sequence< Any > aOutParam; - Sequence< uno::Any > aParams; - - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.TestMSP?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + Any aRet = executeMacro("vnd.sun.Star.script:Standard.Module1.TestMSP?language=Basic&location=document"); OUString sResult; aRet >>= sResult; @@ -169,11 +161,6 @@ void ScMacrosTest::testPasswordProtectedStarBasic() createFileURL(u"testTypePassword.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - Any aRet; - Sequence< sal_Int16 > aOutParamIndex; - Sequence< Any > aOutParam; - Sequence< uno::Any > aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); @@ -182,30 +169,21 @@ void ScMacrosTest::testPasswordProtectedStarBasic() // User defined types - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.LoadAndExecuteTest?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:Standard.Module1.LoadAndExecuteTest?language=Basic&location=document"); OUString aValue = rDoc.GetString(0,0,0); CPPUNIT_ASSERT_EQUAL_MESSAGE("User defined types script did not change the value of Sheet1.A1", OUString("success"), aValue); // Big Module - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:MyLibrary.BigModule.bigMethod?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:MyLibrary.BigModule.bigMethod?language=Basic&location=document"); aValue = rDoc.GetString(1,0,0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Big module script did not change the value of Sheet1.B1", OUString("success"), aValue); // far big method tdf#94617 - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:MyLibrary.BigModule.farBigMethod?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:MyLibrary.BigModule.farBigMethod?language=Basic&location=document"); aValue = rDoc.GetString(2,0,0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Far Method script did not change the value of Sheet1.C1", OUString("success"), aValue); @@ -219,21 +197,13 @@ void ScMacrosTest::testStarBasic() createFileURL(u"StarBasic.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - Any aRet; - Sequence< sal_Int16 > aOutParamIndex; - Sequence< Any > aOutParam; - Sequence< uno::Any > aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); ScDocument& rDoc = pDocSh->GetDocument(); - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.Macro1?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:Standard.Module1.Macro1?language=Basic&location=document"); double aValue = rDoc.GetValue(0,0,0); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("script did not change the value of Sheet1.A1",2.0, aValue, 0.00001); pDocSh->DoClose(); @@ -245,29 +215,18 @@ void ScMacrosTest::testRowColumn() createFileURL(u"StarBasic.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - Any aRet; - Sequence< sal_Int16 > aOutParamIndex; - Sequence< Any > aOutParam; - Sequence< uno::Any > aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); ScDocument& rDoc = pDocSh->GetDocument(); - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.Macro_RowHeight?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:Standard.Module1.Macro_RowHeight?language=Basic&location=document"); sal_uInt16 nHeight = o3tl::convert(rDoc.GetRowHeight(0, 0), o3tl::Length::twip, o3tl::Length::mm100); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(2000), nHeight); - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.Macro_ColumnWidth?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:Standard.Module1.Macro_ColumnWidth?language=Basic&location=document"); sal_uInt16 nWidth = o3tl::convert(rDoc.GetColWidth(0, 0), o3tl::Length::twip, o3tl::Length::mm100); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(4001), nWidth); @@ -337,15 +296,7 @@ void ScMacrosTest::testTdf104902() createFileURL(u"tdf104902.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - Any aRet; - Sequence<sal_Int16> aOutParamIndex; - Sequence<Any> aOutParam; - Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.display_bug?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:Standard.Module1.display_bug?language=Basic&location=document"); // Export to ODS saveAndReload("calc8"); @@ -384,26 +335,15 @@ void ScMacrosTest::testTdf64639() 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( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.DrawGraph?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:Standard.Module1.DrawGraph?language=Basic&location=document"); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount()); - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.DeleteGraph?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:Standard.Module1.DeleteGraph?language=Basic&location=document"); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pPage->GetObjCount()); } @@ -417,15 +357,7 @@ void ScMacrosTest::testTdf142033() createFileURL(u"tdf142033.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - Any aRet; - Sequence< sal_Int16 > aOutParamIndex; - Sequence< Any > aOutParam; - Sequence< uno::Any > aParams; - - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.display_bug?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:Standard.Module1.display_bug?language=Basic&location=document"); // Export to ODS saveAndReload("calc8"); @@ -462,13 +394,7 @@ void ScMacrosTest::testPasswordProtectedUnicodeString() // Check that loading password-protected macro image correctly loads Unicode strings { - Any aRet; - Sequence<sal_Int16> aOutParamIndex; - Sequence<Any> aOutParam; - Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript(mxComponent, sMacroURL, aParams, aRet, aOutParamIndex, - aOutParam); + Any aRet = executeMacro(sMacroURL); OUString aReturnValue; aRet >>= aReturnValue; @@ -490,13 +416,7 @@ void ScMacrosTest::testPasswordProtectedUnicodeString() saveAndReload("calc8"); { - Any aRet; - Sequence<sal_Int16> aOutParamIndex; - Sequence<Any> aOutParam; - Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript(mxComponent, sMacroURL, aParams, aRet, aOutParamIndex, - aOutParam); + Any aRet = executeMacro(sMacroURL); OUString aReturnValue; aRet >>= aReturnValue; @@ -519,13 +439,7 @@ void ScMacrosTest::testPasswordProtectedArrayInUserType() // Check that loading password-protected macro image correctly loads array bounds { - Any aRet; - Sequence<sal_Int16> aOutParamIndex; - Sequence<Any> aOutParam; - Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript(mxComponent, sMacroURL, aParams, aRet, aOutParamIndex, - aOutParam); + Any aRet = executeMacro(sMacroURL); sal_Int16 nReturnValue; aRet >>= nReturnValue; @@ -547,13 +461,7 @@ void ScMacrosTest::testPasswordProtectedArrayInUserType() saveAndReload("calc8"); { - Any aRet; - Sequence<sal_Int16> aOutParamIndex; - Sequence<Any> aOutParam; - Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript(mxComponent, sMacroURL, aParams, aRet, aOutParamIndex, - aOutParam); + Any aRet = executeMacro(sMacroURL); sal_Int16 nReturnValue; aRet >>= nReturnValue; @@ -570,11 +478,6 @@ void ScMacrosTest::testTdf114427() createFileURL(u"tdf114427.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - Any aRet; - Sequence< sal_Int16 > aOutParamIndex; - Sequence< Any > aOutParam; - Sequence< uno::Any > aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); @@ -588,10 +491,7 @@ void ScMacrosTest::testTdf114427() CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xDraws->getCount()); // Without the fix in place, it would have crashed here - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.DeletingFrame?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:Standard.Module1.DeletingFrame?language=Basic&location=document"); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDraws->getCount()); @@ -613,17 +513,10 @@ void ScMacrosTest::testTdf131296_legacy() createFileURL(u"tdf131296_legacy.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); { - Any aRet; - Sequence<sal_Int16> aOutParamIndex; - Sequence<Any> aOutParam; - Sequence<uno::Any> aParams; - for (auto& [sTestName, sExpected] : aTests) { - SfxObjectShell::CallXScript(mxComponent, - "vnd.sun.Star.script:Protected.Module1." + sTestName - + "?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + Any aRet = executeMacro("vnd.sun.Star.script:Protected.Module1." + sTestName + + "?language=Basic&location=document"); OUString aReturnValue; aRet >>= aReturnValue; @@ -651,17 +544,10 @@ void ScMacrosTest::testTdf131296_new() createFileURL(u"tdf131296_new.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); { - Any aRet; - Sequence<sal_Int16> aOutParamIndex; - Sequence<Any> aOutParam; - Sequence<uno::Any> aParams; - for (auto& [sTestName, sExpected] : aTests) { - SfxObjectShell::CallXScript(mxComponent, - "vnd.sun.Star.script:Protected.Module1." + sTestName - + "?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + Any aRet = executeMacro("vnd.sun.Star.script:Protected.Module1." + sTestName + + "?language=Basic&location=document"); OUString aReturnValue; aRet >>= aReturnValue; @@ -679,21 +565,13 @@ void ScMacrosTest::testTdf46119() createFileURL(u"tdf46119.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - Any aRet; - Sequence< sal_Int16 > aOutParamIndex; - Sequence< Any > aOutParam; - Sequence< uno::Any > aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); ScDocument& rDoc = pDocSh->GetDocument(); - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.Main?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:Standard.Module1.Main?language=Basic&location=document"); CPPUNIT_ASSERT_EQUAL(OUString("0.074"), rDoc.GetString(ScAddress(2, 24, 0))); CPPUNIT_ASSERT_EQUAL(OUString("0.067"), rDoc.GetString(ScAddress(2, 25, 0))); @@ -719,15 +597,7 @@ void ScMacrosTest::testTdf128218() createFileURL(u"tdf128218.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - Any aRet; - Sequence< sal_Int16 > aOutParamIndex; - Sequence< Any > aOutParam; - Sequence< uno::Any > aParams; - - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.TestRAND?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + Any aRet = executeMacro("vnd.sun.Star.script:Standard.Module1.TestRAND?language=Basic&location=document"); OUString aReturnValue; aRet >>= aReturnValue; @@ -895,15 +765,7 @@ void ScMacrosTest::testTdf143582() createFileURL(u"tdf143582.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - css::uno::Any aRet; - css::uno::Sequence<css::uno::Any> aParams; - css::uno::Sequence<css::uno::Any> aOutParam; - css::uno::Sequence<sal_Int16> aOutParamIndex; - - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.TestScriptInvoke?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + Any aRet = executeMacro("vnd.sun.Star.script:Standard.Module1.TestScriptInvoke?language=Basic&location=document"); OUString aReturnValue; aRet >>= aReturnValue; @@ -923,15 +785,7 @@ void ScMacrosTest::testTdf144085() createFileURL(u"tdf144085.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - css::uno::Any aRet; - css::uno::Sequence<css::uno::Any> aParams; - css::uno::Sequence<css::uno::Any> aOutParam; - css::uno::Sequence<sal_Int16> aOutParamIndex; - - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.TestScriptInvoke?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + Any aRet = executeMacro("vnd.sun.Star.script:Standard.Module1.TestScriptInvoke?language=Basic&location=document"); OUString aReturnValue; aRet >>= aReturnValue; @@ -951,11 +805,6 @@ void ScMacrosTest::testTdf125800() createFileURL(u"tdf125800.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - css::uno::Any aRet; - css::uno::Sequence<css::uno::Any> aParams; - css::uno::Sequence<css::uno::Any> aOutParam; - css::uno::Sequence<sal_Int16> aOutParamIndex; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); @@ -968,10 +817,7 @@ void ScMacrosTest::testTdf125800() // Without the fix in place, this test would have failed with // - Expression: false // - Unexpected dialog: Error: Inadmissible value or data type. Index out of defined range. - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.cf.doItForThisSheetindexThisRange?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + Any aRet = executeMacro("vnd.sun.Star.script:Standard.cf.doItForThisSheetindexThisRange?language=Basic&location=document"); OUString aReturnValue; aRet >>= aReturnValue; @@ -995,15 +841,7 @@ void ScMacrosTest::testTdf130307() createFileURL(u"tdf130307.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - css::uno::Any aRet; - css::uno::Sequence<css::uno::Any> aParams; - css::uno::Sequence<css::uno::Any> aOutParam; - css::uno::Sequence<sal_Int16> aOutParamIndex; - - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.ForEachSheets?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + Any aRet = executeMacro("vnd.sun.Star.script:Standard.Module1.ForEachSheets?language=Basic&location=document"); OUString aReturnValue; aRet >>= aReturnValue; @@ -1021,11 +859,6 @@ void ScMacrosTest::testTdf144970() createFileURL(u"tdf144970.ods", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - Any aRet; - Sequence< sal_Int16 > aOutParamIndex; - Sequence< Any > aOutParam; - Sequence< uno::Any > aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); @@ -1045,10 +878,7 @@ void ScMacrosTest::testTdf144970() // - Unexpected dialog: Error: BASIC runtime error. // An exception occurred // Type: com.sun.star.lang.IllegalArgumentException - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:Standard.Module1.Main?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:Standard.Module1.Main?language=Basic&location=document"); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount()); @@ -1079,17 +909,10 @@ void ScMacrosTest::testTdf138646() }); { - Any aRet; - Sequence<sal_Int16> aOutParamIndex; - Sequence<Any> aOutParam; - Sequence<uno::Any> aParams; - for (auto& [sTestName, sExpected] : aTests) { - SfxObjectShell::CallXScript(mxComponent, - "vnd.sun.Star.script:Standard.Module1." + sTestName - + "?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + Any aRet = executeMacro("vnd.sun.Star.script:Standard.Module1." + sTestName + + "?language=Basic&location=document"); OUString aReturnValue; aRet >>= aReturnValue; @@ -1137,19 +960,12 @@ void ScMacrosTest::testTdf107572() " thisComponent.Sheets(0).getCellRangeByName(\"A1:F14\").autoformat(\"Default\")\n" "End Function\n"))); - Any aRet; - Sequence<sal_Int16> aOutParamIndex; - Sequence<Any> aOutParam; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); CPPUNIT_ASSERT(pDocSh); // Without the fix in place, this test would have crashed - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:TestLibrary.TestModule.Main?language=Basic&location=document", - {}, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:TestLibrary.TestModule.Main?language=Basic&location=document"); ScDocument& rDoc = pDocSh->GetDocument(); @@ -1208,14 +1024,7 @@ void ScMacrosTest::testShapeLayerId() " TestLayerID = origID & \" Expected runtime error happened\"\n" "End Function\n"))); - Any aRet; - Sequence<sal_Int16> aOutParamIndex; - Sequence<Any> aOutParam; - - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:TestLibrary.TestModule.TestLayerID?language=Basic&location=document", - {}, aRet, aOutParamIndex, aOutParam); + Any aRet = executeMacro("vnd.sun.Star.script:TestLibrary.TestModule.TestLayerID?language=Basic&location=document"); // Without the fix in place, this test would have failed in non-debug builds with // - Expected : <Any: (string) 0 Expected runtime error happened> // - Actual : <Any: (string) 0 1> diff --git a/sc/qa/extras/vba-macro-test.cxx b/sc/qa/extras/vba-macro-test.cxx index c9b0ac800d4e..a54c4bdfd57e 100644 --- a/sc/qa/extras/vba-macro-test.cxx +++ b/sc/qa/extras/vba-macro-test.cxx @@ -99,11 +99,6 @@ void VBAMacroTest::testSimpleCopyAndPaste() createFileURL(u"SimpleCopyPaste.xlsm", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); @@ -119,9 +114,7 @@ void VBAMacroTest::testSimpleCopyAndPaste() CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 4, 0))); CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 5, 0))); - SfxObjectShell::CallXScript( - mxComponent, "vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document"); // Copy from C4-C6 CPPUNIT_ASSERT_EQUAL(10.0, rDoc.GetValue(ScAddress(2, 3, 0))); @@ -156,11 +149,6 @@ void VBAMacroTest::testMultiDocumentCopyAndPaste() createFileURL(u"MultiDocumentCopyPaste.xlsm", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); @@ -171,9 +159,7 @@ void VBAMacroTest::testMultiDocumentCopyAndPaste() CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 2, 0))); CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 3, 0))); - SfxObjectShell::CallXScript( - mxComponent, "vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document"); CPPUNIT_ASSERT_EQUAL(200.0, rDoc.GetValue(ScAddress(1, 1, 0))); CPPUNIT_ASSERT_EQUAL(100.0, rDoc.GetValue(ScAddress(1, 2, 0))); @@ -210,15 +196,8 @@ void VBAMacroTest::testSheetAndColumnSelectAndHide() CPPUNIT_ASSERT(!rDoc.ColHidden(3, 2)); CPPUNIT_ASSERT(!rDoc.ColHidden(4, 2)); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:VBAProject.ThisWorkbook.testHide?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro( + "vnd.sun.Star.script:VBAProject.ThisWorkbook.testHide?language=Basic&location=document"); CPPUNIT_ASSERT(!rDoc.ColHidden(0, 1)); CPPUNIT_ASSERT(rDoc.ColHidden(1, 1)); @@ -234,10 +213,8 @@ void VBAMacroTest::testSheetAndColumnSelectAndHide() CPPUNIT_ASSERT_EQUAL(SCTAB(0), rViewData.GetTabNo()); - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:VBAProject.ThisWorkbook.testUnhide?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro( + "vnd.sun.Star.script:VBAProject.ThisWorkbook.testUnhide?language=Basic&location=document"); CPPUNIT_ASSERT(!rDoc.ColHidden(0, 1)); CPPUNIT_ASSERT(!rDoc.ColHidden(1, 1)); @@ -275,15 +252,8 @@ void VBAMacroTest::testPrintArea() CPPUNIT_ASSERT_EQUAL(false, aSequence.hasElements()); } - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript(mxComponent, - "vnd.sun.Star.script:VBAProject.ThisWorkbook.testPrintArea?" - "language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:VBAProject.ThisWorkbook.testPrintArea?language=Basic&" + "location=document"); { const uno::Sequence<table::CellRangeAddress> aSequence = xPrintAreas->getPrintAreas(); @@ -312,15 +282,8 @@ void VBAMacroTest::testSelectAllChaged() auto const& pViewData = pView->GetViewData(); CPPUNIT_ASSERT_EQUAL(ScRange(), pViewData.GetMarkData().GetMarkArea()); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript(mxComponent, - "vnd.sun.Star.script:VBAProject.ThisWorkbook.testSelectAll?" - "language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:VBAProject.ThisWorkbook.testSelectAll?language=Basic&" + "location=document"); // A1:E1048576 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 4, MAXROW, 0), pViewData.GetMarkData().GetMarkArea()); @@ -346,15 +309,8 @@ void VBAMacroTest::testRangeSelect() auto const& pViewData = pView->GetViewData(); CPPUNIT_ASSERT_EQUAL(ScRange(), pViewData.GetMarkData().GetMarkArea()); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript(mxComponent, - "vnd.sun.Star.script:VBAProject.ThisWorkbook.testRangeSelect?" - "language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:VBAProject.ThisWorkbook.testRangeSelect?language=Basic&" + "location=document"); // B2:E5 CPPUNIT_ASSERT_EQUAL(ScRange(1, 1, 0, 4, 1, 0), pViewData.GetMarkData().GetMarkArea()); @@ -372,15 +328,8 @@ void VBAMacroTest::testWindowState() createFileURL(u"VariousTestMacros.xlsm", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript(mxComponent, - "vnd.sun.Star.script:VBAProject.ThisWorkbook.testWindowState?" - "language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:VBAProject.ThisWorkbook.testWindowState?language=Basic&" + "location=document"); css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); xCloseable->close(true); @@ -407,15 +356,8 @@ void VBAMacroTest::testScroll() CPPUNIT_ASSERT_EQUAL(SCCOL(0), rViewData.GetPosX(ScHSplitPos::SC_SPLIT_LEFT)); CPPUNIT_ASSERT_EQUAL(SCROW(0), rViewData.GetPosY(ScVSplitPos::SC_SPLIT_BOTTOM)); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:VBAProject.ThisWorkbook.testScroll?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro( + "vnd.sun.Star.script:VBAProject.ThisWorkbook.testScroll?language=Basic&location=document"); CPPUNIT_ASSERT_EQUAL(ScSplitPos::SC_SPLIT_BOTTOMLEFT, rViewData.GetActivePart()); CPPUNIT_ASSERT_EQUAL(SCCOL(29), rViewData.GetPosX(ScHSplitPos::SC_SPLIT_LEFT)); @@ -579,9 +521,6 @@ void VBAMacroTest::testVba() // methods. Scheduler::ProcessEventsToIdle(); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; bool bWorkbooksHandling = rTestInfo.sFileBaseName == "Workbooks." && !sTempDir.isEmpty(); if (bWorkbooksHandling) @@ -592,10 +531,10 @@ void VBAMacroTest::testVba() SAL_INFO("sc.qa", "about to invoke vba test in " << aFileName << " with url " << rTestInfo.sMacroUrl); - SfxObjectShell::CallXScript(mxComponent, rTestInfo.sMacroUrl, aParams, aRet, aOutParamIndex, - aOutParam); + uno::Any aRet = executeMacro(rTestInfo.sMacroUrl, aParams); OUString aStringRes; aRet >>= aStringRes; + CPPUNIT_ASSERT_EQUAL_MESSAGE( OUString("script reported failure in file " + rTestInfo.sFileBaseName + "xls") .toUtf8() @@ -630,10 +569,6 @@ void VBAMacroTest::testTdf149579() "Range(\"A1\").Sort Key1:=Range(\"A1\")\n" "End Sub\n"))); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); CPPUNIT_ASSERT(pDocSh); @@ -644,12 +579,8 @@ void VBAMacroTest::testTdf149579() rDoc.SetValue(ScAddress(0, 2, 0), 1.0); // Without the fix in place, this call would have crashed in debug builds with failed assertion - ErrCode result = SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:TestLibrary.TestModule.TestTdf149579?language=Basic&location=document", - {}, aRet, aOutParamIndex, aOutParam); - CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, result); - + executeMacro("vnd.sun.Star.script:TestLibrary.TestModule.TestTdf149579?language=Basic&location=" + "document"); // Without the fix in place, this test would have failed with // - Expected: 1 // - Actual : 5 @@ -674,10 +605,6 @@ void VBAMacroTest::testVbaRangeSort() " Selection.Sort Key1:=Range(\"A1\"), Header:=False\n" "End Sub\n"))); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); CPPUNIT_ASSERT(pDocSh); @@ -688,11 +615,8 @@ void VBAMacroTest::testVbaRangeSort() rDoc.SetValue(ScAddress(0, 2, 0), 2.0); // Without the fix in place, this call would have crashed in debug builds with failed assertion - ErrCode result = SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:TestLibrary.TestModule.TestRangeSort?language=Basic&location=document", - {}, aRet, aOutParamIndex, aOutParam); - CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, result); + executeMacro("vnd.sun.Star.script:TestLibrary.TestModule.TestRangeSort?language=Basic&location=" + "document"); CPPUNIT_ASSERT_EQUAL(0.5, rDoc.GetValue(ScAddress(0, 0, 0))); CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(ScAddress(0, 1, 0))); @@ -704,11 +628,8 @@ void VBAMacroTest::testVbaRangeSort() aParam.maKeyState[0].bAscending = false; rDoc.SetSortParam(aParam, 0); - result = SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:TestLibrary.TestModule.TestRangeSort?language=Basic&location=document", - {}, aRet, aOutParamIndex, aOutParam); - CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, result); + executeMacro("vnd.sun.Star.script:TestLibrary.TestModule.TestRangeSort?language=Basic&location=" + "document"); // Without the fix in place, this test would have failed in non-debug builds with // - Expected: 2 @@ -726,11 +647,6 @@ void VBAMacroTest::testTdf107885() createFileURL(u"tdf107885.xlsm", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); @@ -743,10 +659,8 @@ void VBAMacroTest::testTdf107885() CPPUNIT_ASSERT(!rDoc.RowHidden(4, 0)); // Call auto filter macro using a string condition - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:VBAProject.Module1.AFString?language=Basic&location=document", aParams, - aRet, aOutParamIndex, aOutParam); + executeMacro( + "vnd.sun.Star.script:VBAProject.Module1.AFString?language=Basic&location=document"); //Without the fix in place, all rows in autofilter would have been hidden CPPUNIT_ASSERT(rDoc.RowHidden(1, 0)); @@ -755,10 +669,8 @@ void VBAMacroTest::testTdf107885() CPPUNIT_ASSERT(!rDoc.RowHidden(4, 0)); // Call auto filter macro using a numeric condition without any locale - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:VBAProject.Module1.AFNumeric?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro( + "vnd.sun.Star.script:VBAProject.Module1.AFNumeric?language=Basic&location=document"); CPPUNIT_ASSERT(rDoc.RowHidden(1, 0)); CPPUNIT_ASSERT(rDoc.RowHidden(2, 0)); @@ -774,11 +686,6 @@ void VBAMacroTest::testTdf131562() createFileURL(u"tdf131562.xlsm", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); @@ -788,10 +695,8 @@ void VBAMacroTest::testTdf131562() CPPUNIT_ASSERT_EQUAL(OUString("1"), rDoc.GetString(ScAddress(0, 2, 0))); CPPUNIT_ASSERT_EQUAL(OUString(""), rDoc.GetString(ScAddress(0, 3, 0))); - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:VBAProject.Munka1.numberconcat?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro( + "vnd.sun.Star.script:VBAProject.Munka1.numberconcat?language=Basic&location=document"); //Without the fix in place, the macro wouldn't have concatenated 1 and " ." CPPUNIT_ASSERT_EQUAL(OUString("1 ."), rDoc.GetString(ScAddress(0, 2, 0))); @@ -806,11 +711,6 @@ void VBAMacroTest::testTdf52602() createFileURL(u"tdf52602.xls", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); @@ -818,10 +718,8 @@ void VBAMacroTest::testTdf52602() ScDocument& rDoc = pDocSh->GetDocument(); //Without the fix in place, it would have failed with 'Unexpected dialog: Error: BASIC runtime error.' - SfxObjectShell::CallXScript(mxComponent, - "vnd.sun.Star.script:VBAProject.Modul1.Test_NumberFormat_DateTime?" - "language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:VBAProject.Modul1.Test_NumberFormat_DateTime?language=Basic&" + "location=document"); CPPUNIT_ASSERT_EQUAL(OUString("15:20"), rDoc.GetString(ScAddress(0, 0, 0))); CPPUNIT_ASSERT_EQUAL(OUString("15:20"), rDoc.GetString(ScAddress(0, 1, 0))); @@ -844,11 +742,6 @@ void VBAMacroTest::testTdf107902() createFileURL(u"tdf107902.xlsm", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent); CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); @@ -856,9 +749,7 @@ void VBAMacroTest::testTdf107902() ScDocument& rDoc = pDocSh->GetDocument(); //Without the fix in place, it would have failed with 'Unexpected dialog: Error: BASIC runtime error.' - SfxObjectShell::CallXScript( - mxComponent, "vnd.sun.Star.script:VBAProject.Module1.AF?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:VBAProject.Module1.AF?language=Basic&location=document"); //Check the autofilter was created const ScPatternAttr* pPattern = rDoc.GetPattern(0, 0, 0); @@ -883,17 +774,10 @@ void VBAMacroTest::testTdf90278() createFileURL(u"tdf90278.xls", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - // Without the fix in place, changing the border weight // would cause a Basic exception/error in the following script. - SfxObjectShell::CallXScript( - mxComponent, - "vnd.sun.Star.script:VBAProject.Module1.BorderWeight?language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + uno::Any aRet = executeMacro( + "vnd.sun.Star.script:VBAProject.Module1.BorderWeight?language=Basic&location=document"); // Check the border weight of the corresponding cell in the test document sal_Int32 aReturnValue; @@ -916,19 +800,12 @@ void VBAMacroTest::testTdf149531() ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); ScDocument& rDoc = pDocSh->GetDocument(); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - for (sal_Int32 i = 0; i < 5; ++i) { // Without the fix in place, this test would have crashed // also check the test doesn't crash when the macro is executed a few times in a row - SfxObjectShell::CallXScript(mxComponent, - "vnd.sun.Star.script:VBAProject.Module1.SetColumnWidth?" - "language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + executeMacro("vnd.sun.Star.script:VBAProject.Module1.SetColumnWidth?language=Basic&" + "location=document"); } sal_uInt16 nWidth @@ -944,16 +821,9 @@ void VBAMacroTest::testTdf118247() createFileURL(u"tdf118247.xlsm", aFileName); mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); - uno::Any aRet; - uno::Sequence<sal_Int16> aOutParamIndex; - uno::Sequence<uno::Any> aOutParam; - uno::Sequence<uno::Any> aParams; - - SfxObjectShell::CallXScript( - mxComponent, + uno::Any aRet = executeMacro( "vnd.sun.Star.script:VBAProject.Module1.testXlSpecialCellsValuesConstantsEmpty?" - "language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + "language=Basic&location=document"); OUString aReturnValue; aRet >>= aReturnValue; @@ -967,12 +837,11 @@ void VBAMacroTest::testTdf118247() for (auto & [ nXlSpecialCellsValue, sRange ] : aTestParams) { - aParams = { uno::Any(nXlSpecialCellsValue) }; - SfxObjectShell::CallXScript( - mxComponent, + uno::Sequence<uno::Any> aParams = { uno::Any(nXlSpecialCellsValue) }; + aRet = executeMacro( "vnd.sun.Star.script:VBAProject.Module1.testXlSpecialCellsValuesConstants?" "language=Basic&location=document", - aParams, aRet, aOutParamIndex, aOutParam); + aParams); aRet >>= aReturnValue; CPPUNIT_ASSERT_EQUAL(sRange, aReturnValue); } diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index 813b61ec538f..4e179080c70a 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -27,6 +27,7 @@ $(eval $(call gb_Library_use_libraries,subsequenttest,\ cppuhelper \ i18nlangtag \ sal \ + sfx \ test \ tl \ utl \ diff --git a/test/source/calc_unoapi_test.cxx b/test/source/calc_unoapi_test.cxx index 578ac9d97c2d..1aaed35f3fb5 100644 --- a/test/source/calc_unoapi_test.cxx +++ b/test/source/calc_unoapi_test.cxx @@ -8,6 +8,7 @@ */ #include <test/calc_unoapi_test.hxx> +#include <sfx2/objsh.hxx> using namespace css; using namespace css::uno; @@ -35,4 +36,17 @@ void CalcUnoApiTest::tearDown() UnoApiTest::tearDown(); } +uno::Any CalcUnoApiTest::executeMacro(const OUString& rScriptURL, const uno::Sequence<uno::Any>& rParams) +{ + uno::Any aRet; + uno::Sequence<sal_Int16> aOutParamIndex; + uno::Sequence<uno::Any> aOutParam; + + ErrCode result = SfxObjectShell::CallXScript( + mxComponent, rScriptURL, + rParams, aRet, aOutParamIndex, aOutParam); + CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, result); + + return aRet; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
