summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-06-15 12:30:24 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-06-15 22:44:16 +0200
commitfc5357935cc160fd19b61db7cbf7f098962d42a3 (patch)
treea3b7b62cdb299948cd014b8e199b9e64d915c380 /sc
parent157d58605acc714a5756525b567d6b59a1322d35 (diff)
tdf#52602: sc_vba_macro_test: Add unittest
Change-Id: I3e6ab3d8f3e9dddfec90f1a9762e7bf2007c10db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135899 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/extras/testdocuments/tdf52602.xlsbin0 -> 41984 bytes
-rw-r--r--sc/qa/extras/vba-macro-test.cxx41
2 files changed, 41 insertions, 0 deletions
diff --git a/sc/qa/extras/testdocuments/tdf52602.xls b/sc/qa/extras/testdocuments/tdf52602.xls
new file mode 100644
index 000000000000..1770b15fb45d
--- /dev/null
+++ b/sc/qa/extras/testdocuments/tdf52602.xls
Binary files differ
diff --git a/sc/qa/extras/vba-macro-test.cxx b/sc/qa/extras/vba-macro-test.cxx
index 1f93a6247975..456b57822566 100644
--- a/sc/qa/extras/vba-macro-test.cxx
+++ b/sc/qa/extras/vba-macro-test.cxx
@@ -66,6 +66,7 @@ public:
void testVbaRangeSort();
void testTdf107885();
void testTdf131562();
+ void testTdf52602();
void testTdf107902();
void testTdf90278();
void testTdf149531();
@@ -85,6 +86,7 @@ public:
CPPUNIT_TEST(testVbaRangeSort);
CPPUNIT_TEST(testTdf107885);
CPPUNIT_TEST(testTdf131562);
+ CPPUNIT_TEST(testTdf52602);
CPPUNIT_TEST(testTdf107902);
CPPUNIT_TEST(testTdf90278);
CPPUNIT_TEST(testTdf149531);
@@ -736,6 +738,45 @@ void VBAMacroTest::testTdf131562()
pDocSh->DoClose();
}
+void VBAMacroTest::testTdf52602()
+{
+ OUString aFileName;
+ createFileURL(u"tdf52602.xls", aFileName);
+ uno::Reference<css::lang::XComponent> xComponent
+ = 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);
+
+ 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.Modul1.Test_NumberFormat_DateTime?"
+ "language=Basic&location=document",
+ aParams, aRet, aOutParamIndex, aOutParam);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("15:20"), rDoc.GetString(ScAddress(0, 0, 0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("15:20"), rDoc.GetString(ScAddress(0, 1, 0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("03/01/2012 15:20"), rDoc.GetString(ScAddress(1, 0, 0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("03/01/2012 15:20"), rDoc.GetString(ScAddress(1, 1, 0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("03/01/2012 15:20:00"), rDoc.GetString(ScAddress(2, 0, 0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("03/01/2012 15:20:00"), rDoc.GetString(ScAddress(2, 1, 0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("1/3/12 15:20"), rDoc.GetString(ScAddress(3, 0, 0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("1/3/12 15:20"), rDoc.GetString(ScAddress(3, 1, 0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("1/ March 2012"), rDoc.GetString(ScAddress(4, 0, 0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("1/ March 2012"), rDoc.GetString(ScAddress(4, 1, 0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("1/ Mar 2012"), rDoc.GetString(ScAddress(5, 0, 0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("1/ Mar 2012"), rDoc.GetString(ScAddress(5, 1, 0)));
+
+ pDocSh->DoClose();
+}
void VBAMacroTest::testTdf107902()
{
OUString aFileName;