diff options
author | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2021-12-30 19:57:10 +0100 |
---|---|---|
committer | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2022-02-15 07:46:03 +0100 |
commit | 44d237c375b7ef9a5a61a2f752bd19b57649ffbd (patch) | |
tree | 79ab534d175fb69f926a759260834ca7cf3ecce3 /sc/qa/extras/macros-test.cxx | |
parent | 31180cc24f8ff66895c52a2d4aa828ee0dcb34f3 (diff) |
tdf#104902 - Handle embedded newline in Calc's .uno:EnterString
Change-Id: I6377aebb06b6e6873ce61984a887d9e16eecd361
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127766
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Diffstat (limited to 'sc/qa/extras/macros-test.cxx')
-rw-r--r-- | sc/qa/extras/macros-test.cxx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 802f44a0541c..6c41b269111e 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -44,6 +44,7 @@ public: void testPasswordProtectedStarBasic(); void testTdf114427(); void testRowColumn(); + void testTdf104902(); void testTdf142033(); void testPasswordProtectedUnicodeString(); void testPasswordProtectedArrayInUserType(); @@ -70,6 +71,7 @@ public: CPPUNIT_TEST(testPasswordProtectedStarBasic); CPPUNIT_TEST(testTdf114427); CPPUNIT_TEST(testRowColumn); + CPPUNIT_TEST(testTdf104902); CPPUNIT_TEST(testTdf142033); CPPUNIT_TEST(testPasswordProtectedUnicodeString); CPPUNIT_TEST(testPasswordProtectedArrayInUserType); @@ -322,6 +324,44 @@ void ScMacrosTest::testMacroButtonFormControlXlsxExport() assertXPath(pWorkbookDoc, "//x:workbook/definedNames", 0); } +void ScMacrosTest::testTdf104902() +{ + OUString aFileName; + createFileURL(u"tdf104902.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 + saveAndReload(xComponent, "calc8"); + CPPUNIT_ASSERT(xComponent); + + 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("string no newlines"), rDoc.GetString(ScAddress(0, 0, 0))); + + // Without the fix in place, this test would have failed with + // - Expected: string with + // newlines + // - Actual : string withnewlines + CPPUNIT_ASSERT_EQUAL(OUString(u"string with" + OUStringChar(u'\xA') + u"newlines"), rDoc.GetString(ScAddress(0, 1, 0))); + + css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW); + xCloseable->close(true); +} + void ScMacrosTest::testTdf142033() { OUString aFileName; |