writerperfect/source/writer/EPUBPackage.cxx | 21 ++++++++++++++++++--- writerperfect/source/writer/EPUBPackage.hxx | 6 ++++-- 2 files changed, 22 insertions(+), 5 deletions(-)
New commits: commit 9d1350fe183485025a924f8c03d8f34c077028d3 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Aug 8 11:02:31 2017 +0200 EPUB export: write most of XML content in the package No attributes yet, though. Change-Id: I268d59a67c311f8e2e46331b2add1a91702545e2 Reviewed-on: https://gerrit.libreoffice.org/40864 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/writerperfect/source/writer/EPUBPackage.cxx b/writerperfect/source/writer/EPUBPackage.cxx index bf9c03089708..7589dae19722 100644 --- a/writerperfect/source/writer/EPUBPackage.cxx +++ b/writerperfect/source/writer/EPUBPackage.cxx @@ -11,9 +11,11 @@ #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> +#include <com/sun/star/xml/sax/Writer.hpp> #include <comphelper/storagehelper.hxx> #include <unotools/mediadescriptor.hxx> +#include <xmloff/attrlist.hxx> using namespace com::sun::star; @@ -49,29 +51,42 @@ void EPUBPackage::openXMLFile(const char *pName) { assert(pName); assert(!mxOutputStream.is()); + assert(!mxOutputWriter.is()); mxOutputStream.set(mxStorage->openStreamElementByHierarchicalName(OUString::fromUtf8(pName), embed::ElementModes::READWRITE), uno::UNO_QUERY); + mxOutputWriter = xml::sax::Writer::create(mxContext); + mxOutputWriter->setOutputStream(mxOutputStream); + mxOutputWriter->startDocument(); } void EPUBPackage::openElement(const char *pName, const librevenge::RVNGPropertyList &/*rAttributes*/) { - SAL_WARN("writerperfect", "EPUBPackage::openElement, " << pName << ": implement me"); + assert(mxOutputWriter.is()); + + rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList()); + mxOutputWriter->startElement(OUString::fromUtf8(pName), uno::Reference<xml::sax::XAttributeList>(pAttributeList.get())); } void EPUBPackage::closeElement(const char *pName) { - SAL_WARN("writerperfect", "EPUBPackage::closeElement, " << pName << ": implement me"); + assert(mxOutputWriter.is()); + + mxOutputWriter->endElement(OUString::fromUtf8(pName)); } void EPUBPackage::insertCharacters(const librevenge::RVNGString &rCharacters) { - SAL_WARN("writerperfect", "EPUBPackage::insertCharacters, " << rCharacters.cstr() << ": implement me"); + mxOutputWriter->characters(OUString::fromUtf8(rCharacters.cstr())); } void EPUBPackage::closeXMLFile() { + assert(mxOutputWriter.is()); assert(mxOutputStream.is()); + mxOutputWriter->endDocument(); + mxOutputWriter.clear(); + uno::Reference<embed::XTransactedObject> xTransactedObject(mxOutputStream, uno::UNO_QUERY); xTransactedObject->commit(); mxOutputStream.clear(); diff --git a/writerperfect/source/writer/EPUBPackage.hxx b/writerperfect/source/writer/EPUBPackage.hxx index 9d8ff8eef543..5e093f540cc8 100644 --- a/writerperfect/source/writer/EPUBPackage.hxx +++ b/writerperfect/source/writer/EPUBPackage.hxx @@ -12,10 +12,11 @@ #include <libepubgen/EPUBPackage.h> -#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/embed/XHierarchicalStorageAccess.hpp> #include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/xml/sax/XWriter.hpp> namespace writerperfect { @@ -26,6 +27,7 @@ class EPUBPackage : public libepubgen::EPUBPackage css::uno::Reference<css::uno::XComponentContext> mxContext; css::uno::Reference<css::embed::XHierarchicalStorageAccess> mxStorage; css::uno::Reference<css::io::XOutputStream> mxOutputStream; + css::uno::Reference<css::xml::sax::XWriter> mxOutputWriter; public: explicit EPUBPackage(const css::uno::Reference<css::uno::XComponentContext> &xContext, const css::uno::Sequence<css::beans::PropertyValue> &rDescriptor); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits