summaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-01-22 16:00:10 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-01-23 09:06:08 +0100
commit90ae1e1bbbce7be9b2ff7add75923b1891e65df6 (patch)
tree5c16e0655a2da33111fe80a321a3c6874be161ce /external
parenta54787669b9283efdfdd18b0cbafc3184cdde58f (diff)
EPUB export, fxl: silence Page <N> toc entries when have chapter names
The EPUB ToC is now on par with the PDF ToC. Change-Id: Iea714fdb68c825aa14345037e909c354bbd7cf00 Reviewed-on: https://gerrit.libreoffice.org/48346 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'external')
-rw-r--r--external/libepubgen/libepubgen-epub3.patch.168
1 files changed, 68 insertions, 0 deletions
diff --git a/external/libepubgen/libepubgen-epub3.patch.1 b/external/libepubgen/libepubgen-epub3.patch.1
index bcec187b5218..f102eaefe7a6 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -355,3 +355,71 @@ index 8e88adb..38ddcdf 100644
--
2.13.6
+From b6081f659e3000d9f3d5851278d8abdd33448353 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos@collabora.co.uk>
+Date: Mon, 22 Jan 2018 15:54:43 +0100
+Subject: [PATCH] fixed layout: avoid Page <N> entries when chapter names are
+ provided
+
+---
+ src/lib/EPUBHTMLManager.cpp | 31 ++++++++++++++++++-------------
+ src/test/EPUBTextGeneratorTest.cpp | 16 ++++++++++++++++
+ 2 files changed, 34 insertions(+), 13 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLManager.cpp b/src/lib/EPUBHTMLManager.cpp
+index d35bc3f..35d82e8 100644
+--- a/src/lib/EPUBHTMLManager.cpp
++++ b/src/lib/EPUBHTMLManager.cpp
+@@ -7,6 +7,7 @@
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
++#include <algorithm>
+ #include <cassert>
+ #include <iomanip>
+ #include <sstream>
+@@ -91,24 +92,28 @@ void EPUBHTMLManager::writeTocTo(EPUBXMLSink &sink, const EPUBPath &tocPath, int
+ {
+ if (version >= 30)
+ {
++ bool hasChapterNames = std::find_if(m_paths.begin(), m_paths.end(), [](const EPUBPath &path)
++ {
++ return !path.getChapters().empty();
++ }) != m_paths.end();
+ for (std::vector<EPUBPath>::size_type i = 0; m_paths.size() != i; ++i)
+ {
+ const std::vector<std::string> &chapters = m_paths[i].getChapters();
+- if (!chapters.empty())
++ for (const auto &chapter : chapters)
+ {
+- for (const auto &chapter : chapters)
+- {
+- sink.openElement("li");
+- librevenge::RVNGPropertyList anchorAttrs;
+- anchorAttrs.insert("href", m_paths[i].relativeTo(tocPath).str().c_str());
+- sink.openElement("a", anchorAttrs);
+- std::ostringstream label;
+- sink.insertCharacters(chapter.c_str());
+- sink.closeElement("a");
+- sink.closeElement("li");
+- }
+- continue;
++ sink.openElement("li");
++ librevenge::RVNGPropertyList anchorAttrs;
++ anchorAttrs.insert("href", m_paths[i].relativeTo(tocPath).str().c_str());
++ sink.openElement("a", anchorAttrs);
++ std::ostringstream label;
++ sink.insertCharacters(chapter.c_str());
++ sink.closeElement("a");
++ sink.closeElement("li");
+ }
++ if (hasChapterNames)
++ // Chapter names are provided for this document, so never write Page
++ // <N> entries.
++ continue;
+
+ sink.openElement("li");
+ librevenge::RVNGPropertyList anchorAttrs;
+--
+2.13.6
+