diff options
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 39 | ||||
-rw-r--r-- | sw/source/filter/html/htmlnumwriter.cxx | 13 |
2 files changed, 51 insertions, 1 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 5a2ea84292ac..d16c60735ace 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -2005,6 +2005,45 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testOleEmfPreviewToHtml) CPPUNIT_ASSERT(aPath.endsWith("gif")); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testNestedBullets) +{ + // Given a documented with nested lists: + SwDoc* pDoc = createSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->Insert("first"); + 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())); + rTextNode.SetAttrListLevel(0); + } + pWrtShell->SplitNode(); + pWrtShell->Insert("second"); + { + SwNode& rNode = pWrtShell->GetCursor()->GetPoint()->nNode.GetNode(); + SwTextNode& rTextNode = *rNode.GetTextNode(); + rTextNode.SetAttr(SwNumRuleItem(pNumRule->GetName())); + rTextNode.SetAttrListLevel(1); + } + + // When exporting to xhtml: + ExportToReqif(); + + // Then make sure that there is a <li> between the outer and the inner <ol>: + SvMemoryStream aStream; + HtmlExportTest::wrapFragment(maTempFile, aStream); + xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); + CPPUNIT_ASSERT(pDoc); + // Without the accompanying fix in place, this test would have failed with: + // - XPath '//reqif-xhtml:ol/reqif-xhtml:li/reqif-xhtml:ol/reqif-xhtml:li/reqif-xhtml:p' not found + // i.e. the <li> inside the outer <ol> was missing. + assertXPathContent( + pXmlDoc, "//reqif-xhtml:ol/reqif-xhtml:li/reqif-xhtml:ol/reqif-xhtml:li/reqif-xhtml:p", + "second"); +} + 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 f57e57d19be3..7fe8ec110661 100644 --- a/sw/source/filter/html/htmlnumwriter.cxx +++ b/sw/source/filter/html/htmlnumwriter.cxx @@ -211,11 +211,15 @@ Writer& OutHTML_NumberBulletListStart( SwHTMLWriter& rWrt, rWrt.m_aBulletGrfs[i].clear(); OString sOut = "<" + rWrt.GetNamespace(); + if (rWrt.mbXHTML && (nPrevDepth != 0 || i != 0)) + { + sOut += OOO_STRING_SVTOOLS_HTML_li "><" + rWrt.GetNamespace(); + } const SwNumFormat& rNumFormat = rInfo.GetNumRule()->Get( i ); sal_Int16 eType = rNumFormat.GetNumberingType(); if( SVX_NUM_CHAR_SPECIAL == eType ) { - // ordered list: <OL> + // unordered list: <UL> sOut += OOO_STRING_SVTOOLS_HTML_unorderlist; // determine the type by the bullet character @@ -319,6 +323,7 @@ Writer& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt, if (rWrt.mbXHTML) { + // XHTML </li> for the list item content. if ((bListEnd && rInfo.IsNumbered()) || (!bListEnd && rNextInfo.IsNumbered())) { HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), @@ -387,6 +392,12 @@ Writer& OutHTML_NumberBulletListEnd( SwHTMLWriter& rWrt, else aTag = OOO_STRING_SVTOOLS_HTML_orderlist; HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + aTag), false ); + if (rWrt.mbXHTML && (nNextDepth != 0 || i != 1)) + { + HTMLOutFuncs::Out_AsciiTag( + rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_li), + /*bOn=*/false); + } rWrt.m_bLFPossible = true; } |