diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-10-17 12:31:41 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-10-17 13:50:30 +0200 |
commit | 7a72f593dada6a7b3231a599772aed8be7d5a62f (patch) | |
tree | c24c6bc1a489ecc695771cfedba91fb1bdcaa479 /external/libepubgen | |
parent | 167afaf1111af5dab7645ef6efd12528eaa0389d (diff) |
EPUB export: fix handling of empty paragraphs
sw HTML export does work to avoid vertical collapsing of empty
(ODF) paragraphs, do the same for EPUB export.
Change-Id: I316a310178dd4aadbe3ed8548be23d64aabf5e47
Reviewed-on: https://gerrit.libreoffice.org/43451
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'external/libepubgen')
-rw-r--r-- | external/libepubgen/libepubgen-epub3.patch.1 | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/external/libepubgen/libepubgen-epub3.patch.1 b/external/libepubgen/libepubgen-epub3.patch.1 index 95ad47038ba9..98d4930c5f3f 100644 --- a/external/libepubgen/libepubgen-epub3.patch.1 +++ b/external/libepubgen/libepubgen-epub3.patch.1 @@ -2419,3 +2419,71 @@ index 5e53ee2..e25fa26 100644 -- 2.12.3 +From 383f315b067e9fc1aa840913c581e7451949c2db Mon Sep 17 00:00:00 2001 +From: Miklos Vajna <vmiklos@collabora.co.uk> +Date: Tue, 17 Oct 2017 12:21:26 +0200 +Subject: [PATCH] EPUBHTMLGenerator: better handling of empty paragraphs + +The ODF/librevenge concept is that empty paragraphs still take their +vertical space, i.e. inserting lots of them is a (poor) equivalent of a +page break. + +HTML collapses empty paragraphs by default, so empty paragraphs need +some content to preserve this effect. Do the same trick what LibreOffice +Writer does: if the text has no content, add a <br/> element inside the +paragraph. +--- + src/lib/EPUBHTMLGenerator.cpp | 8 ++++++++ + src/test/EPUBTextGeneratorTest.cpp | 15 +++++++++++++++ + 2 files changed, 23 insertions(+) + +diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp +index f3b30a6..d822571 100644 +--- a/src/lib/EPUBHTMLGenerator.cpp ++++ b/src/lib/EPUBHTMLGenerator.cpp +@@ -362,6 +362,7 @@ struct EPUBHTMLGeneratorImpl + , m_stylesheetPath(stylesheetPath) + , m_actualPage(0) + , m_ignore(false) ++ , m_hasText(false) + , m_frameAnchorTypes() + , m_stylesMethod(stylesMethod) + , m_actualSink() +@@ -449,6 +450,8 @@ struct EPUBHTMLGeneratorImpl + + int m_actualPage; + bool m_ignore; ++ /// Does the currently opened paragraph have some text? ++ bool m_hasText; + + std::stack<std::string> m_frameAnchorTypes; + +@@ -595,6 +598,7 @@ void EPUBHTMLGenerator::openParagraph(const RVNGPropertyList &propList) + break; + } + m_impl->output(false).openElement("p", attrs); ++ m_impl->m_hasText = false; + } + + void EPUBHTMLGenerator::closeParagraph() +@@ -602,6 +606,9 @@ void EPUBHTMLGenerator::closeParagraph() + if (m_impl->m_ignore) + return; + ++ if (!m_impl->m_hasText) ++ insertLineBreak(); ++ + m_impl->output().closeElement("p"); + } + +@@ -694,6 +701,7 @@ void EPUBHTMLGenerator::insertText(const RVNGString &text) + if (m_impl->m_ignore) + return; + m_impl->output().insertCharacters(text); ++ m_impl->m_hasText = true; + } + + void EPUBHTMLGenerator::insertSpace() +-- +2.12.3 + |