summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@collabora.co.uk>2022-10-10 13:42:22 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-10-13 18:14:26 +0200
commit113d41180c8647a381b06a17186fc4485ff11bd3 (patch)
tree4a4474bbea735725a92968d8f9ccf1594962119a
parenttdf#125363, tdf#123095 - Use CaseTransliteration for autofilter (diff)
downloadcore-113d41180c8647a381b06a17186fc4485ff11bd3.tar.gz
core-113d41180c8647a381b06a17186fc4485ff11bd3.zip
improve setup/teardown handling in VBAMacrosTest
do the same thing that the other UnoApiTest subclasses are doing, seems to fix the problem for me Change-Id: I0d5288b638a5c8d6994fae5ae5d99f2f29bcf377 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141155 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141300
-rw-r--r--sc/qa/extras/vba-macro-test.cxx115
1 files changed, 56 insertions, 59 deletions
diff --git a/sc/qa/extras/vba-macro-test.cxx b/sc/qa/extras/vba-macro-test.cxx
index 5b3100502c79..18ac229538a2 100644
--- a/sc/qa/extras/vba-macro-test.cxx
+++ b/sc/qa/extras/vba-macro-test.cxx
@@ -38,6 +38,8 @@ public:
{
}
+ virtual void tearDown() override;
+
void testSimpleCopyAndPaste();
void testMultiDocumentCopyAndPaste();
void testSheetAndColumnSelectAndHide();
@@ -71,8 +73,17 @@ public:
CPPUNIT_TEST(testTdf107902);
CPPUNIT_TEST(testTdf90278);
CPPUNIT_TEST_SUITE_END();
+
+private:
+ uno::Reference<lang::XComponent> mxComponent;
};
+void VBAMacroTest::tearDown()
+{
+ closeDocument(mxComponent);
+ UnoApiTest::tearDown();
+}
+
void VBAMacroTest::testSimpleCopyAndPaste()
{
// Copy-paste values in the same sheet
@@ -83,15 +94,14 @@ void VBAMacroTest::testSimpleCopyAndPaste()
OUString aFileName;
createFileURL(u"SimpleCopyPaste.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ 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(xComponent);
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
@@ -107,7 +117,7 @@ void VBAMacroTest::testSimpleCopyAndPaste()
CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 5, 0)));
SfxObjectShell::CallXScript(
- xComponent, "vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document",
+ mxComponent, "vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
// Copy from C4-C6
@@ -141,15 +151,14 @@ void VBAMacroTest::testMultiDocumentCopyAndPaste()
OUString aFileName;
createFileURL(u"MultiDocumentCopyPaste.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ 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(xComponent);
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
@@ -160,7 +169,7 @@ void VBAMacroTest::testMultiDocumentCopyAndPaste()
CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 3, 0)));
SfxObjectShell::CallXScript(
- xComponent, "vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document",
+ mxComponent, "vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
CPPUNIT_ASSERT_EQUAL(200.0, rDoc.GetValue(ScAddress(1, 1, 0)));
@@ -174,10 +183,9 @@ void VBAMacroTest::testSheetAndColumnSelectAndHide()
{
OUString aFileName;
createFileURL(u"SheetAndColumnSelectAndHide.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
- SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
@@ -205,7 +213,7 @@ void VBAMacroTest::testSheetAndColumnSelectAndHide()
uno::Sequence<uno::Any> aParams;
SfxObjectShell::CallXScript(
- xComponent,
+ mxComponent,
"vnd.sun.Star.script:VBAProject.ThisWorkbook.testHide?language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
@@ -224,7 +232,7 @@ void VBAMacroTest::testSheetAndColumnSelectAndHide()
CPPUNIT_ASSERT_EQUAL(SCTAB(0), rViewData.GetTabNo());
SfxObjectShell::CallXScript(
- xComponent,
+ mxComponent,
"vnd.sun.Star.script:VBAProject.ThisWorkbook.testUnhide?language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
@@ -252,10 +260,9 @@ void VBAMacroTest::testPrintArea()
OUString aFileName;
createFileURL(u"VariousTestMacros.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
- uno::Reference<sheet::XSpreadsheetDocument> xDoc(xComponent, uno::UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
uno::Reference<sheet::XPrintAreas> xPrintAreas(xSheet, uno::UNO_QUERY_THROW);
@@ -270,7 +277,7 @@ void VBAMacroTest::testPrintArea()
uno::Sequence<uno::Any> aOutParam;
uno::Sequence<uno::Any> aParams;
- SfxObjectShell::CallXScript(xComponent,
+ SfxObjectShell::CallXScript(mxComponent,
"vnd.sun.Star.script:VBAProject.ThisWorkbook.testPrintArea?"
"language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
@@ -280,7 +287,7 @@ void VBAMacroTest::testPrintArea()
CPPUNIT_ASSERT_EQUAL(true, aSequence.hasElements());
}
- css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW);
xCloseable->close(true);
}
@@ -291,10 +298,9 @@ void VBAMacroTest::testSelectAllChaged()
OUString aFileName;
createFileURL(u"VariousTestMacros.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
- SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
@@ -308,7 +314,7 @@ void VBAMacroTest::testSelectAllChaged()
uno::Sequence<uno::Any> aOutParam;
uno::Sequence<uno::Any> aParams;
- SfxObjectShell::CallXScript(xComponent,
+ SfxObjectShell::CallXScript(mxComponent,
"vnd.sun.Star.script:VBAProject.ThisWorkbook.testSelectAll?"
"language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
@@ -326,10 +332,9 @@ void VBAMacroTest::testRangeSelect()
OUString aFileName;
createFileURL(u"VariousTestMacros.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
- SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
@@ -343,7 +348,7 @@ void VBAMacroTest::testRangeSelect()
uno::Sequence<uno::Any> aOutParam;
uno::Sequence<uno::Any> aParams;
- SfxObjectShell::CallXScript(xComponent,
+ SfxObjectShell::CallXScript(mxComponent,
"vnd.sun.Star.script:VBAProject.ThisWorkbook.testRangeSelect?"
"language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
@@ -362,20 +367,19 @@ void VBAMacroTest::testWindowState()
OUString aFileName;
createFileURL(u"VariousTestMacros.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ 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(xComponent,
+ SfxObjectShell::CallXScript(mxComponent,
"vnd.sun.Star.script:VBAProject.ThisWorkbook.testWindowState?"
"language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
- css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW);
xCloseable->close(true);
}
@@ -386,10 +390,9 @@ void VBAMacroTest::testScroll()
OUString aFileName;
createFileURL(u"VariousTestMacros.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
- SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
@@ -407,7 +410,7 @@ void VBAMacroTest::testScroll()
uno::Sequence<uno::Any> aParams;
SfxObjectShell::CallXScript(
- xComponent,
+ mxComponent,
"vnd.sun.Star.script:VBAProject.ThisWorkbook.testScroll?language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
@@ -425,10 +428,9 @@ void VBAMacroTest::testMacroKeyBinding()
OUString aFileName;
createFileURL(u"KeyShortcut.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
- uno::Reference<frame::XModel> xModel(xComponent, uno::UNO_QUERY);
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
CPPUNIT_ASSERT(xModel.is());
uno::Reference<ui::XUIConfigurationManagerSupplier> xConfigSupplier(xModel, uno::UNO_QUERY);
@@ -456,7 +458,7 @@ void VBAMacroTest::testMacroKeyBinding()
"vnd.sun.star.script:VBAProject.ThisWorkbook.key_T?language=Basic&location=document"),
xAccelerator->getCommandByKeyEvent(aCtrlT));
- css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW);
xCloseable->close(true);
}
@@ -558,8 +560,7 @@ void VBAMacroTest::testVba()
{
OUString aFileName;
createFileURL(OUStringConcatenation(rTestInfo.sFileBaseName + "xls"), aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
// process all events such as OnLoad events etc. otherwise they tend
// to arrive later at a random time - while processing other StarBasic
@@ -579,7 +580,7 @@ void VBAMacroTest::testVba()
SAL_INFO("sc.qa", "about to invoke vba test in " << aFileName << " with url "
<< rTestInfo.sMacroUrl);
- SfxObjectShell::CallXScript(xComponent, rTestInfo.sMacroUrl, aParams, aRet, aOutParamIndex,
+ SfxObjectShell::CallXScript(mxComponent, rTestInfo.sMacroUrl, aParams, aRet, aOutParamIndex,
aOutParam);
OUString aStringRes;
aRet >>= aStringRes;
@@ -589,7 +590,7 @@ void VBAMacroTest::testVba()
.getStr(),
OUString("OK"), aStringRes);
- css::uno::Reference<css::util::XCloseable> xCloseable(xComponent,
+ css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent,
css::uno::UNO_QUERY_THROW);
xCloseable->close(true);
@@ -608,15 +609,14 @@ void VBAMacroTest::testTdf107885()
{
OUString aFileName;
createFileURL(u"tdf107885.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ 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(xComponent);
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
@@ -629,7 +629,7 @@ void VBAMacroTest::testTdf107885()
// Call auto filter macro using a string condition
SfxObjectShell::CallXScript(
- xComponent,
+ mxComponent,
"vnd.sun.Star.script:VBAProject.Module1.AFString?language=Basic&location=document", aParams,
aRet, aOutParamIndex, aOutParam);
@@ -641,7 +641,7 @@ void VBAMacroTest::testTdf107885()
// Call auto filter macro using a numeric condition without any locale
SfxObjectShell::CallXScript(
- xComponent,
+ mxComponent,
"vnd.sun.Star.script:VBAProject.Module1.AFNumeric?language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
@@ -657,15 +657,14 @@ void VBAMacroTest::testTdf131562()
{
OUString aFileName;
createFileURL(u"tdf131562.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ 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(xComponent);
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
@@ -675,7 +674,7 @@ void VBAMacroTest::testTdf131562()
CPPUNIT_ASSERT_EQUAL(OUString(""), rDoc.GetString(ScAddress(0, 3, 0)));
SfxObjectShell::CallXScript(
- xComponent,
+ mxComponent,
"vnd.sun.Star.script:VBAProject.Munka1.numberconcat?language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
@@ -690,15 +689,14 @@ void VBAMacroTest::testTdf107902()
{
OUString aFileName;
createFileURL(u"tdf107902.xlsm", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ 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(xComponent);
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(mxComponent);
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
@@ -706,7 +704,7 @@ void VBAMacroTest::testTdf107902()
//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",
+ mxComponent, "vnd.sun.Star.script:VBAProject.Module1.AF?language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
//Check the autofilter was created
@@ -730,8 +728,7 @@ void VBAMacroTest::testTdf90278()
{
OUString aFileName;
createFileURL(u"tdf90278.xls", aFileName);
- uno::Reference<css::lang::XComponent> xComponent
- = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
uno::Any aRet;
uno::Sequence<sal_Int16> aOutParamIndex;
@@ -741,7 +738,7 @@ void VBAMacroTest::testTdf90278()
// Without the fix in place, changing the border weight
// would cause a Basic exception/error in the following script.
SfxObjectShell::CallXScript(
- xComponent,
+ mxComponent,
"vnd.sun.Star.script:VBAProject.Module1.BorderWeight?language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
@@ -750,7 +747,7 @@ void VBAMacroTest::testTdf90278()
aRet >>= aReturnValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aReturnValue);
- css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW);
xCloseable->close(true);
}