[Libreoffice-commits] core.git: external/libepubgen writerperfect/qa writerperfect/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Aug 29 07:10:26 UTC 2017
external/libepubgen/libepubgen-epub3.patch.1 | 59 +++++++++++++++++++++++++++
writerperfect/qa/unit/EPUBExportTest.cxx | 5 ++
writerperfect/source/writer/exp/xmlmetai.cxx | 24 ++++++++++
3 files changed, 88 insertions(+)
New commits:
commit 6dfb01f15ce7a7287dcb705a592ede852ccf9cab
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Aug 28 18:10:59 2017 +0200
EPUB export: write generator string
Should help with debugging when it's not clear the version creating the
output had a certain fix or not.
Change-Id: Ibd1b5153d3210d30f95eba8927c55e2e812d985c
Reviewed-on: https://gerrit.libreoffice.org/41652
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/external/libepubgen/libepubgen-epub3.patch.1 b/external/libepubgen/libepubgen-epub3.patch.1
index 52070425d7c0..d1d35c102022 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -1803,3 +1803,62 @@ index 019404f..aa09332 100644
--
2.12.3
+From 143a470f190aaf2f420d2f84b5f08e9b01b40473 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos at collabora.co.uk>
+Date: Fri, 25 Aug 2017 17:44:38 +0200
+Subject: [PATCH] Export generator
+
+---
+ src/lib/EPUBGenerator.cpp | 28 ++++++++++++++++++++++++++++
+ src/test/EPUBTextGeneratorTest.cpp | 17 +++++++++++++++++
+ 2 files changed, 45 insertions(+)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 4ce2964..1661064 100644
+--- a/src/lib/EPUBGenerator.cpp
++++ b/src/lib/EPUBGenerator.cpp
+@@ -7,6 +7,10 @@
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
++#ifdef HAVE_CONFIG_H
++#include "config.h"
++#endif
++
+ #include <ctime>
+ #include <sstream>
+
+@@ -298,6 +302,30 @@ void EPUBGenerator::writeRoot()
+ sink.openElement("meta", metaAttrs);
+ sink.insertCharacters(date);
+ sink.closeElement("meta");
++
++#ifdef VERSION
++ const std::string version(VERSION);
++#else
++ const std::string version("unknown");
++#endif
++ std::string generator;
++ if (m_metadata["meta:generator"])
++ generator = m_metadata["meta:generator"]->getStr().cstr();
++
++ if (generator.empty())
++ generator = "libepubgen/" + version;
++ else
++ {
++ generator += " (";
++ generator += "libepubgen/" + version;
++ generator += ")";
++ }
++
++ metaAttrs.clear();
++ metaAttrs.insert("name", "generator");
++ metaAttrs.insert("content", generator.c_str());
++ sink.openElement("meta", metaAttrs);
++ sink.closeElement("meta");
+ }
+
+ sink.closeElement("metadata");
+--
+2.12.3
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index f6e0d756fd25..cf602956c631 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -19,6 +19,7 @@
#include <test/bootstrapfixture.hxx>
#include <test/xmltesttools.hxx>
#include <unotest/macros_test.hxx>
+#include <unotools/docinfohelper.hxx>
#include <unotools/mediadescriptor.hxx>
#include <unotools/tempfile.hxx>
#include <unotools/ucbstreamhelper.hxx>
@@ -138,6 +139,10 @@ void EPUBExportTest::testMimetype()
mpXmlDoc = parseExport("OEBPS/content.opf");
// Default is EPUB3.
assertXPath(mpXmlDoc, "/opf:package", "version", "3.0");
+
+ // This was just "libepubgen/x.y.z", i.e. the LO version was missing.
+ OUString aGenerator = getXPath(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@name='generator']", "content");
+ CPPUNIT_ASSERT(aGenerator.startsWith(utl::DocInfoHelper::GetGeneratorString()));
}
void EPUBExportTest::testEPUB2()
diff --git a/writerperfect/source/writer/exp/xmlmetai.cxx b/writerperfect/source/writer/exp/xmlmetai.cxx
index cc8b37f43a0a..6c01adeb8f11 100644
--- a/writerperfect/source/writer/exp/xmlmetai.cxx
+++ b/writerperfect/source/writer/exp/xmlmetai.cxx
@@ -84,6 +84,28 @@ void XMLDcDateContext::characters(const OUString &rChars)
mrMeta.m_aPropertyList.insert("dc:date", librevenge::RVNGString(sCharU8.getStr()));
}
+/// Handler for <meta:generator>.
+class XMLMetaGeneratorContext : public XMLImportContext
+{
+public:
+ XMLMetaGeneratorContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta);
+
+ void SAL_CALL characters(const OUString &rChars) override;
+
+ XMLMetaDocumentContext &mrMeta;
+};
+
+XMLMetaGeneratorContext::XMLMetaGeneratorContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta)
+ : XMLImportContext(rImport), mrMeta(rMeta)
+{
+}
+
+void XMLMetaGeneratorContext::characters(const OUString &rChars)
+{
+ OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8);
+ mrMeta.m_aPropertyList.insert("meta:generator", librevenge::RVNGString(sCharU8.getStr()));
+}
+
XMLMetaDocumentContext::XMLMetaDocumentContext(XMLImport &rImport)
: XMLImportContext(rImport)
{
@@ -97,6 +119,8 @@ XMLImportContext *XMLMetaDocumentContext::CreateChildContext(const OUString &rNa
return new XMLDcLanguageContext(mrImport, *this);
if (rName == "dc:date")
return new XMLDcDateContext(mrImport, *this);
+ if (rName == "meta:generator")
+ return new XMLMetaGeneratorContext(mrImport, *this);
return nullptr;
}
More information about the Libreoffice-commits
mailing list