diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-03-24 16:38:18 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-03-24 20:05:13 +0100 |
commit | ab6a7a9addfc059d8f1fbeaa6c6012666629d420 (patch) | |
tree | ae157e4669023a3e934189644f69a07cb52cbb74 | |
parent | a7cf7da8d21d3d4d54bd532f07fc0c4712239dbb (diff) |
sw reqif-xhtml export: fix unexpected height for <td>
The ReqIF validator complains about this, similar to the already
disabled width.
Change-Id: I05137a9dcc7e94bffe92269e98d310724a144b24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113061
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 33 | ||||
-rw-r--r-- | sw/source/filter/html/htmltabw.cxx | 6 |
2 files changed, 39 insertions, 0 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 295acb34f04c..52eb25978a10 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -740,6 +740,39 @@ DECLARE_HTMLEXPORT_TEST(testReqIfTable2, "reqif-table2.odt") CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:td>") != -1); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIfTableHeight) +{ + // Given a document with a table in it, with an explicit row height: + loadURL("private:factory/swriter", nullptr); + uno::Sequence<beans::PropertyValue> aTableProperties = { + comphelper::makePropertyValue("Rows", static_cast<sal_Int32>(1)), + comphelper::makePropertyValue("Columns", static_cast<sal_Int32>(1)), + }; + dispatchCommand(mxComponent, ".uno:InsertTable", aTableProperties); + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), + uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xRow(xTable->getRows()->getByIndex(0), uno::UNO_QUERY); + xRow->setPropertyValue("Height", uno::makeAny(static_cast<sal_Int32>(1000))); + + // When exporting to reqif-xhtml: + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aStoreProperties = { + comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")), + comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")), + }; + xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties); + + // Then make sure that the explicit cell height is omitted from the output: + SvMemoryStream aStream; + HtmlExportTest::wrapFragment(maTempFile, aStream); + xmlDocUniquePtr pDoc = parseXmlStream(&aStream); + // Without the accompanying fix in place, this test would have failed, explicit height was + // written, which is not valid reqif-xhtml. + assertXPathNoAttribute(pDoc, "//reqif-xhtml:td", "height"); +} + DECLARE_HTMLEXPORT_TEST(testXHTMLUseCSS, "xhtml-css.odt") { SvStream* pStream = maTempFile.GetStream(StreamMode::READ); diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx index 4c83319747b7..8c1ace39bc2e 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -380,6 +380,12 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt, sOut.append("\""); } + if (rWrt.mbReqIF) + { + // ReqIF implies strict XHTML: no height for <td>. + nHeight = 0; + } + if( nHeight ) { sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_height) |