configure.ac | 3 external/libepubgen/libepubgen-epub3.patch.1 | 561 +++++++++++++++++++++++ filter/source/svg/impsvgdialog.hxx | 1 filter/source/svg/svgexport.cxx | 5 filter/source/svg/svgfilter.hxx | 2 writerperfect/qa/unit/EPUBExportTest.cxx | 25 + writerperfect/source/writer/EPUBExportFilter.cxx | 5 writerperfect/source/writer/exp/txtparai.cxx | 7 writerperfect/source/writer/exp/txtstyli.cxx | 96 --- writerperfect/source/writer/exp/txtstyli.hxx | 29 - writerperfect/source/writer/exp/xmlfmt.cxx | 13 writerperfect/source/writer/exp/xmlfmt.hxx | 8 writerperfect/source/writer/exp/xmlimp.cxx | 33 - writerperfect/source/writer/exp/xmlimp.hxx | 7 14 files changed, 606 insertions(+), 189 deletions(-)
New commits: commit d4246aeaa2b182c3defcefb68426d1be8e2caf75 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Dec 1 12:00:35 2017 +0100 EPUB export, fixed layout: fix spine names They are pages, not sections. Change-Id: Ifd72d5ebec1d372a9bd99653d849479a6ffb6bfa Reviewed-on: https://gerrit.libreoffice.org/45690 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/configure.ac b/configure.ac index 8c5434bd1883..264e4ba99750 100644 --- a/configure.ac +++ b/configure.ac @@ -7688,7 +7688,8 @@ AS_IF([test "$SYSTEM_EPUBGEN" = "TRUE"], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ #include <libepubgen/libepubgen.h> ], [ - const libepubgen::EPUBTextGenerator generator(nullptr, EPUB_SPLIT_METHOD_NONE, 30); + libepubgen::EPUBTextGenerator generator(nullptr); + generator.setOption(libepubgen::EPUB_GENERATOR_OPTION_SPLIT, libepubgen::EPUB_SPLIT_METHOD_NONE); ])], [ AC_MSG_RESULT([yes]) diff --git a/external/libepubgen/libepubgen-epub3.patch.1 b/external/libepubgen/libepubgen-epub3.patch.1 index af6c9366fbc1..bf9670995049 100644 --- a/external/libepubgen/libepubgen-epub3.patch.1 +++ b/external/libepubgen/libepubgen-epub3.patch.1 @@ -5856,3 +5856,564 @@ index 02c299a..38573ec 100644 -- 2.13.6 +diff --git a/NEWS b/NEWS +index 912efbc..ad3d4d1 100644 +--- a/NEWS ++++ b/NEWS +@@ -1,3 +1,13 @@ ++- Fix various validation problems, pointed out by epubcheck. ++- Add EPUB3 support. ++- Split on headings: add user-friendly section names. ++- Support writing CSS styles inline in the XHTML streams. ++- Support various image wrap types. ++- Support embedded fonts. ++- Support cover images. ++- Support footnotes. ++- Support EPUB3 fixed layout. ++ + libepubgen-0.0.1 + + - Fix escaping of HTML entities. +diff --git a/inc/libepubgen/EPUBDrawingGenerator.h b/inc/libepubgen/EPUBDrawingGenerator.h +index 963e3b8..8f14959 100644 +--- a/inc/libepubgen/EPUBDrawingGenerator.h ++++ b/inc/libepubgen/EPUBDrawingGenerator.h +@@ -36,13 +36,19 @@ public: + * + * @param[in] version possible values: 20, 30. + */ +- explicit EPUBDrawingGenerator(EPUBPackage *package, EPUBSplitMethod split = EPUB_SPLIT_METHOD_PAGE_BREAK, int version = 20); ++ explicit EPUBDrawingGenerator(EPUBPackage *package, int version = 30); + EPUBDrawingGenerator(EPUBEmbeddingContact &contact, EPUBPackage *package); + ~EPUBDrawingGenerator() override; + + void setSplitHeadingLevel(unsigned level); + void setSplitSize(unsigned size); + ++ /** Set an option for the EPUB generator ++ * @param[in] key a value from the EPUBGeneratorOption enumeration ++ * @param[in] value depends on the value of key ++ */ ++ void setOption(int key, int value); ++ + /** Register a handler for embedded images. + * + * The handler must convert the image to one of the OPS Core Media Types. +diff --git a/inc/libepubgen/EPUBPresentationGenerator.h b/inc/libepubgen/EPUBPresentationGenerator.h +index 512c52d..b7ad190 100644 +--- a/inc/libepubgen/EPUBPresentationGenerator.h ++++ b/inc/libepubgen/EPUBPresentationGenerator.h +@@ -36,13 +36,19 @@ public: + * + * @param[in] version possible values: 20, 30. + */ +- explicit EPUBPresentationGenerator(EPUBPackage *package, EPUBSplitMethod split = EPUB_SPLIT_METHOD_PAGE_BREAK, int version = 20); ++ explicit EPUBPresentationGenerator(EPUBPackage *package, int version = 30); + EPUBPresentationGenerator(EPUBEmbeddingContact &contact, EPUBPackage *package); + ~EPUBPresentationGenerator() override; + + void setSplitHeadingLevel(unsigned level); + void setSplitSize(unsigned size); + ++ /** Set an option for the EPUB generator ++ * @param[in] key a value from the EPUBGeneratorOption enumeration ++ * @param[in] value depends on the value of key ++ */ ++ void setOption(int key, int value); ++ + /** Register a handler for embedded images. + * + * The handler must convert the image to one of the OPS Core Media Types. +diff --git a/inc/libepubgen/EPUBTextGenerator.h b/inc/libepubgen/EPUBTextGenerator.h +index beb05aa..809078a 100644 +--- a/inc/libepubgen/EPUBTextGenerator.h ++++ b/inc/libepubgen/EPUBTextGenerator.h +@@ -36,14 +36,19 @@ public: + * + * @param[in] version possible values: 20, 30. + */ +- explicit EPUBTextGenerator(EPUBPackage *package, EPUBSplitMethod split = EPUB_SPLIT_METHOD_PAGE_BREAK, int version = 20); ++ explicit EPUBTextGenerator(EPUBPackage *package, int version = 30); + EPUBTextGenerator(EPUBEmbeddingContact &contact, EPUBPackage *package); + ~EPUBTextGenerator() override; + + void setSplitHeadingLevel(unsigned level); + void setSplitSize(unsigned size); +- void setStylesMethod(EPUBStylesMethod styles); +- void setLayoutMethod(EPUBLayoutMethod layout); ++ ++ /** Set an option for the EPUB generator ++ * ++ * @param[in] key a value from the EPUBGeneratorOption enumeration ++ * @param[in] value depends on the value of key ++ */ ++ void setOption(int key, int value); + + /** Register a handler for embedded images. + * +diff --git a/inc/libepubgen/libepubgen-decls.h b/inc/libepubgen/libepubgen-decls.h +index 3eb206e..490dbc3 100644 +--- a/inc/libepubgen/libepubgen-decls.h ++++ b/inc/libepubgen/libepubgen-decls.h +@@ -77,6 +77,15 @@ enum EPUBLayoutMethod + EPUB_LAYOUT_METHOD_FIXED, //< Exactly one page per HTML file. + }; + ++/** The possible options for a generator. ++ */ ++enum EPUBGeneratorOption ++{ ++ EPUB_GENERATOR_OPTION_SPLIT, //< EPUBSplitMethod. ++ EPUB_GENERATOR_OPTION_STYLES, //< EPUBStylesMethod. ++ EPUB_GENERATOR_OPTION_LAYOUT //< EPUBLayoutMethod. ++}; ++ + } + + #endif // INCLUDED_LIBEPUBGEN_LIBEPUBGEN_DECLS_H +diff --git a/src/lib/EPUBDrawingGenerator.cpp b/src/lib/EPUBDrawingGenerator.cpp +index bcb4994..aef43ad 100644 +--- a/src/lib/EPUBDrawingGenerator.cpp ++++ b/src/lib/EPUBDrawingGenerator.cpp +@@ -20,16 +20,16 @@ using librevenge::RVNGString; + class EPUBDrawingGenerator::Impl : public EPUBPagedGenerator + { + public: +- Impl(EPUBPackage *const package, const EPUBSplitMethod method, int version); ++ Impl(EPUBPackage *const package, int version); + }; + +-EPUBDrawingGenerator::Impl::Impl(EPUBPackage *const package, const EPUBSplitMethod method, int version) +- : EPUBPagedGenerator(package, method, version) ++EPUBDrawingGenerator::Impl::Impl(EPUBPackage *const package, int version) ++ : EPUBPagedGenerator(package, version) + { + } + +-EPUBDrawingGenerator::EPUBDrawingGenerator(EPUBPackage *const package, EPUBSplitMethod split, int version) +- : m_impl(new Impl(package, split, version)) ++EPUBDrawingGenerator::EPUBDrawingGenerator(EPUBPackage *const package, int version) ++ : m_impl(new Impl(package, version)) + { + } + +@@ -51,6 +51,16 @@ void EPUBDrawingGenerator::setSplitHeadingLevel(const unsigned level) + m_impl->setSplitHeadingLevel(level); + } + ++void EPUBDrawingGenerator::setOption(int key, int value) ++{ ++ switch (key) ++ { ++ case EPUB_GENERATOR_OPTION_SPLIT: ++ m_impl->setSplitMethod(static_cast<EPUBSplitMethod>(value)); ++ break; ++ } ++} ++ + void EPUBDrawingGenerator::setSplitSize(const unsigned size) + { + m_impl->setSplitSize(size); +diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp +index f608331..83f3f40 100644 +--- a/src/lib/EPUBGenerator.cpp ++++ b/src/lib/EPUBGenerator.cpp +@@ -30,7 +30,7 @@ using librevenge::RVNGPropertyFactory; + using librevenge::RVNGPropertyList; + using librevenge::RVNGString; + +-EPUBGenerator::EPUBGenerator(EPUBPackage *const package, const EPUBSplitMethod split, int version) ++EPUBGenerator::EPUBGenerator(EPUBPackage *const package, int version) + : m_package(package) + , m_manifest() + , m_htmlManager(m_manifest) +@@ -44,7 +44,7 @@ EPUBGenerator::EPUBGenerator(EPUBPackage *const package, const EPUBSplitMethod s + , m_documentProps() + , m_metadata() + , m_currentHtml() +- , m_splitGuard(split) ++ , m_splitGuard(EPUB_SPLIT_METHOD_PAGE_BREAK) + , m_version(version) + , m_stylesMethod(EPUB_STYLES_METHOD_CSS) + , m_layoutMethod(EPUB_LAYOUT_METHOD_REFLOWABLE) +@@ -61,7 +61,7 @@ void EPUBGenerator::startDocument(const RVNGPropertyList &props) + + startNewHtmlFile(); + +- if (m_version == 30) ++ if (m_version >= 30) + m_manifest.insert(EPUBPath("OEBPS/toc.xhtml"), "application/xhtml+xml", "toc.xhtml", "nav"); + m_manifest.insert(EPUBPath("OEBPS/toc.ncx"), "application/x-dtbncx+xml", "toc.ncx", ""); + m_manifest.insert(m_stylesheetPath, "text/css", "stylesheet.css", ""); +@@ -88,7 +88,7 @@ void EPUBGenerator::setDocumentMetaData(const RVNGPropertyList &props) + { + m_metadata = props; + +- if (m_version == 30) ++ if (m_version >= 30) + { + const librevenge::RVNGPropertyListVector *coverImages = props.child("librevenge:cover-images"); + if (coverImages) +@@ -157,6 +157,11 @@ int EPUBGenerator::getVersion() const + return m_version; + } + ++void EPUBGenerator::setSplitMethod(EPUBSplitMethod split) ++{ ++ m_splitGuard.setSplitMethod(split); ++} ++ + void EPUBGenerator::setStylesMethod(EPUBStylesMethod styles) + { + m_stylesMethod = styles; +@@ -195,7 +200,7 @@ void EPUBGenerator::writeContainer() + + void EPUBGenerator::writeNavigation() + { +- if (m_version == 30) ++ if (m_version >= 30) + { + EPUBXMLSink sink; + +@@ -214,7 +219,7 @@ void EPUBGenerator::writeNavigation() + sink.openElement("nav", navAttrs); + + sink.openElement("ol"); +- m_htmlManager.writeTocTo(sink, path, m_version); ++ m_htmlManager.writeTocTo(sink, path, m_version, m_layoutMethod); + sink.closeElement("ol"); + + sink.closeElement("nav"); +@@ -248,7 +253,7 @@ void EPUBGenerator::writeNavigation() + sink.openElement("navMap"); + // In case of EPUB3 the (deprecated, but valid) EPUB2 markup is wanted, so + // the version is unconditional here. +- m_htmlManager.writeTocTo(sink, path, /*version=*/20); ++ m_htmlManager.writeTocTo(sink, path, /*version=*/20, m_layoutMethod); + sink.closeElement("navMap"); + + sink.closeElement("ncx"); +@@ -281,7 +286,7 @@ void EPUBGenerator::writeRoot() + packageAttrs.insert("xmlns:dc", "http://purl.org/dc/elements/1.1/"); + packageAttrs.insert("xmlns:dcterms", "http://purl.org/dc/terms/"); + packageAttrs.insert("xmlns:opf", "http://www.idpf.org/2007/opf"); +- if (m_version == 30) ++ if (m_version >= 30) + packageAttrs.insert("version", RVNGPropertyFactory::newStringProp("3.0")); + else + packageAttrs.insert("version", RVNGPropertyFactory::newStringProp("2.0")); +@@ -326,7 +331,7 @@ void EPUBGenerator::writeRoot() + sink.insertCharacters(language); + sink.closeElement("dc:language"); + +- if (m_version == 30) ++ if (m_version >= 30) + { + RVNGString date; + time_t now = 0; +diff --git a/src/lib/EPUBGenerator.h b/src/lib/EPUBGenerator.h +index 5a0df86..bcb54c5 100644 +--- a/src/lib/EPUBGenerator.h ++++ b/src/lib/EPUBGenerator.h +@@ -33,7 +33,7 @@ class EPUBGenerator + EPUBGenerator &operator=(const EPUBGenerator &); + + public: +- EPUBGenerator(EPUBPackage *package, EPUBSplitMethod method, int version); ++ EPUBGenerator(EPUBPackage *package, int version); + virtual ~EPUBGenerator(); + + void startDocument(const librevenge::RVNGPropertyList &props); +@@ -51,6 +51,8 @@ public: + EPUBSplitGuard &getSplitGuard(); + int getVersion() const; + ++ void setSplitMethod(EPUBSplitMethod splitMethod); ++ + void setStylesMethod(EPUBStylesMethod stylesMethod); + + void setLayoutMethod(EPUBLayoutMethod layoutMethod); +diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp +index 7a53ce3..342213e 100644 +--- a/src/lib/EPUBHTMLGenerator.cpp ++++ b/src/lib/EPUBHTMLGenerator.cpp +@@ -239,7 +239,7 @@ struct TextZoneSink + uiLabel = number.cstr(); + if (!lbl.length()) + return; +- int version = 20; ++ int version = 30; + if (m_zone) + version = m_zone->getVersion(); + { +@@ -248,7 +248,7 @@ struct TextZoneSink + if (closeAnchor) + output.openElement("sup", supAttrs); + RVNGPropertyList aAttrs; +- if (version == 30) ++ if (version >= 30) + aAttrs.insert("epub:type", "noteref"); + aAttrs.insert("href", ("#data" + lbl).c_str()); + output.openElement("a", aAttrs); +@@ -260,7 +260,7 @@ struct TextZoneSink + } + } + flush(); +- if (version == 30) ++ if (version >= 30) + { + RVNGPropertyList asideAttrs; + asideAttrs.insert("epub:type", "footnote"); +@@ -598,7 +598,7 @@ void EPUBHTMLGenerator::endDocument() + m_impl->m_document.insertEmptyElement("link", linkAttrs); + m_impl->m_document.closeElement("head"); + RVNGPropertyList bodyAttrs; +- if (m_impl->m_version == 30) ++ if (m_impl->m_version >= 30) + bodyAttrs.insert("xmlns:epub", "http://www.idpf.org/2007/ops"); + m_impl->m_document.openElement("body", bodyAttrs); + m_impl->flushUnsent(m_impl->m_document); +@@ -889,7 +889,7 @@ void EPUBHTMLGenerator::closeFootnote() + { + if (m_impl->m_ignore) + return; +- if (m_impl->m_version == 30) ++ if (m_impl->m_version >= 30) + m_impl->output().closeElement("aside"); + m_impl->pop(); + } +diff --git a/src/lib/EPUBHTMLManager.cpp b/src/lib/EPUBHTMLManager.cpp +index 363b33e..5e96d1d 100644 +--- a/src/lib/EPUBHTMLManager.cpp ++++ b/src/lib/EPUBHTMLManager.cpp +@@ -22,10 +22,16 @@ namespace + { + + /// Extracts a title string from a path and provides a fallback if it would be empty. +-void getPathTitle(std::ostringstream &label, const EPUBPath &path, std::vector<EPUBPath>::size_type index) ++void getPathTitle(std::ostringstream &label, const EPUBPath &path, EPUBLayoutMethod layout, std::vector<EPUBPath>::size_type index) + { + if (path.getTitle().empty()) +- label << "Section " << (index + 1); ++ { ++ if (layout == EPUB_LAYOUT_METHOD_FIXED) ++ label << "Page "; ++ else ++ label << "Section "; ++ label << (index + 1); ++ } + else + label << path.getTitle(); + } +@@ -81,9 +87,9 @@ void EPUBHTMLManager::writeSpineTo(EPUBXMLSink &sink) + } + } + +-void EPUBHTMLManager::writeTocTo(EPUBXMLSink &sink, const EPUBPath &tocPath, int version) ++void EPUBHTMLManager::writeTocTo(EPUBXMLSink &sink, const EPUBPath &tocPath, int version, EPUBLayoutMethod layout) + { +- if (version == 30) ++ if (version >= 30) + { + for (std::vector<EPUBPath>::size_type i = 0; m_paths.size() != i; ++i) + { +@@ -92,7 +98,7 @@ void EPUBHTMLManager::writeTocTo(EPUBXMLSink &sink, const EPUBPath &tocPath, int + anchorAttrs.insert("href", m_paths[i].relativeTo(tocPath).str().c_str()); + sink.openElement("a", anchorAttrs); + std::ostringstream label; +- getPathTitle(label, m_paths[i], i); ++ getPathTitle(label, m_paths[i], layout, i); + sink.insertCharacters(label.str().c_str()); + sink.closeElement("a"); + sink.closeElement("li"); +@@ -115,7 +121,7 @@ void EPUBHTMLManager::writeTocTo(EPUBXMLSink &sink, const EPUBPath &tocPath, int + sink.openElement("navLabel"); + sink.openElement("text"); + std::ostringstream label; +- getPathTitle(label, m_paths[i], i); ++ getPathTitle(label, m_paths[i], layout, i); + sink.insertCharacters(label.str().c_str()); + sink.closeElement("text"); + sink.closeElement("navLabel"); +diff --git a/src/lib/EPUBHTMLManager.h b/src/lib/EPUBHTMLManager.h +index 31e6dfe..157896b 100644 +--- a/src/lib/EPUBHTMLManager.h ++++ b/src/lib/EPUBHTMLManager.h +@@ -46,7 +46,7 @@ public: + void writeTo(EPUBPackage &package); + + void writeSpineTo(EPUBXMLSink &sink); +- void writeTocTo(EPUBXMLSink &sink, const EPUBPath &tocPath, int version); ++ void writeTocTo(EPUBXMLSink &sink, const EPUBPath &tocPath, int version, EPUBLayoutMethod layout); + + /// Appends text to the title of the current heading. + void insertHeadingText(const std::string &text); +diff --git a/src/lib/EPUBPagedGenerator.cpp b/src/lib/EPUBPagedGenerator.cpp +index 6a3bff0..b3a06e4 100644 +--- a/src/lib/EPUBPagedGenerator.cpp ++++ b/src/lib/EPUBPagedGenerator.cpp +@@ -25,7 +25,7 @@ class EPUBPagedGenerator::Impl : public EPUBGenerator + Impl &operator=(const Impl &); + + public: +- Impl(EPUBPackage *const package, EPUBSplitMethod method, int version); ++ Impl(EPUBPackage *const package, int version); + + private: + void startHtmlFile() override; +@@ -35,12 +35,17 @@ public: + bool m_firstPage; + }; + +-EPUBPagedGenerator::Impl::Impl(EPUBPackage *const package, const EPUBSplitMethod method, int version) +- : EPUBGenerator(package, method, version) ++EPUBPagedGenerator::Impl::Impl(EPUBPackage *const package, int version) ++ : EPUBGenerator(package, version) + , m_firstPage(true) + { + } + ++void EPUBPagedGenerator::setSplitMethod(EPUBSplitMethod split) ++{ ++ m_impl->setSplitMethod(split); ++} ++ + void EPUBPagedGenerator::setSplitHeadingLevel(const unsigned level) + { + m_impl->getSplitGuard().setSplitHeadingLevel(level); +@@ -59,8 +64,8 @@ void EPUBPagedGenerator::Impl::endHtmlFile() + { + } + +-EPUBPagedGenerator::EPUBPagedGenerator(EPUBPackage *const package, const EPUBSplitMethod method, int version) +- : m_impl(new Impl(package, method, version)) ++EPUBPagedGenerator::EPUBPagedGenerator(EPUBPackage *const package, int version) ++ : m_impl(new Impl(package, version)) + { + } + +diff --git a/src/lib/EPUBPagedGenerator.h b/src/lib/EPUBPagedGenerator.h +index 74d70da..4effb65 100644 +--- a/src/lib/EPUBPagedGenerator.h ++++ b/src/lib/EPUBPagedGenerator.h +@@ -26,8 +26,9 @@ class EPUBPagedGenerator: public librevenge::RVNGPresentationInterface + class Impl; + + public: +- EPUBPagedGenerator(EPUBPackage *package, EPUBSplitMethod method, int version); ++ EPUBPagedGenerator(EPUBPackage *package, int version); + ++ void setSplitMethod(EPUBSplitMethod split); + void setSplitHeadingLevel(unsigned level); + void setSplitSize(unsigned size); + +diff --git a/src/lib/EPUBPresentationGenerator.cpp b/src/lib/EPUBPresentationGenerator.cpp +index 80b5ac2..3ebca24 100644 +--- a/src/lib/EPUBPresentationGenerator.cpp ++++ b/src/lib/EPUBPresentationGenerator.cpp +@@ -20,18 +20,17 @@ using librevenge::RVNGString; + class EPUBPresentationGenerator::Impl : public EPUBPagedGenerator + { + public: +- Impl(EPUBPackage *const package, EPUBSplitMethod method, int version); ++ Impl(EPUBPackage *const package, int version); + }; + +-EPUBPresentationGenerator::Impl::Impl(EPUBPackage *const package, const EPUBSplitMethod method, int version) +- : EPUBPagedGenerator(package, method, version) ++EPUBPresentationGenerator::Impl::Impl(EPUBPackage *const package, int version) ++ : EPUBPagedGenerator(package, version) + { + } + +-EPUBPresentationGenerator::EPUBPresentationGenerator(EPUBPackage *const package, EPUBSplitMethod method, int version) +- : m_impl(new Impl(package, method, version)) ++EPUBPresentationGenerator::EPUBPresentationGenerator(EPUBPackage *const package, int version) ++ : m_impl(new Impl(package, version)) + { +- (void) method; + } + + EPUBPresentationGenerator::EPUBPresentationGenerator(EPUBEmbeddingContact &contact, EPUBPackage *const package) +@@ -47,6 +46,16 @@ EPUBPresentationGenerator::~EPUBPresentationGenerator() + delete m_impl; + } + ++void EPUBPresentationGenerator::setOption(int key, int value) ++{ ++ switch (key) ++ { ++ case EPUB_GENERATOR_OPTION_SPLIT: ++ m_impl->setSplitMethod(static_cast<EPUBSplitMethod>(value)); ++ break; ++ } ++} ++ + void EPUBPresentationGenerator::setSplitHeadingLevel(const unsigned level) + { + m_impl->setSplitHeadingLevel(level); +diff --git a/src/lib/EPUBTextGenerator.cpp b/src/lib/EPUBTextGenerator.cpp +index 38573ec..78eeaae 100644 +--- a/src/lib/EPUBTextGenerator.cpp ++++ b/src/lib/EPUBTextGenerator.cpp +@@ -67,7 +67,7 @@ bool isPageBreak(const librevenge::RVNGProperty *property) + + struct EPUBTextGenerator::Impl : public EPUBGenerator + { +- Impl(EPUBPackage *package, EPUBSplitMethod method, int version); ++ Impl(EPUBPackage *package, int version); + + private: + void startHtmlFile() override; +@@ -93,8 +93,8 @@ private: + Impl &operator=(const Impl &); + }; + +-EPUBTextGenerator::Impl::Impl(EPUBPackage *const package, const EPUBSplitMethod method, int version) +- : EPUBGenerator(package, method, version) ++EPUBTextGenerator::Impl::Impl(EPUBPackage *const package, int version) ++ : EPUBGenerator(package, version) + , m_inPageSpan(false) + , m_inHeader(false) + , m_inFooter(false) +@@ -123,10 +123,9 @@ void EPUBTextGenerator::Impl::endHtmlFile() + m_currentFooter->write(getHtml().get()); + } + +-EPUBTextGenerator::EPUBTextGenerator(EPUBPackage *const package, const EPUBSplitMethod method, int version) +- : m_impl(new Impl(package, method, version)) ++EPUBTextGenerator::EPUBTextGenerator(EPUBPackage *const package, int version) ++ : m_impl(new Impl(package, version)) + { +- (void) method; + } + + EPUBTextGenerator::EPUBTextGenerator(EPUBEmbeddingContact &contact, EPUBPackage *const package) +@@ -152,14 +151,20 @@ void EPUBTextGenerator::setSplitSize(const unsigned size) + m_impl->getSplitGuard().setSplitSize(size); + } + +-void EPUBTextGenerator::setStylesMethod(EPUBStylesMethod styles) ++void EPUBTextGenerator::setOption(int key, int value) + { +- m_impl->setStylesMethod(styles); +-} +- +-void EPUBTextGenerator::setLayoutMethod(EPUBLayoutMethod layout) +-{ +- m_impl->setLayoutMethod(layout); ++ switch (key) ++ { ++ case EPUB_GENERATOR_OPTION_SPLIT: ++ m_impl->setSplitMethod(static_cast<EPUBSplitMethod>(value)); ++ break; ++ case EPUB_GENERATOR_OPTION_STYLES: ++ m_impl->setStylesMethod(static_cast<EPUBStylesMethod>(value)); ++ break; ++ case EPUB_GENERATOR_OPTION_LAYOUT: ++ m_impl->setLayoutMethod(static_cast<EPUBLayoutMethod>(value)); ++ break; ++ } + } + + void EPUBTextGenerator::registerEmbeddedImageHandler(const librevenge::RVNGString &mimeType, EPUBEmbeddedImage imageHandler) diff --git a/writerperfect/source/writer/EPUBExportFilter.cxx b/writerperfect/source/writer/EPUBExportFilter.cxx index 301bdeb6f460..2d06e2c2e34f 100644 --- a/writerperfect/source/writer/EPUBExportFilter.cxx +++ b/writerperfect/source/writer/EPUBExportFilter.cxx @@ -95,13 +95,14 @@ sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDe // file, the flat ODF filter has access to the doc model, everything else // is in-between. EPUBPackage aPackage(mxContext, rDescriptor); - libepubgen::EPUBTextGenerator aGenerator(&aPackage, static_cast<libepubgen::EPUBSplitMethod>(nSplitMethod) + libepubgen::EPUBTextGenerator aGenerator(&aPackage #if LIBEPUBGEN_VERSION_SUPPORT , nVersion #endif ); #if LIBEPUBGEN_VERSION_SUPPORT - aGenerator.setLayoutMethod(static_cast<libepubgen::EPUBLayoutMethod>(nLayoutMethod)); + aGenerator.setOption(libepubgen::EPUB_GENERATOR_OPTION_SPLIT, nSplitMethod); + aGenerator.setOption(libepubgen::EPUB_GENERATOR_OPTION_LAYOUT, nLayoutMethod); #endif OUString aSourceURL; uno::Reference<frame::XModel> xSourceModel(mxSourceDocument, uno::UNO_QUERY); commit 19339e79e41cb9bbbbf0bd9a0e0d4a2cccc1f6a5 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Dec 1 11:00:09 2017 +0100 EPUB export, fixed layout: remove old non-metafile-based page size approach This was unused code. Change-Id: I7f728544127dc283cd74e4425e699d598caeae1a Reviewed-on: https://gerrit.libreoffice.org/45649 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/writerperfect/source/writer/exp/txtparai.cxx b/writerperfect/source/writer/exp/txtparai.cxx index 95f85d86f454..309f80ce607a 100644 --- a/writerperfect/source/writer/exp/txtparai.cxx +++ b/writerperfect/source/writer/exp/txtparai.cxx @@ -397,13 +397,6 @@ void XMLParaContext::startElement(const OUString &/*rName*/, const css::uno::Ref } } - if (!mrImport.IsPageSpanOpened()) - { - auto it = mrImport.GetMasterPages().find("Standard"); - if (it != mrImport.GetMasterPages().end()) - mrImport.GetGenerator().openPageSpan(it->second); - mrImport.SetPageSpanOpened(true); - } mrImport.GetGenerator().openParagraph(aPropertyList); } diff --git a/writerperfect/source/writer/exp/txtstyli.cxx b/writerperfect/source/writer/exp/txtstyli.cxx index 38b32768ddf0..e8fe1a43bea0 100644 --- a/writerperfect/source/writer/exp/txtstyli.cxx +++ b/writerperfect/source/writer/exp/txtstyli.cxx @@ -320,102 +320,6 @@ librevenge::RVNGPropertyList &XMLStyleContext::GetGraphicPropertyList() return m_aGraphicPropertyList; } -XMLMasterPageContext::XMLMasterPageContext(XMLImport &rImport, XMLStylesContext &rStyles) - : XMLImportContext(rImport), - m_rStyles(rStyles) -{ - // I'll remove this in a follow-up commit. - (void)m_rStyles; -} - -void XMLMasterPageContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) -{ - OUString aName; - OUString aPageLayoutName; - for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) - { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); - if (rAttributeName == "style:name") - aName = rAttributeValue; - else if (rAttributeName == "style:page-layout-name") - aPageLayoutName = rAttributeValue; - } - auto it = mrImport.GetPageLayouts().find(aPageLayoutName); - if (it == mrImport.GetPageLayouts().end()) - return; - - librevenge::RVNGPropertyList::Iter itProp(it->second); - librevenge::RVNGPropertyList aPropertyList; - for (itProp.rewind(); itProp.next();) - aPropertyList.insert(itProp.key(), itProp()->clone()); - mrImport.GetMasterPages()[aName] = aPropertyList; -} - -/// Handler for <style:page-layout-properties>. -class XMLPageLayoutPropertiesContext : public XMLImportContext -{ -public: - XMLPageLayoutPropertiesContext(XMLImport &rImport, XMLPageLayoutContext &rStyle); - - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - -private: - XMLPageLayoutContext &m_rStyle; -}; - -XMLPageLayoutPropertiesContext::XMLPageLayoutPropertiesContext(XMLImport &rImport, XMLPageLayoutContext &rStyle) - : XMLImportContext(rImport) - , m_rStyle(rStyle) -{ -} - -void XMLPageLayoutPropertiesContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) -{ - for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) - { - OString sName = OUStringToOString(xAttribs->getNameByIndex(i), RTL_TEXTENCODING_UTF8); - OString sValue = OUStringToOString(xAttribs->getValueByIndex(i), RTL_TEXTENCODING_UTF8); - m_rStyle.GetPropertyList().insert(sName.getStr(), sValue.getStr()); - } -} - -XMLPageLayoutContext::XMLPageLayoutContext(XMLImport &rImport, XMLStylesContext &rStyles) - : XMLImportContext(rImport), - m_rStyles(rStyles) -{ -} - -void XMLPageLayoutContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) -{ - for (sal_Int16 i = 0; i < xAttribs->getLength(); ++i) - { - const OUString &rAttributeName = xAttribs->getNameByIndex(i); - const OUString &rAttributeValue = xAttribs->getValueByIndex(i); - if (rAttributeName == "style:name") - m_aName = rAttributeValue; - } -} - -rtl::Reference<XMLImportContext> XMLPageLayoutContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) -{ - if (rName == "style:page-layout-properties") - return new XMLPageLayoutPropertiesContext(mrImport, *this); - return nullptr; -} - -void XMLPageLayoutContext::endElement(const OUString &/*rName*/) -{ - if (m_aName.isEmpty()) - return; - - m_rStyles.GetCurrentPageLayouts()[m_aName] = m_aPropertyList; -} - -librevenge::RVNGPropertyList &XMLPageLayoutContext::GetPropertyList() -{ - return m_aPropertyList; -} } // namespace exp } // namespace writerperfect diff --git a/writerperfect/source/writer/exp/txtstyli.hxx b/writerperfect/source/writer/exp/txtstyli.hxx index 06ae15e503f8..f3b3b6da38c9 100644 --- a/writerperfect/source/writer/exp/txtstyli.hxx +++ b/writerperfect/source/writer/exp/txtstyli.hxx @@ -52,35 +52,6 @@ private: XMLStylesContext &m_rStyles; }; -/// Handler for <style:master-page>. -class XMLMasterPageContext : public XMLImportContext -{ -public: - XMLMasterPageContext(XMLImport &rImport, XMLStylesContext &rStyles); - - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - -private: - XMLStylesContext &m_rStyles; -}; - -/// Handler for <style:page-layout>. -class XMLPageLayoutContext : public XMLImportContext -{ -public: - XMLPageLayoutContext(XMLImport &rImport, XMLStylesContext &rStyles); - - rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; - void SAL_CALL endElement(const OUString &rName) override; - - librevenge::RVNGPropertyList &GetPropertyList(); -private: - OUString m_aName; - librevenge::RVNGPropertyList m_aPropertyList; - XMLStylesContext &m_rStyles; -}; - } // namespace exp } // namespace writerperfect diff --git a/writerperfect/source/writer/exp/xmlfmt.cxx b/writerperfect/source/writer/exp/xmlfmt.cxx index a4b0781c73f9..e33f299f5c0e 100644 --- a/writerperfect/source/writer/exp/xmlfmt.cxx +++ b/writerperfect/source/writer/exp/xmlfmt.cxx @@ -28,9 +28,7 @@ XMLStylesContext::XMLStylesContext(XMLImport &rImport, StyleType eType) m_rColumnStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticColumnStyles() : mrImport.GetColumnStyles()), m_rRowStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticRowStyles() : mrImport.GetRowStyles()), m_rTableStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticTableStyles() : mrImport.GetTableStyles()), - m_rGraphicStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticGraphicStyles() : mrImport.GetGraphicStyles()), - m_rPageLayouts(mrImport.GetPageLayouts()), - m_eType(eType) + m_rGraphicStyles(eType == StyleType_AUTOMATIC ? mrImport.GetAutomaticGraphicStyles() : mrImport.GetGraphicStyles()) { } @@ -38,10 +36,6 @@ rtl::Reference<XMLImportContext> XMLStylesContext::CreateChildContext(const OUSt { if (rName == "style:style") return new XMLStyleContext(mrImport, *this); - if (m_eType == StyleType_MASTER && rName == "style:master-page") - return new XMLMasterPageContext(mrImport, *this); - if (m_eType == StyleType_AUTOMATIC && rName == "style:page-layout") - return new XMLPageLayoutContext(mrImport, *this); return nullptr; } @@ -80,11 +74,6 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentGr return m_rGraphicStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLStylesContext::GetCurrentPageLayouts() -{ - return m_rPageLayouts; -} - /// Handler for <style:font-face>. class XMLFontFaceContext : public XMLImportContext { diff --git a/writerperfect/source/writer/exp/xmlfmt.hxx b/writerperfect/source/writer/exp/xmlfmt.hxx index 24ee493cd660..e66f37dc8846 100644 --- a/writerperfect/source/writer/exp/xmlfmt.hxx +++ b/writerperfect/source/writer/exp/xmlfmt.hxx @@ -21,15 +21,14 @@ namespace writerperfect namespace exp { -/// Handler for <office:automatic-styles>/<office:master-styles>/<office:styles>. +/// Handler for <office:automatic-styles>/<office:styles>. class XMLStylesContext : public XMLImportContext { public: enum StyleType { StyleType_NONE, - StyleType_AUTOMATIC, - StyleType_MASTER + StyleType_AUTOMATIC }; XMLStylesContext(XMLImport &rImport, StyleType eType); @@ -42,7 +41,6 @@ public: std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentRowStyles(); std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentTableStyles(); std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentGraphicStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetCurrentPageLayouts(); private: std::map<OUString, librevenge::RVNGPropertyList> &m_rParagraphStyles; std::map<OUString, librevenge::RVNGPropertyList> &m_rTextStyles; @@ -51,8 +49,6 @@ private: std::map<OUString, librevenge::RVNGPropertyList> &m_rRowStyles; std::map<OUString, librevenge::RVNGPropertyList> &m_rTableStyles; std::map<OUString, librevenge::RVNGPropertyList> &m_rGraphicStyles; - std::map<OUString, librevenge::RVNGPropertyList> &m_rPageLayouts; - StyleType m_eType; }; /// Handler for <office:font-face-decls>. diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx index 6750019216e3..f8defce11dc4 100644 --- a/writerperfect/source/writer/exp/xmlimp.cxx +++ b/writerperfect/source/writer/exp/xmlimp.cxx @@ -255,8 +255,6 @@ rtl::Reference<XMLImportContext> XMLOfficeDocContext::CreateChildContext(const O return new XMLStylesContext(mrImport, XMLStylesContext::StyleType_NONE); if (rName == "office:font-face-decls") return new XMLFontFaceDeclsContext(mrImport); - if (rName == "office:master-styles") - return new XMLStylesContext(mrImport, XMLStylesContext::StyleType_MASTER); if (rName == "office:body") { if (mrImport.GetPageMetafiles().empty()) @@ -409,16 +407,6 @@ bool XMLImport::FillPopupData(const OUString &rURL, librevenge::RVNGPropertyList return false; } -void XMLImport::SetPageSpanOpened(bool bPageSpanOpened) -{ - mbPageSpanOpened = bPageSpanOpened; -} - -bool XMLImport::IsPageSpanOpened() const -{ - return mbPageSpanOpened; -} - const std::vector<std::pair<uno::Sequence<sal_Int8>, Size>> &XMLImport::GetPageMetafiles() const { return mrPageMetafiles; @@ -511,16 +499,6 @@ std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetGraphicStyles() return maGraphicStyles; } -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetPageLayouts() -{ - return maPageLayouts; -} - -std::map<OUString, librevenge::RVNGPropertyList> &XMLImport::GetMasterPages() -{ - return maMasterPages; -} - void XMLImport::startDocument() { mrGenerator.startDocument(librevenge::RVNGPropertyList()); @@ -528,11 +506,6 @@ void XMLImport::startDocument() void XMLImport::endDocument() { - if (mbPageSpanOpened) - { - mrGenerator.closePageSpan(); - mbPageSpanOpened = false; - } mrGenerator.endDocument(); } diff --git a/writerperfect/source/writer/exp/xmlimp.hxx b/writerperfect/source/writer/exp/xmlimp.hxx index c5a84852603b..a6d2a49f1f59 100644 --- a/writerperfect/source/writer/exp/xmlimp.hxx +++ b/writerperfect/source/writer/exp/xmlimp.hxx @@ -54,15 +54,12 @@ class XMLImport : public cppu::WeakImplHelper std::map<OUString, librevenge::RVNGPropertyList> maTableStyles; std::map<OUString, librevenge::RVNGPropertyList> maAutomaticGraphicStyles; std::map<OUString, librevenge::RVNGPropertyList> maGraphicStyles; - std::map<OUString, librevenge::RVNGPropertyList> maPageLayouts; - std::map<OUString, librevenge::RVNGPropertyList> maMasterPages; librevenge::RVNGPropertyListVector maCoverImages; /// Author, date, etc -- overwrites what would be from the document out of the box. librevenge::RVNGPropertyList maMetaData; const css::uno::Reference<css::uno::XComponentContext> &mxContext; css::uno::Reference<css::uri::XUriReferenceFactory> mxUriReferenceFactory; OUString maMediaDir; - bool mbPageSpanOpened = false; const std::vector<std::pair<css::uno::Sequence<sal_Int8>, Size>> &mrPageMetafiles; public: @@ -85,13 +82,9 @@ public: std::map<OUString, librevenge::RVNGPropertyList> &GetRowStyles(); std::map<OUString, librevenge::RVNGPropertyList> &GetTableStyles(); std::map<OUString, librevenge::RVNGPropertyList> &GetGraphicStyles(); - std::map<OUString, librevenge::RVNGPropertyList> &GetPageLayouts(); - std::map<OUString, librevenge::RVNGPropertyList> &GetMasterPages(); const librevenge::RVNGPropertyListVector &GetCoverImages(); const librevenge::RVNGPropertyList &GetMetaData(); bool FillPopupData(const OUString &rURL, librevenge::RVNGPropertyList &rPropList); - void SetPageSpanOpened(bool bPageSpanOpened); - bool IsPageSpanOpened() const; const std::vector<std::pair<css::uno::Sequence<sal_Int8>, Size>> &GetPageMetafiles() const; const css::uno::Reference<css::uno::XComponentContext> &GetComponentContext() const; commit e83d7993d46b096ecc18c01d92d39e170cce18c1 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Dec 1 10:59:36 2017 +0100 EPUB export, fixed layout: disable DTD string in SVG header epubcheck complains: ERROR(HTM-003): test.epub/OEBPS/images/image0001.svg(5675,37): External entities are not allowed in EPUB v3 documents. External entity declaration found: %svg-extensibility.mod. and similar ones. Just not writing the DTD header is enough to address the error. Change-Id: I5307e932a0f07585297cce734aceae77e43cc7a6 Reviewed-on: https://gerrit.libreoffice.org/45648 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/filter/source/svg/impsvgdialog.hxx b/filter/source/svg/impsvgdialog.hxx index 0e31fc33bef1..9f1d04fa9a32 100644 --- a/filter/source/svg/impsvgdialog.hxx +++ b/filter/source/svg/impsvgdialog.hxx @@ -31,6 +31,7 @@ #define SVG_EXPORTFILTER_CONFIGPATH "Office.Common/Filter/SVG/Export/" #define SVG_PROP_TINYPROFILE "TinyMode" +#define SVG_PROP_DTDSTRING "DTDString" #define SVG_PROP_EMBEDFONTS "EmbedFonts" #define SVG_PROP_NATIVEDECORATION "UseNativeTextDecoration" #define SVG_PROP_OPACITY "Opacity" diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index ce4c169f78bc..ab4cb14f5910 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -317,6 +317,9 @@ SVGExport::SVGExport( // TinyProfile mbIsUseTinyProfile = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_TINYPROFILE, false); + // DTD string + mbIsUseDTDString = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_DTDSTRING, true); + // Font Embedding comphelper::SequenceAsHashMap::const_iterator iter = aFilterDataHashMap.find(SVG_PROP_EMBEDFONTS); if(iter==aFilterDataHashMap.end()) @@ -2307,7 +2310,7 @@ void SVGExport::writeMtf( const GDIMetaFile& rMtf ) rtl::OUString aAttr; Reference< XExtendedDocumentHandler> xExtDocHandler( GetDocHandler(), UNO_QUERY ); - if( xExtDocHandler.is() ) + if( xExtDocHandler.is() && IsUseDTDString() ) xExtDocHandler->unknown( SVG_DTD_STRING ); aAttr = OUString::number( aSize.Width() ); diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx index 11ae4dea86cc..e006e8071684 100644 --- a/filter/source/svg/svgfilter.hxx +++ b/filter/source/svg/svgfilter.hxx @@ -71,6 +71,7 @@ static const OUString sPlaceholderTag( "<[:isPlaceholder:]>" ); class SVGExport : public SvXMLExport { bool mbIsUseTinyProfile; + bool mbIsUseDTDString; bool mbIsEmbedFonts; bool mbIsUseOpacity; bool mbIsUseNativeTextDecoration; @@ -85,6 +86,7 @@ public: virtual ~SVGExport() override; bool IsUseTinyProfile() const { return mbIsUseTinyProfile; }; + bool IsUseDTDString() const { return mbIsUseDTDString; }; bool IsEmbedFonts() const { return mbIsEmbedFonts; }; bool IsUseOpacity() const { return mbIsUseOpacity; }; bool IsUseNativeTextDecoration() const { return mbIsUseNativeTextDecoration; }; diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx index bd42356e60ce..178041d9c0da 100644 --- a/writerperfect/qa/unit/EPUBExportTest.cxx +++ b/writerperfect/qa/unit/EPUBExportTest.cxx @@ -96,6 +96,7 @@ public: void testPopup(); void testPopupAPI(); void testPageSize(); + void testSVG(); CPPUNIT_TEST_SUITE(EPUBExportTest); CPPUNIT_TEST(testOutlineLevel); @@ -139,6 +140,7 @@ public: CPPUNIT_TEST(testPopup); CPPUNIT_TEST(testPopupAPI); CPPUNIT_TEST(testPageSize); + CPPUNIT_TEST(testSVG); CPPUNIT_TEST_SUITE_END(); }; @@ -813,6 +815,29 @@ void EPUBExportTest::testPageSize() assertXPath(mpXmlDoc, "/xhtml:html/xhtml:head/xhtml:meta[@name='viewport']", "content", "width=816, height=1056"); } +void EPUBExportTest::testSVG() +{ + uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( + { + {"EPUBLayoutMethod", uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED))} + })); + createDoc("hello.fodt", aFilterData); + + CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/images/image0001.svg")); + uno::Reference<io::XInputStream> xInputStream(mxZipFile->getByName("OEBPS/images/image0001.svg"), uno::UNO_QUERY); + std::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); + + SvMemoryStream aMemoryStream; + aMemoryStream.WriteStream(*pStream); + OString aExpected("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<svg"); + CPPUNIT_ASSERT(aMemoryStream.GetSize() > static_cast<sal_uInt64>(aExpected.getLength())); + + // This failed, there was a '<!DOCTYPE' line between the xml and the svg + // one, causing a validation error. + OString aActual(static_cast<const char *>(aMemoryStream.GetBuffer()), aExpected.getLength()); + CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +} + CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest); } diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx index 4686cd95ad64..6750019216e3 100644 --- a/writerperfect/source/writer/exp/xmlimp.cxx +++ b/writerperfect/source/writer/exp/xmlimp.cxx @@ -17,6 +17,7 @@ #include <com/sun/star/xml/sax/InputSource.hpp> #include <com/sun/star/xml/sax/Parser.hpp> #include <com/sun/star/xml/sax/Writer.hpp> +#include <comphelper/propertyvalue.hxx> #include <rtl/uri.hxx> #include <tools/stream.hxx> #include <tools/urlobj.hxx> @@ -283,7 +284,10 @@ void XMLOfficeDocContext::HandleFixedLayoutPage(const uno::Sequence<sal_Int8> &r if (!xSaxWriter.is()) return; - uno::Sequence<uno::Any> aArguments; + uno::Sequence<uno::Any> aArguments = + { + uno::makeAny(uno::Sequence<beans::PropertyValue>({comphelper::makePropertyValue("DTDString", false)})) + }; uno::Reference<svg::XSVGWriter> xSVGWriter(xCtx->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.svg.SVGWriter", aArguments, xCtx), uno::UNO_QUERY); if (!xSVGWriter.is()) return; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits