diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-08-11 18:38:51 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-08-11 21:54:50 +0200 |
commit | a4eddfffaa1d2fd76a4c8a1013c11d80ccd8f1b2 (patch) | |
tree | 2ec0174a4b588e4429f54aa99a09f4685af59d4d /writerperfect/source | |
parent | 7634b279a53e7212925566e0de25d721fa7598ac (diff) |
EPUB export: add initial metadata support, document title
librevenge also uses librevenge:descriptive-name next to dc:title for
this purpose, but the later seems to be recommended in new code.
Change-Id: I3c3887911945ad14960c7cbbccfa66716e519893
Reviewed-on: https://gerrit.libreoffice.org/41044
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerperfect/source')
-rw-r--r-- | writerperfect/source/writer/exp/xmlimp.cxx | 3 | ||||
-rw-r--r-- | writerperfect/source/writer/exp/xmlmetai.cxx | 63 | ||||
-rw-r--r-- | writerperfect/source/writer/exp/xmlmetai.hxx | 40 |
3 files changed, 106 insertions, 0 deletions
diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx index b975bbcceebc..1b2365e16f5e 100644 --- a/writerperfect/source/writer/exp/xmlimp.cxx +++ b/writerperfect/source/writer/exp/xmlimp.cxx @@ -10,6 +10,7 @@ #include "xmlimp.hxx" #include "xmlictxt.hxx" +#include "xmlmetai.hxx" #include "xmltext.hxx" using namespace com::sun::star; @@ -58,6 +59,8 @@ XMLImportContext *XMLOfficeDocContext::CreateChildContext(const OUString &rName, { if (rName == "office:body") return new XMLBodyContext(mrImport); + else if (rName == "office:meta") + return new XMLMetaDocumentContext(mrImport); return nullptr; } diff --git a/writerperfect/source/writer/exp/xmlmetai.cxx b/writerperfect/source/writer/exp/xmlmetai.cxx new file mode 100644 index 000000000000..c6251dccafff --- /dev/null +++ b/writerperfect/source/writer/exp/xmlmetai.cxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "xmlmetai.hxx" + +#include "xmlimp.hxx" + +using namespace com::sun::star; + +namespace writerperfect +{ +namespace exp +{ + +/// Handler for <dc:title>. +class XMLDcTitleContext : public XMLImportContext +{ +public: + XMLDcTitleContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta); + + void SAL_CALL characters(const OUString &rChars) override; + + XMLMetaDocumentContext &mrMeta; +}; + +XMLDcTitleContext::XMLDcTitleContext(XMLImport &rImport, XMLMetaDocumentContext &rMeta) + : XMLImportContext(rImport), mrMeta(rMeta) +{ +} + +void XMLDcTitleContext::characters(const OUString &rChars) +{ + OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8); + mrMeta.m_aPropertyList.insert("dc:title", librevenge::RVNGString(sCharU8.getStr())); +} + +XMLMetaDocumentContext::XMLMetaDocumentContext(XMLImport &rImport) + : XMLImportContext(rImport) +{ +} + +XMLImportContext *XMLMetaDocumentContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/) +{ + if (rName == "dc:title") + return new XMLDcTitleContext(mrImport, *this); + return nullptr; +} + +void XMLMetaDocumentContext::endElement(const OUString &/*rName*/) +{ + mrImport.GetGenerator().setDocumentMetaData(m_aPropertyList); +} + +} // namespace exp +} // namespace writerperfect + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/writer/exp/xmlmetai.hxx b/writerperfect/source/writer/exp/xmlmetai.hxx new file mode 100644 index 000000000000..b02e1f21caaf --- /dev/null +++ b/writerperfect/source/writer/exp/xmlmetai.hxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_WRITERPERFECT_SOURCE_WRITER_EXP_XMLMETAI_HXX +#define INCLUDED_WRITERPERFECT_SOURCE_WRITER_EXP_XMLMETAI_HXX + +#include <librevenge/librevenge.h> + +#include "xmlictxt.hxx" + +namespace writerperfect +{ +namespace exp +{ + +/// Handler for <office:meta>. +class XMLMetaDocumentContext : public XMLImportContext +{ +public: + XMLMetaDocumentContext(XMLImport &rImport); + + XMLImportContext *CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override; + + void SAL_CALL endElement(const OUString &rName) override; + + librevenge::RVNGPropertyList m_aPropertyList; +}; + +} // namespace exp +} // namespace writerperfect + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |