summaryrefslogtreecommitdiff
path: root/writerperfect/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-08-08 11:02:31 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-08-08 12:08:27 +0200
commit9d1350fe183485025a924f8c03d8f34c077028d3 (patch)
tree65b0a2e96b85669c435eef82997e02e00b1c72fc /writerperfect/source
parent99f3d9895f63ed19496bbe47bd36899b0f39dbce (diff)
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 <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerperfect/source')
-rw-r--r--writerperfect/source/writer/EPUBPackage.cxx21
-rw-r--r--writerperfect/source/writer/EPUBPackage.hxx6
2 files changed, 22 insertions, 5 deletions
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);