diff options
Diffstat (limited to 'sw/qa/extras/htmlexport/htmlexport.cxx')
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 113 |
1 files changed, 76 insertions, 37 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 2554e7d23a7b..cf370a324789 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -127,10 +127,11 @@ private: FieldUnit m_eUnit; public: - HtmlExportTest() : - SwModelTestBase("/sw/qa/extras/htmlexport/data/", "HTML (StarWriter)"), - m_eUnit(FieldUnit::NONE) - {} + HtmlExportTest() + : SwModelTestBase("/sw/qa/extras/htmlexport/data/", "HTML (StarWriter)") + , m_eUnit(FieldUnit::NONE) + { + } /** * Wraps a reqif-xhtml fragment into an XHTML file, so an XML parser can @@ -193,11 +194,10 @@ private: { // FIXME if padding-top gets exported as inches, not cms, we get rounding errors. SwGlobals::ensure(); // make sure that SW_MOD() is not 0 - std::unique_ptr<Resetter> pResetter(new Resetter( - [this] () { - SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false)); - pPref->SetMetric(this->m_eUnit); - })); + std::unique_ptr<Resetter> pResetter(new Resetter([this]() { + SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false)); + pPref->SetMetric(this->m_eUnit); + })); SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false)); m_eUnit = pPref->GetMetric(); pPref->SetMetric(FieldUnit::CM); @@ -205,10 +205,10 @@ private: } return nullptr; } - }; -#define DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, nullptr, HtmlExportTest) +#define DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(TestName, filename) \ + DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, nullptr, HtmlExportTest) /// HTML export of the sw doc model tests. class SwHtmlDomExportTest : public SwModelTestBase, public HtmlTestTools @@ -275,7 +275,8 @@ DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testFdo86857, "fdo86857.html") CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), getProperty<sal_Int32>(xStyle, "BackColor")); // check that table background color works, which still uses RES_BACKGROUND uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), + uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); @@ -286,27 +287,35 @@ DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testCharacterBorder, "charborder.odt") { CPPUNIT_ASSERT_EQUAL(1, getPages()); - uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 1), uno::UNO_QUERY); // Different Border { - CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0x6666FF,12,12,12,3,37), getProperty<table::BorderLine2>(xRun,"CharTopBorder")); - CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF9900,0,99,0,2,99), getProperty<table::BorderLine2>(xRun,"CharLeftBorder")); - CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF0000,0,169,0,1,169), getProperty<table::BorderLine2>(xRun,"CharBottomBorder")); - CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0x0000FF,0,169,0,0,169), getProperty<table::BorderLine2>(xRun,"CharRightBorder")); + CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0x6666FF, 12, 12, 12, 3, 37), + getProperty<table::BorderLine2>(xRun, "CharTopBorder")); + CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF9900, 0, 99, 0, 2, 99), + getProperty<table::BorderLine2>(xRun, "CharLeftBorder")); + CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF0000, 0, 169, 0, 1, 169), + getProperty<table::BorderLine2>(xRun, "CharBottomBorder")); + CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0x0000FF, 0, 169, 0, 0, 169), + getProperty<table::BorderLine2>(xRun, "CharRightBorder")); } // Different Padding { - CPPUNIT_ASSERT_EQUAL(sal_Int32(450), getProperty<sal_Int32>(xRun,"CharTopBorderDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(550), getProperty<sal_Int32>(xRun,"CharLeftBorderDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xRun,"CharBottomBorderDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xRun,"CharRightBorderDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(450), getProperty<sal_Int32>(xRun, "CharTopBorderDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(550), + getProperty<sal_Int32>(xRun, "CharLeftBorderDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(150), + getProperty<sal_Int32>(xRun, "CharBottomBorderDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(250), + getProperty<sal_Int32>(xRun, "CharRightBorderDistance")); } // No shadow } -#define DECLARE_HTMLEXPORT_TEST(TestName, filename) DECLARE_SW_EXPORT_TEST(TestName, filename, nullptr, HtmlExportTest) +#define DECLARE_HTMLEXPORT_TEST(TestName, filename) \ + DECLARE_SW_EXPORT_TEST(TestName, filename, nullptr, HtmlExportTest) DECLARE_HTMLEXPORT_TEST(testExportOfImages, "textAndImage.docx") { @@ -420,7 +429,8 @@ DECLARE_HTMLEXPORT_TEST(testExportUrlEncoding, "tdf76291.odt") CPPUNIT_ASSERT(pDoc); // Test URI encoded hyperlink with Chinese characters - assertXPath(pDoc, "/html/body/p/a", "href", "http://www.youtube.com/results?search_query=%E7%B2%B5%E8%AA%9Emv&sm=12"); + assertXPath(pDoc, "/html/body/p/a", "href", + "http://www.youtube.com/results?search_query=%E7%B2%B5%E8%AA%9Emv&sm=12"); } DECLARE_HTMLEXPORT_TEST(testExportInternalUrl, "tdf90905.odt") @@ -440,7 +450,35 @@ DECLARE_HTMLEXPORT_TEST(testExportImageBulletList, "tdf66822.odt") // Encoded base64 SVG bullet should match and render on browser assertXPath(pDoc, "/html/body/ul", 1); - assertXPath(pDoc, "/html/body/ul", "style", "list-style-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxMi4wLjEsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDUxNDQ4KSAgLS0+DQo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiIFsNCgk8IUVOVElUWSBuc19zdmcgImh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCgk8IUVOVElUWSBuc194bGluayAiaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+DQpdPg0KPHN2ZyAgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9IiZuc19zdmc7IiB4bWxuczp4bGluaz0iJm5zX3hsaW5rOyIgd2lkdGg9IjE0LjAwOCIgaGVpZ2h0PSIxNC4wMSINCgkgdmlld0JveD0iMCAwIDE0LjAwOCAxNC4wMSIgb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CAxIDAiLz4NCgkJPC9maWx0ZXI+" + "DQoJPC9kZWZzPg0KCTxtYXNrIG1hc2tVbml0cz0idXNlclNwYWNlT25Vc2UiIHg9IjMuNDgxIiB5PSIwLjY5MyIgd2" + "lkdGg9IjYuOTg4IiBoZWlnaHQ9IjMuODkzIiBpZD0iWE1MSURfNV8iPg0KCQk8ZyBmaWx0ZXI9InVybCgjQWRvYmVf" + "T3BhY2l0eU1hc2tGaWx0ZXIpIj4NCgkJCTxsaW5lYXJHcmFkaWVudCBpZD0iWE1MSURfNl8iIGdyYWRpZW50VW5pdH" + "M9InVzZXJTcGFjZU9uVXNlIiB4MT0iNy4xMjIxIiB5MT0iMC4xMDMiIHgyPSI3LjEyMjEiIHkyPSI1LjIzNDQiPg0K" + "CQkJCTxzdG9wICBvZmZzZXQ9IjAiIHN0eWxlPSJzdG9wLWNvbG9yOiNGRkZGRkYiLz4NCgkJCQk8c3RvcCAgb2Zmc2" + "V0PSIxIiBzdHlsZT0ic3RvcC1jb2xvcjojMDAwMDAwIi8+DQoJCQk8L2xpbmVhckdyYWRpZW50Pg0KCQkJPHJlY3Qg" + "eD0iMy4xOTkiIHk9IjAuMzM5IiBvcGFjaXR5PSIwLjciIGZpbGw9InVybCgjWE1MSURfNl8pIiB3aWR0aD0iNy44ND" + "YiIGhlaWdodD0iNC42MDEiLz4NCgkJPC9nPg0KCTwvbWFzaz4NCgk8ZWxsaXBzZSBtYXNrPSJ1cmwoI1hNTElEXzVf" + "KSIgZmlsbD0iI0ZGRkZGRiIgY3g9IjYuOTc1IiBjeT0iMi42NCIgcng9IjMuNDk0IiByeT0iMS45NDYiLz4NCjwvZz" + "4NCjwvc3ZnPg0K);"); } DECLARE_HTMLEXPORT_TEST(testTdf83890, "tdf83890.odt") @@ -453,7 +491,7 @@ DECLARE_HTMLEXPORT_TEST(testTdf83890, "tdf83890.odt") DECLARE_HTMLEXPORT_TEST(testExtbChars, "extb.html") { - OUString aExpected( u"\U00024b62"); + OUString aExpected(u"\U00024b62"); // Assert that UTF8 encoded non-BMP Unicode character is correct uno::Reference<text::XTextRange> xTextRange1 = getRun(getParagraph(1), 1); CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange1->getString()); @@ -512,9 +550,9 @@ DECLARE_HTMLEXPORT_TEST(testReqIfParagraph, "reqif-p.xhtml") sal_uInt64 nLength = pStream->TellEnd(); OString aExpected = "<reqif-xhtml:div><reqif-xhtml:p>aaa<reqif-xhtml:br/>\nbbb" - "</reqif-xhtml:p>" SAL_NEWLINE_STRING - // This was '<table' instead. - "<reqif-xhtml:table"; + "</reqif-xhtml:p>" SAL_NEWLINE_STRING + // This was '<table' instead. + "<reqif-xhtml:table"; OString aStream(read_uInt8s_ToOString(*pStream, nLength)); pStream->Seek(0); @@ -532,7 +570,8 @@ DECLARE_HTMLEXPORT_TEST(testReqIfParagraph, "reqif-p.xhtml") CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:strong>") != -1); // This was "<strike>" instead of CSS. - CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:span style=\"text-decoration: line-through\"") != -1); + CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:span style=\"text-decoration: line-through\"") + != -1); // This was "<font>" instead of CSS + namespace prefix was missing. CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:span style=\"color: #ce181e\"") != -1); @@ -700,7 +739,8 @@ DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOle2, "reqif-ole2.xhtml") uno::UNO_QUERY); uno::Reference<document::XEmbeddedObjectSupplier2> xObject(xObjects->getByIndex(0), uno::UNO_QUERY); - uno::Reference<io::XActiveDataStreamer> xEmbeddedObject(xObject->getExtendedControlOverEmbeddedObject(), uno::UNO_QUERY); + uno::Reference<io::XActiveDataStreamer> xEmbeddedObject( + xObject->getExtendedControlOverEmbeddedObject(), uno::UNO_QUERY); // This failed, the "RTF fragment" native data was loaded as-is, we had no // filter to handle it, so nothing happened on double-click. CPPUNIT_ASSERT(xEmbeddedObject.is()); @@ -940,10 +980,9 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifComment) { // Create a document with a comment in it. loadURL("private:factory/swriter", nullptr); - uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( - { - {"Text", uno::makeAny(OUString("some text"))}, - {"Author", uno::makeAny(OUString("me"))}, + uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence({ + { "Text", uno::makeAny(OUString("some text")) }, + { "Author", uno::makeAny(OUString("me")) }, }); dispatchCommand(mxComponent, ".uno:InsertAnnotation", aPropertyValues); @@ -1101,8 +1140,7 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifOle1Paint) comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")), comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")), }; - mxComponent - = loadFromDesktop(aURL, "com.sun.star.text.TextDocument", aLoadProperties); + mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument", aLoadProperties); // Save it as ODT to inspect the result of the OLE1 -> OLE2 conversion. uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); @@ -1211,7 +1249,8 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testUnderlineNone) uno::Reference<text::XText> xText = xTextDocument->getText(); xText->insertString(xText->getEnd(), "x", /*bAbsorb=*/false); uno::Reference<beans::XPropertySet> xParagraph(getParagraph(1), uno::UNO_QUERY); - xParagraph->setPropertyValue("CharUnderline", uno::makeAny(sal_Int16(awt::FontUnderline::NONE))); + xParagraph->setPropertyValue("CharUnderline", + uno::makeAny(sal_Int16(awt::FontUnderline::NONE))); // Export to reqif-xhtml. uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); |