sw/qa/extras/htmlexport/htmlexport.cxx | 33 +++++++++++++++++++++++++++++++++ sw/source/filter/html/htmltabw.cxx | 6 ++++++ 2 files changed, 39 insertions(+)
New commits: commit 833de9c3dbf52adaa2e62d0e5f624dce9ec0113d Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Mar 24 16:38:18 2021 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Mar 25 13:49:49 2021 +0100 sw reqif-xhtml export: fix unexpected height for <td> The ReqIF validator complains about this, similar to the already disabled width. (cherry picked from commit ab6a7a9addfc059d8f1fbeaa6c6012666629d420) Change-Id: I05137a9dcc7e94bffe92269e98d310724a144b24 diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 6fdf15730dde..5e1264fcadb4 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -684,6 +684,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 f7d5951ae585..1febebd9ff34 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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits