summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/CppunitTest_sw_htmlexport.mk1
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx53
-rw-r--r--sw/source/filter/html/htmlatr.cxx17
-rw-r--r--sw/source/filter/html/htmlnumwriter.cxx14
4 files changed, 69 insertions, 16 deletions
diff --git a/sw/CppunitTest_sw_htmlexport.mk b/sw/CppunitTest_sw_htmlexport.mk
index f1e2342ad1ba..3315566bb087 100644
--- a/sw/CppunitTest_sw_htmlexport.mk
+++ b/sw/CppunitTest_sw_htmlexport.mk
@@ -27,6 +27,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_htmlexport, \
sfx \
sot \
sw \
+ svl \
svt \
test \
tl \
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 7ea6e300f603..512fd4c070cb 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -22,6 +22,9 @@
#include <swmodule.hxx>
#include <swdll.hxx>
#include <usrpref.hxx>
+#include <wrtsh.hxx>
+#include <ndtxt.hxx>
+#include <paratr.hxx>
#include <test/htmltesttools.hxx>
#include <tools/urlobj.hxx>
@@ -33,6 +36,7 @@
#include <svtools/rtftoken.h>
#include <filter/msfilter/rtfutil.hxx>
#include <sot/storage.hxx>
+#include <svl/eitem.hxx>
class HtmlExportTest : public SwModelTestBase, public HtmlTestTools
{
@@ -1053,6 +1057,55 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifOle1PDF)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(39409), pOleNative->GetSize());
}
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testMultiParaListItem)
+{
+ // Create a document with 3 list items: A, B&C and D.
+ loadURL("private:factory/swriter", nullptr);
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Insert("A");
+ SwDoc* pDoc = pWrtShell->GetDoc();
+ {
+ // Enable numbering.
+ sal_uInt16 nPos = pDoc->MakeNumRule(pDoc->GetUniqueNumRuleName());
+ SwNumRule* pNumRule = pDoc->GetNumRuleTable()[nPos];
+ SwNode& rNode = pWrtShell->GetCursor()->GetPoint()->nNode.GetNode();
+ SwTextNode& rTextNode = *rNode.GetTextNode();
+ rTextNode.SetAttr(SwNumRuleItem(pNumRule->GetName()));
+ }
+ pWrtShell->SplitNode();
+ pWrtShell->Insert("B");
+ pWrtShell->SplitNode();
+ pWrtShell->Insert("C");
+ {
+ // C is in the same list item as B.
+ SwNode& rNode = pWrtShell->GetCursor()->GetPoint()->nNode.GetNode();
+ SwTextNode& rTextNode = *rNode.GetTextNode();
+ rTextNode.SetCountedInList(false);
+ }
+ pWrtShell->SplitNode();
+ pWrtShell->Insert("D");
+
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aStoreProperties = {
+ comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")),
+ comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")),
+ };
+ xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties);
+
+ SvMemoryStream aStream;
+ HtmlExportTest::wrapFragment(maTempFile, aStream);
+ xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream);
+ CPPUNIT_ASSERT(pDoc);
+ assertXPathContent(pXmlDoc, "//reqif-xhtml:ol/reqif-xhtml:li[1]/reqif-xhtml:p", "A");
+ assertXPathContent(pXmlDoc, "//reqif-xhtml:ol/reqif-xhtml:li[2]/reqif-xhtml:p[1]", "B");
+ // Without the accompanying fix in place, this test would have failed with:
+ // XPath '//reqif-xhtml:ol/reqif-xhtml:li[2]/reqif-xhtml:p[2]' not found
+ // i.e. </li> was writen before "C", not after "C", so "C" was not in the 2nd list item.
+ assertXPathContent(pXmlDoc, "//reqif-xhtml:ol/reqif-xhtml:li[2]/reqif-xhtml:p[2]", "C");
+ assertXPathContent(pXmlDoc, "//reqif-xhtml:ol/reqif-xhtml:li[3]/reqif-xhtml:p", "D");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 9bee7fc22157..fa70b2767f09 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -207,7 +207,6 @@ struct SwHTMLTextCollOutputInfo
bool bParaPossible; // a </P> may be output additionally
bool bOutPara; // a </P> is supposed to be output
bool bOutDiv; // write a </DIV>
- bool bOutLi = false; // write a </li>
SwHTMLTextCollOutputInfo() :
bInNumberBulletList( false ),
@@ -764,14 +763,8 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
html.start(OOO_STRING_SVTOOLS_HTML_li);
if( USHRT_MAX != nNumStart )
html.attribute(OOO_STRING_SVTOOLS_HTML_O_value, OString::number(nNumStart));
- if (rHWrt.mbXHTML)
- {
- rWrt.Strm().WriteCharPtr(">");
- rInfo.bOutLi = true;
- }
- else
- // Finish the opening element, but don't close it.
- html.characters(OString());
+ // Finish the opening element, but don't close it.
+ html.characters(OString());
}
if( rHWrt.m_nDefListLvl > 0 && !bForceDL )
@@ -1022,11 +1015,7 @@ static void OutHTML_SwFormatOff( Writer& rWrt, const SwHTMLTextCollOutputInfo& r
rHWrt.m_bLFPossible = true;
}
- if (rInfo.bOutLi)
- HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rHWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_li,
- false);
-
- // if necessary, close a bulleted or numbered list
+ // if necessary, close the list item, then close a bulleted or numbered list
if( rInfo.bInNumberBulletList )
{
rHWrt.FillNextNumInfo();
diff --git a/sw/source/filter/html/htmlnumwriter.cxx b/sw/source/filter/html/htmlnumwriter.cxx
index 8977e0dbf684..ea3c949c3801 100644
--- a/sw/source/filter/html/htmlnumwriter.cxx
+++ b/sw/source/filter/html/htmlnumwriter.cxx
@@ -279,8 +279,18 @@ Writer& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt,
{
SwHTMLNumRuleInfo& rInfo = rWrt.GetNumInfo();
bool bSameRule = rNextInfo.GetNumRule() == rInfo.GetNumRule();
- if( bSameRule && rNextInfo.GetDepth() >= rInfo.GetDepth() &&
- !rNextInfo.IsRestart() )
+ bool bListEnd = !bSameRule || rNextInfo.GetDepth() < rInfo.GetDepth() || rNextInfo.IsRestart();
+
+ if (rWrt.mbXHTML)
+ {
+ if (bListEnd || (!bListEnd && rNextInfo.IsNumbered()))
+ {
+ HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(),
+ rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_li, false);
+ }
+ }
+
+ if (!bListEnd)
{
return rWrt;
}