sw/qa/extras/htmlexport/data/reqif-table2.odt |binary sw/qa/extras/htmlexport/htmlexport.cxx | 21 ++++++++++++++++++--- sw/source/filter/html/htmltabw.cxx | 17 +++++++++-------- 3 files changed, 27 insertions(+), 11 deletions(-)
New commits: commit b263c92250834993f954ed9535f67225d330861c Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Apr 18 18:56:05 2018 +0200 sw XHTML export: close <col> for tables By switching to HtmlWriter instead of manually constructing HTML elements / attributes. Also fix a validity problem for ReqIF (transitional XHTML still allows that, so not depending on mbXHTML here). Change-Id: I4f3fef781fdbb4c72824701ad6d380cece8e6f81 Reviewed-on: https://gerrit.libreoffice.org/53120 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sw/qa/extras/htmlexport/data/reqif-table2.odt b/sw/qa/extras/htmlexport/data/reqif-table2.odt new file mode 100644 index 000000000000..772dde0dd6a9 Binary files /dev/null and b/sw/qa/extras/htmlexport/data/reqif-table2.odt differ diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index bafe6798c8c4..a582ac00b41a 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -56,9 +56,12 @@ private: setFilterOptions("XHTML"); else if (getTestName().indexOf("ReqIf") != -1) { - setImportFilterOptions("xhtmlns=reqif-xhtml"); - // Bypass filter detect. - setImportFilterName("HTML (StarWriter)"); + if (OString(filename).endsWith(".xhtml")) + { + setImportFilterOptions("xhtmlns=reqif-xhtml"); + // Bypass filter detect. + setImportFilterName("HTML (StarWriter)"); + } // Export options (implies XHTML). setFilterOptions("xhtmlns=reqif-xhtml"); } @@ -475,6 +478,18 @@ DECLARE_HTMLEXPORT_TEST(testReqIfTable, "reqif-table.xhtml") assertXPathNoAttribute(pDoc, "/html/body/div/table/tr/th", "bgcolor"); } +DECLARE_HTMLEXPORT_TEST(testReqIfTable2, "reqif-table2.odt") +{ + SvStream* pStream = maTempFile.GetStream(StreamMode::READ); + CPPUNIT_ASSERT(pStream); + pStream->Seek(STREAM_SEEK_TO_END); + sal_uInt64 nLength = pStream->Tell(); + pStream->Seek(0); + OString aStream(read_uInt8s_ToOString(*pStream, nLength)); + // This failed, <reqif-xhtml:td width="..."> was written. + CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:td>") != -1); +} + DECLARE_HTMLEXPORT_TEST(testReqIfList, "reqif-list.xhtml") { SvStream* pStream = maTempFile.GetStream(StreamMode::READ); diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx index 0b73f5687afe..28a2d416075a 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -340,6 +340,10 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt, nWidth = GetAbsWidth( nCol, nColSpan ); } + if (rWrt.mbReqIF) + // ReqIF implies strict XHTML: no width for <td>. + bOutWidth = false; + long nHeight = pCell->GetHeight() > 0 ? GetAbsHeight( pCell->GetHeight(), nRow, nRowSpan ) : 0; @@ -734,8 +738,8 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign, const SwWriteTableCol *pColumn = m_aCols[nCol]; - OStringBuffer sOutStr; - sOutStr.append('<').append(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_col); + HtmlWriter html(rWrt.Strm(), rWrt.maNamespace); + html.start(OOO_STRING_SVTOOLS_HTML_col); sal_uInt32 nWidth; bool bRel; @@ -750,14 +754,11 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign, nWidth = bRel ? GetRelWidth(nCol,1) : GetAbsWidth(nCol,1); } - sOutStr.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_width). - append("=\""); if( bRel ) - sOutStr.append(static_cast<sal_Int32>(nWidth)).append('*'); + html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, OString::number(nWidth) + "*"); else - sOutStr.append(static_cast<sal_Int32>(SwHTMLWriter::ToPixel(nWidth,false))); - sOutStr.append("\">"); - rWrt.Strm().WriteCharPtr( sOutStr.makeStringAndClear().getStr() ); + html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, OString::number(SwHTMLWriter::ToPixel(nWidth,false))); + html.end(); if( bColGroups && pColumn->bRightBorder && nCol<nCols-1 ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits