diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-08-28 18:10:59 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-08-29 09:03:42 +0200 |
commit | 6dfb01f15ce7a7287dcb705a592ede852ccf9cab (patch) | |
tree | 546fc0fdfdc81d95fe4c95a41280402d4ad5b251 /writerperfect | |
parent | 5bcf4e98769dbaf07e8b28a86edc2d3d648a571c (diff) |
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@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerperfect')
-rw-r--r-- | writerperfect/qa/unit/EPUBExportTest.cxx | 5 | ||||
-rw-r--r-- | writerperfect/source/writer/exp/xmlmetai.cxx | 24 |
2 files changed, 29 insertions, 0 deletions
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; } |