Kaydet (Commit) 90ae1e1b authored tarafından Miklos Vajna's avatar Miklos Vajna

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/48346Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst a5478766
......@@ -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
......@@ -40,7 +40,7 @@ $(eval $(call gb_Module_add_check_targets,writerperfect,\
$(eval $(call gb_Module_add_slowcheck_targets,writerperfect,\
CppunitTest_writerperfect_calc \
CppunitTest_writerperfect_draw \
CppunitTest_writerperfect_epubexport \
$(if $(SYSTEM_EPUBGEN),,CppunitTest_writerperfect_epubexport) \
CppunitTest_writerperfect_import \
CppunitTest_writerperfect_impress \
CppunitTest_writerperfect_writer \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment