sw/qa/extras/htmlexport/data/tableRight.fodt | 22 ++++++++++++++++++++++ sw/qa/extras/htmlexport/htmlexport.cxx | 14 ++++++++++++++ sw/source/filter/html/htmltabw.cxx | 19 +++++++++++++++---- 3 files changed, 51 insertions(+), 4 deletions(-)
New commits: commit ff8a99c40b9829b4062c94c3b3e3286f47ae5e17 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat May 27 11:02:06 2023 +0300 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue May 30 11:51:01 2023 +0200 ReqIF: do not write 'align' attribute to 'div' element To keep the alignment information, use 'style' in this case. Maybe it makes sense to unify on 'style' also in normal case in a later change. Change-Id: I6e07acd46fbabeaa47ae9dbe71c00e1b1abc6b73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152340 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152367 diff --git a/sw/qa/extras/htmlexport/data/tableRight.fodt b/sw/qa/extras/htmlexport/data/tableRight.fodt new file mode 100644 index 000000000000..374364750f51 --- /dev/null +++ b/sw/qa/extras/htmlexport/data/tableRight.fodt @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:automatic-styles> + <style:style style:name="Table1" style:family="table"> + <style:table-properties style:width="10cm" table:align="right"/> + </style:style> + </office:automatic-styles> + <office:body> + <office:text> + <text:p>This is a right aligned table:</text:p> + <table:table table:style-name="Table1"> + <table:table-column table:number-columns-repeated="2"/> + <table:table-row> + <table:table-cell/> + <table:table-cell/> + </table:table-row> + </table:table> + <text:p/> + </office:text> + </office:body> +</office:document> \ No newline at end of file diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 0cac6b56af8c..0ba830337da6 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -2527,6 +2527,20 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTdf155496) CPPUNIT_ASSERT_EQUAL(OUString("list 1 item 1\n\t\tsub-header"), aContent.trim()); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_RightAlignedTable) +{ + createSwDoc("tableRight.fodt"); + ExportToReqif(); + + SvMemoryStream aStream; + WrapReqifFromTempFile(aStream); + xmlDocUniquePtr pDoc = parseXmlStream(&aStream); + CPPUNIT_ASSERT(pDoc); + + // No 'align' attribute must be present in 'div' + assertXPathNoAttribute(pDoc, "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:div", "align"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx index 538a509db53c..acc9e6f76049 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -1115,10 +1115,21 @@ Writer& OutHTML_SwTableNode( Writer& rWrt, SwTableNode & rNode, } else { - OStringLiteral sOut = OOO_STRING_SVTOOLS_HTML_division - " " OOO_STRING_SVTOOLS_HTML_O_align "=\"" - OOO_STRING_SVTOOLS_HTML_AL_right "\""; - HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rHTMLWrt.GetNamespace() + sOut) ); + if (rHTMLWrt.mbReqIF) + { + // In ReqIF, div cannot have an 'align' attribute. For now, use 'style' only + // for ReqIF; maybe it makes sense to use it in both cases? + static constexpr char sOut[] = OOO_STRING_SVTOOLS_HTML_division + " style=\"display: flex; flex-direction: column; align-items: flex-end\""; + HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), Concat2View(rHTMLWrt.GetNamespace() + sOut)); + } + else + { + static constexpr char sOut[] = OOO_STRING_SVTOOLS_HTML_division + " " OOO_STRING_SVTOOLS_HTML_O_align "=\"" + OOO_STRING_SVTOOLS_HTML_AL_right "\""; + HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), Concat2View(rHTMLWrt.GetNamespace() + sOut) ); + } } rHTMLWrt.IncIndentLevel(); // indent content of <CENTER> rHTMLWrt.m_bLFPossible = true;