diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-05-21 11:05:30 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-05-21 13:08:11 +0200 |
commit | 119b6876c92e4cdae44583c4b1b1419d3533e3ee (patch) | |
tree | d16b8554120d8f325ae8c662be07bdabbf4d8a41 /sw/source | |
parent | 09c757cbdd3f973c97151203d8ff522141102da7 (diff) |
sw XHTML export: properly write <li>...</li> around multiple paragraphs
Writer just has a list of text nodes, but ODF and HTML can have multiple
paragraphs inside <li>, in case the non-first text nodes have their
RES_PARATR_LIST_ISCOUNTED set to false.
Improve b6f7a4908d1c3fc610440a1cbbbc1673a53da8b6 (sw XHTML export:
properly write <li>...</li> around paragraphs, 2018-04-11) to make the
decision around when to write </li> based on not only the current but
also the next text node. This way we omit </li> for non-first paragraphs
inside <li>, but keep writing it in other cases.
Change-Id: I994855961aeea92050268dba5f19f125c7ad2b7f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94622
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/html/htmlatr.cxx | 17 | ||||
-rw-r--r-- | sw/source/filter/html/htmlnumwriter.cxx | 14 |
2 files changed, 15 insertions, 16 deletions
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; } |