summaryrefslogtreecommitdiff
path: root/sw/source/filter/html
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-09-05 16:15:21 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-09-05 21:00:44 +0200
commit16ed6110313cae310799a82294fc566ce75855a4 (patch)
treec2e5b2e40ffc288becef6a662579b868dc8708eb /sw/source/filter/html
parentac9ae6fed0c237b27861b718686c2cc23fd1ba5e (diff)
sw XHTML import: fix lost empty paragraphs
Plain HTML import ignores empty paragraph, because browsers ignore such paragraphs as well. This has the benefit of layout compatibility, but it breaks the semantics of documents when roundtripping them from Writer's document model to XHTML and back. Fix the problem by disabling this tweak for XHTML: the idea is that when it comes to paragraph / line breaks, XHTML is meant to preserve the semantics of the original document model, even if that results in slight differences in HTML rendering. So in case Writer/ODT doesn't collapse multiple line breaks and browsers/HTML does that, we apply workarounds in the HTML case, but not in the XHTML case. Change-Id: I55de8880503ee2d48fbd7a6af3891f2754f0d172 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139439 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/filter/html')
-rw-r--r--sw/source/filter/html/swhtml.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 9fcb2e0032dd..fa45f91406e3 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -4030,10 +4030,11 @@ void SwHTMLParser::EndPara( bool bReal )
#endif
}
- // Netscape skips empty paragraphs, we do the same.
+ // Netscape skips empty paragraphs, we do the same; unless in XHTML mode, which prefers mapping
+ // the source document to the doc model 1:1 if possible.
if( bReal )
{
- if( m_pPam->GetPoint()->GetContentIndex() )
+ if (m_pPam->GetPoint()->GetContentIndex() || m_bXHTML)
AppendTextNode( AM_SPACE );
else
AddParSpace();