sw/qa/extras/htmlexport/data/tdf155871.fodt |   21 +++++++++++++++++++++
 sw/qa/extras/htmlexport/htmlexport.cxx      |   12 ++++++++++++
 sw/source/filter/html/htmlnumwriter.cxx     |    2 +-
 3 files changed, 34 insertions(+), 1 deletion(-)

New commits:
commit df98b6015cd2ae4f1573e12cee1b1bc947adabf0
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Jun 16 16:22:22 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Jun 16 19:12:34 2023 +0200

    tdf#155871: don't forget to close li before starting next
    
    When closing a nested list, the previous condition failed to close
    the last li in case when the next item is numbered (i.e., will need
    another li). Indeed, if the next item is unnumbered, current last
    li should stay open.
    
    Change-Id: Iad7d83d50d2f02d6bd1d046804b7e23b59f9ce8b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153179
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/qa/extras/htmlexport/data/tdf155871.fodt 
b/sw/qa/extras/htmlexport/data/tdf155871.fodt
new file mode 100644
index 000000000000..97e29fbe69b8
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/tdf155871.fodt
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:body>
+  <office:text>
+   <text:list>
+    <text:list-item>
+     <text:p>foo</text:p>
+     <text:list>
+      <text:list-item>
+       <text:p>bar</text:p>
+      </text:list-item>
+     </text:list>
+    </text:list-item>
+    <text:list-item>
+     <text:p>baz</text:p>
+    </text:list-item>
+   </text:list>
+  </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 c4479353e7f5..496ba550729c 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -2687,6 +2687,18 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, 
testReqIF_ListsWithNumFormat)
     assertXPathNoAttribute(pDoc, 
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:ol[4]", "type");
 }
 
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTdf155871)
+{
+    createSwDoc("tdf155871.fodt");
+    ExportToReqif();
+
+    SvMemoryStream aStream;
+    WrapReqifFromTempFile(aStream);
+    xmlDocUniquePtr pDoc = parseXmlStream(&aStream);
+    // Without the fix in place, this would fail
+    CPPUNIT_ASSERT(pDoc);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlnumwriter.cxx 
b/sw/source/filter/html/htmlnumwriter.cxx
index 6f8f52cc3f7c..8fa9b0074c99 100644
--- a/sw/source/filter/html/htmlnumwriter.cxx
+++ b/sw/source/filter/html/htmlnumwriter.cxx
@@ -320,7 +320,7 @@ SwHTMLWriter& OutHTML_NumberBulletListEnd( SwHTMLWriter& 
rWrt,
         else
             aTag = OOO_STRING_SVTOOLS_HTML_orderlist;
         HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), 
Concat2View(rWrt.GetNamespace() + aTag), false );
-        if (rWrt.mbXHTML && i != nNextDepth + 1)
+        if (rWrt.mbXHTML && (i != nNextDepth + 1 || (i != 1 && 
rNextInfo.IsNumbered())))
         {
             // for all skipped sublevels, close a li
             HTMLOutFuncs::Out_AsciiTag(

Reply via email to