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(-)

New commits:
commit 1aba7cd7385a08e450a4b86ce0b378be5eedb903
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat May 27 11:02:06 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sat May 27 15:19:47 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>

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 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 <CENTER>
         rWrt.m_bLFPossible = true;

Reply via email to