tdf131562: sc_macros_test: Add unittest
Change-Id: I08e8dd0230a6c900d0a88a015d066bffc2e8e8b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98475
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index ee1aa5c6..8aa86fa 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -36,6 +36,7 @@ public:
void testMSP();
void testPasswordProtectedStarBasic();
void testRowColumn();
void testTdf131562();
void testPasswordProtectedUnicodeString();
void testTdf131296_legacy();
void testTdf131296_new();
@@ -46,6 +47,7 @@ public:
CPPUNIT_TEST(testVba);
CPPUNIT_TEST(testPasswordProtectedStarBasic);
CPPUNIT_TEST(testRowColumn);
CPPUNIT_TEST(testTdf131562);
CPPUNIT_TEST(testPasswordProtectedUnicodeString);
CPPUNIT_TEST(testTdf131296_legacy);
CPPUNIT_TEST(testTdf131296_new);
@@ -393,6 +395,40 @@ void ScMacrosTest::testRowColumn()
pDocSh->DoClose();
}
void ScMacrosTest::testTdf131562()
{
OUString aFileName;
createFileURL("tdf131562.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();
CPPUNIT_ASSERT_EQUAL(OUString("1"), rDoc.GetString(ScAddress(0,2,0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), rDoc.GetString(ScAddress(0,3,0)));
SfxObjectShell::CallXScript(
xComponent,
"vnd.sun.Star.script:VBAProject.Munka1.numberconcat?language=Basic&location=document",
aParams, aRet, aOutParamIndex, aOutParam);
//Without the fix in place, the macro wouldn't have concatenated 1 and " ."
CPPUNIT_ASSERT_EQUAL(OUString("1 ."), rDoc.GetString(ScAddress(0,2,0)));
CPPUNIT_ASSERT_EQUAL(OUString("1 .cat"), rDoc.GetString(ScAddress(0,3,0)));
pDocSh->DoClose();
}
void ScMacrosTest::testPasswordProtectedUnicodeString()
{
const OUString sCorrectString(u"English Русский 中文");
diff --git a/sc/qa/extras/testdocuments/tdf131562.xlsm b/sc/qa/extras/testdocuments/tdf131562.xlsm
new file mode 100644
index 0000000..e56576b
--- /dev/null
+++ b/sc/qa/extras/testdocuments/tdf131562.xlsm
Binary files differ