summaryrefslogtreecommitdiffstats
path: root/sw/qa/extras/htmlexport/htmlexport.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/qa/extras/htmlexport/htmlexport.cxx')
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx58
1 files changed, 48 insertions, 10 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 842289f1dd44..00b5f511002f 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -38,11 +38,11 @@ public:
* Wraps a reqif-xhtml fragment into an XHTML file, so an XML parser can
* parse it.
*/
- void wrapFragment(SvMemoryStream& rStream)
+ static void wrapFragment(const utl::TempFile& rTempFile, SvMemoryStream& rStream)
{
rStream.WriteCharPtr(
"<reqif-xhtml:html xmlns:reqif-xhtml=\"http://www.w3.org/1999/xhtml\">\n");
- SvFileStream aFileStream(maTempFile.GetURL(), StreamMode::READ);
+ SvFileStream aFileStream(rTempFile.GetURL(), StreamMode::READ);
rStream.WriteStream(aFileStream);
rStream.WriteCharPtr("</reqif-xhtml:html>\n");
rStream.Seek(0);
@@ -102,6 +102,11 @@ private:
#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
+{
+};
+
DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testFdo81276, "fdo81276.html")
{
uno::Reference<container::XNameAccess> xPageStyles(getStyles("PageStyles"));
@@ -488,17 +493,25 @@ DECLARE_HTMLEXPORT_TEST(testReqIfJpgImg, "reqif-jpg-img.xhtml")
DECLARE_HTMLEXPORT_TEST(testReqIfTable, "reqif-table.xhtml")
{
- htmlDocPtr pDoc = parseHtml(maTempFile);
+ SvMemoryStream aStream;
+ HtmlExportTest::wrapFragment(maTempFile, aStream);
+ xmlDocPtr pDoc = parseXmlStream(&aStream);
CPPUNIT_ASSERT(pDoc);
// <div> was missing, so the XHTML fragment wasn't a valid
// xhtml.BlkStruct.class type anymore.
- assertXPath(pDoc, "/html/body/div/table/tr/th", 1);
+ assertXPath(pDoc,
+ "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr/reqif-xhtml:th",
+ 1);
// The attribute was present to contain "background" and "border", which is
// ignored in reqif-xhtml.
- assertXPathNoAttribute(pDoc, "/html/body/div/table/tr/th", "style");
+ assertXPathNoAttribute(
+ pDoc, "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr/reqif-xhtml:th",
+ "style");
// The attribute was present, which is not valid in reqif-xhtml.
- assertXPathNoAttribute(pDoc, "/html/body/div/table/tr/th", "bgcolor");
+ assertXPathNoAttribute(
+ pDoc, "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr/reqif-xhtml:th",
+ "bgcolor");
}
DECLARE_HTMLEXPORT_TEST(testReqIfTable2, "reqif-table2.odt")
@@ -564,7 +577,7 @@ DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOle2, "reqif-ole2.xhtml")
{
// Check that the replacement graphic is exported at RTF level.
SvMemoryStream aStream;
- wrapFragment(aStream);
+ wrapFragment(maTempFile, aStream);
xmlDocPtr pDoc = parseXmlStream(&aStream);
CPPUNIT_ASSERT(pDoc);
// Get the path of the RTF data.
@@ -627,7 +640,7 @@ DECLARE_HTMLEXPORT_TEST(testTransparentImage, "transparent-image.odt")
DECLARE_HTMLEXPORT_TEST(testTransparentImageReqIf, "transparent-image.odt")
{
SvMemoryStream aStream;
- wrapFragment(aStream);
+ wrapFragment(maTempFile, aStream);
xmlDocPtr pDoc = parseXmlStream(&aStream);
CPPUNIT_ASSERT(pDoc);
@@ -644,7 +657,7 @@ DECLARE_HTMLEXPORT_TEST(testOleNodataReqIf, "reqif-ole-nodata.odt")
{
// This failed, io::IOException was thrown during the filter() call.
SvMemoryStream aStream;
- wrapFragment(aStream);
+ wrapFragment(maTempFile, aStream);
xmlDocPtr pDoc = parseXmlStream(&aStream);
CPPUNIT_ASSERT(pDoc);
@@ -659,7 +672,7 @@ DECLARE_HTMLEXPORT_TEST(testOleNodataReqIf, "reqif-ole-nodata.odt")
DECLARE_HTMLEXPORT_TEST(testNoLangReqIf, "reqif-no-lang.odt")
{
SvMemoryStream aStream;
- wrapFragment(aStream);
+ wrapFragment(maTempFile, aStream);
xmlDocPtr pDoc = parseXmlStream(&aStream);
CPPUNIT_ASSERT(pDoc);
@@ -683,6 +696,31 @@ DECLARE_HTMLEXPORT_TEST(testFieldShade, "field-shade.odt")
assertXPath(pDoc, "/html/body/p[2]/span/span", 0);
}
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testBlockQuoteReqIf)
+{
+ // Build a document model that uses the Quotations paragraph style.
+ loadURL("private:factory/swriter", nullptr);
+ uno::Reference<beans::XPropertySet> xParagraph(getParagraph(1), uno::UNO_QUERY);
+ xParagraph->setPropertyValue("ParaStyleName", uno::makeAny(OUString("Quotations")));
+
+ // Export it.
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("HTML (StarWriter)");
+ aMediaDescriptor["FilterOptions"] <<= OUString("xhtmlns=reqif-xhtml");
+ xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+ SvMemoryStream aStream;
+ HtmlExportTest::wrapFragment(maTempFile, aStream);
+ xmlDocPtr pDoc = parseXmlStream(&aStream);
+ CPPUNIT_ASSERT(pDoc);
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1
+ // - Actual : 0
+ // i.e. <blackquote> had character (direct) children, which is invalid xhtml.
+ assertXPath(pDoc, "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:blockquote/reqif-xhtml:p", 1);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */