summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-11-09 14:43:30 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2021-11-09 16:48:16 +0100
commitcf41b69356672dcedc4448661547c10dbe03f98a (patch)
treea073be99c8db89dd90e2854bd5598552e3b33215
parent3187e75adc67f76724848e00a8cff6974ee9c8e4 (diff)
tdf#142033: sc_macros_test: Add unittest
Change-Id: Id569c3f020c50a30f4c55fecdaa3f7849e1cbb47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124917 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sc/qa/extras/macros-test.cxx56
-rw-r--r--sc/qa/extras/testdocuments/tdf142033.odsbin0 -> 8833 bytes
2 files changed, 56 insertions, 0 deletions
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index f888deffd25e..5ef95b2018d7 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -51,6 +51,7 @@ public:
void testTdf114427();
void testTdf107885();
void testRowColumn();
+ void testTdf142033();
void testTdf131562();
void testPasswordProtectedUnicodeString();
void testPasswordProtectedArrayInUserType();
@@ -80,6 +81,7 @@ public:
CPPUNIT_TEST(testTdf114427);
CPPUNIT_TEST(testTdf107885);
CPPUNIT_TEST(testRowColumn);
+ CPPUNIT_TEST(testTdf142033);
CPPUNIT_TEST(testTdf131562);
CPPUNIT_TEST(testPasswordProtectedUnicodeString);
CPPUNIT_TEST(testPasswordProtectedArrayInUserType);
@@ -520,6 +522,60 @@ void ScMacrosTest::testMacroButtonFormControlXlsxExport()
assertXPath(pWorkbookDoc, "//x:workbook/definedNames", 0);
}
+void ScMacrosTest::testTdf142033()
+{
+ OUString aFileName;
+ createFileURL(u"tdf142033.ods", aFileName);
+ uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+
+ Any aRet;
+ Sequence< sal_Int16 > aOutParamIndex;
+ Sequence< Any > aOutParam;
+ Sequence< uno::Any > aParams;
+
+ SfxObjectShell::CallXScript(
+ xComponent,
+ "vnd.sun.Star.script:Standard.Module1.display_bug?language=Basic&location=document",
+ aParams, aRet, aOutParamIndex, aOutParam);
+
+ // Export to ODS
+ uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("calc8");
+ auto pTempFile = std::make_shared<utl::TempFile>();
+ pTempFile->EnableKillingFile();
+ xStorable->storeToURL(pTempFile->GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+ xComponent->dispose();
+
+ xmlDocUniquePtr pContentXml = XPathHelper::parseExport(pTempFile, m_xSFactory, "content.xml");
+ CPPUNIT_ASSERT(pContentXml);
+
+ assertXPathContent(pContentXml,
+ "/office:document-content/office:body/office:spreadsheet/table:table[1]/"
+ "table:table-row[1]/table:table-cell[1]/text:p", "string no newlines");
+
+ assertXPathContent(pContentXml,
+ "/office:document-content/office:body/office:spreadsheet/table:table[1]/"
+ "table:table-row[1]/table:table-cell[2]/text:p[1]", "string with");
+
+ // Without the fix in place, this test would have failed here with
+ // - Expression: xmlXPathNodeSetGetLength(pXmlNodes) > 0
+ assertXPathContent(pContentXml,
+ "/office:document-content/office:body/office:spreadsheet/table:table[1]/"
+ "table:table-row[1]/table:table-cell[2]/text:p[2]", "newlines");
+
+ assertXPathContent(pContentXml,
+ "/office:document-content/office:body/office:spreadsheet/table:table[1]/"
+ "table:table-row[2]/table:table-cell[1]/text:p", "string no newlines");
+
+ assertXPathContent(pContentXml,
+ "/office:document-content/office:body/office:spreadsheet/table:table[1]/"
+ "table:table-row[2]/table:table-cell[2]/text:p[1]", "string with");
+ assertXPathContent(pContentXml,
+ "/office:document-content/office:body/office:spreadsheet/table:table[1]/"
+ "table:table-row[2]/table:table-cell[2]/text:p[2]", "newlines");
+}
+
void ScMacrosTest::testTdf131562()
{
OUString aFileName;
diff --git a/sc/qa/extras/testdocuments/tdf142033.ods b/sc/qa/extras/testdocuments/tdf142033.ods
new file mode 100644
index 000000000000..da49b7323489
--- /dev/null
+++ b/sc/qa/extras/testdocuments/tdf142033.ods
Binary files differ