summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-03-24 16:38:18 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-03-25 13:49:49 +0100
commit833de9c3dbf52adaa2e62d0e5f624dce9ec0113d (patch)
tree02b58e18a7709c469d5359dc8472da47376a1a5c
parent2bf5a0a2184343f2f5f48e3dd071fd696430123a (diff)
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
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx33
-rw-r--r--sw/source/filter/html/htmltabw.cxx6
2 files changed, 39 insertions, 0 deletions
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)