diff options
author | Henry Castro <hcastro@collabora.com> | 2023-02-13 16:00:18 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-02-15 12:16:35 +0000 |
commit | d3aca6535793a3621bb1983e5bc754076a25ace1 (patch) | |
tree | 90cd2ac48b2cafa2b511594b16b20f2ec9970215 | |
parent | d73a947288788ee59a4a1a2f0b50ae1cb6e55cef (diff) |
sc: qa: add single line paragraph unit test
to preserve character attributes.
Signed-off-by: Henry Castro <hcastro@collabora.com>
Change-Id: I1a56843a80e18ee47e77a31212725ca473eb68df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146946
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | sc/qa/extras/scpdfexport.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sc/qa/extras/scpdfexport.cxx b/sc/qa/extras/scpdfexport.cxx index 8af237856260..ee845b9312dd 100644 --- a/sc/qa/extras/scpdfexport.cxx +++ b/sc/qa/extras/scpdfexport.cxx @@ -73,6 +73,7 @@ public: void testTdf84012(); void testTdf78897(); void testForcepoint97(); + void testSingleLineAttribs(); CPPUNIT_TEST_SUITE(ScPDFExportTest); CPPUNIT_TEST(testExportRange_Tdf120161); @@ -83,6 +84,7 @@ public: CPPUNIT_TEST(testTdf84012); CPPUNIT_TEST(testTdf78897); CPPUNIT_TEST(testForcepoint97); + CPPUNIT_TEST(testSingleLineAttribs); CPPUNIT_TEST_SUITE_END(); }; @@ -602,6 +604,38 @@ void ScPDFExportTest::testForcepoint97() std::shared_ptr<utl::TempFile> pPDFFile = exportToPDF(xModel, range1); } +void ScPDFExportTest::testSingleLineAttribs() +{ + // create test document + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<sheet::XSpreadsheetDocument> xDoc(xModel, uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_SET_THROW); + xSheets->insertNewByName("Test Sheet", 0); + + { + SfxObjectShell* pDocShell = SfxObjectShell::GetShellFromComponent(mxComponent); + CPPUNIT_ASSERT(pDocShell); + ScDocShellRef xDocSh = dynamic_cast<ScDocShell*>(pDocShell); + CPPUNIT_ASSERT(xDocSh); + + ScDocument& rDoc = xDocSh->GetDocument(); + ScFieldEditEngine& rEditEngine = rDoc.GetEditEngine(); + + rEditEngine.Clear(); + rEditEngine.SetTextCurrentDefaults("Bolivia.\nSucre"); + setFont(rEditEngine, 9, 5, "DejaVuSans"); + rDoc.SetEditText(ScAddress(0, 0, 0), rEditEngine.CreateTextObject()); + } + + { + ScRange range1(0, 0, 0, 1, 0, 0); + std::shared_ptr<utl::TempFile> pPDFFile = exportToPDF(xModel, range1); + bool bFound = false; + CPPUNIT_ASSERT(hasTextInPdf(pPDFFile, "DejaVuSans", bFound)); + CPPUNIT_ASSERT_EQUAL(true, bFound); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScPDFExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); |