diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-08-11 18:39:33 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-08-11 21:55:01 +0200 |
commit | aa2265c511bcf704f116e71c3cd440e4fe133289 (patch) | |
tree | 99d648eeb251db729bbcbb853b9229bcd1f47c72 /writerperfect | |
parent | a4eddfffaa1d2fd76a4c8a1013c11d80ccd8f1b2 (diff) |
EPUB export: improve metadata handling
Handle language and document modification date, these two were the
remaining ones where EPUB3 mandates a value.
With this, the default values are not used if the document has custom
values.
Change-Id: Ief36e8143a530fe03ae9f96bbf5b3e33527f1555
Reviewed-on: https://gerrit.libreoffice.org/41052
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerperfect')
-rw-r--r-- | writerperfect/source/writer/exp/xmlmetai.cxx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/writerperfect/source/writer/exp/xmlmetai.cxx b/writerperfect/source/writer/exp/xmlmetai.cxx index c6251dccafff..cc8b37f43a0a 100644 --- a/writerperfect/source/writer/exp/xmlmetai.cxx +++ b/writerperfect/source/writer/exp/xmlmetai.cxx @@ -40,6 +40,50 @@ void XMLDcTitleContext::characters(const OUString &rChars) mrMeta.m_aPropertyList.insert("dc:title", librevenge::RVNGString(sCharU8.getStr())); } +/// Handler for <dc:language>. +class XMLDcLanguageContext : public XMLImportContext +{ +public: + XMLDcLanguageContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta); + + void SAL_CALL characters(const OUString &rChars) override; + + XMLMetaDocumentContext &mrMeta; +}; + +XMLDcLanguageContext::XMLDcLanguageContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta) + : XMLImportContext(rImport), mrMeta(rMeta) +{ +} + +void XMLDcLanguageContext::characters(const OUString &rChars) +{ + OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8); + mrMeta.m_aPropertyList.insert("dc:language", librevenge::RVNGString(sCharU8.getStr())); +} + +/// Handler for <dc:date>. +class XMLDcDateContext : public XMLImportContext +{ +public: + XMLDcDateContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta); + + void SAL_CALL characters(const OUString &rChars) override; + + XMLMetaDocumentContext &mrMeta; +}; + +XMLDcDateContext::XMLDcDateContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta) + : XMLImportContext(rImport), mrMeta(rMeta) +{ +} + +void XMLDcDateContext::characters(const OUString &rChars) +{ + OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8); + mrMeta.m_aPropertyList.insert("dc:date", librevenge::RVNGString(sCharU8.getStr())); +} + XMLMetaDocumentContext::XMLMetaDocumentContext(XMLImport &rImport) : XMLImportContext(rImport) { @@ -49,6 +93,10 @@ XMLImportContext *XMLMetaDocumentContext::CreateChildContext(const OUString &rNa { if (rName == "dc:title") return new XMLDcTitleContext(mrImport, *this); + if (rName == "dc:language") + return new XMLDcLanguageContext(mrImport, *this); + if (rName == "dc:date") + return new XMLDcDateContext(mrImport, *this); return nullptr; } |