From 1aba7cd7385a08e450a4b86ce0b378be5eedb903 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 27 May 2023 11:02:06 +0300 Subject: 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 --- sw/qa/extras/htmlexport/data/tableRight.fodt | 22 ++++++++++++++++++++++ sw/qa/extras/htmlexport/htmlexport.cxx | 14 ++++++++++++++ sw/source/filter/html/htmltabw.cxx | 18 ++++++++++++++---- 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 sw/qa/extras/htmlexport/data/tableRight.fodt 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 @@ + + + + + + + + + + + This is a right aligned table: + + + + + + + + + + + \ No newline at end of file diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 105b19c7ea8d..da0b8bd4c673 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -2645,6 +2645,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 db18995ebb25..d7e5e107969d 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -1113,10 +1113,20 @@ SwHTMLWriter& OutHTML_SwTableNode( SwHTMLWriter& 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(rWrt.GetNamespace() + sOut) ); + if (rWrt.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(rWrt.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(rWrt.GetNamespace() + sOut)); + } } rWrt.IncIndentLevel(); // indent content of
rWrt.m_bLFPossible = true; -- cgit