summaryrefslogtreecommitdiff
path: root/writerperfect
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-08-07 16:29:45 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-08-07 17:56:38 +0200
commit98a7251b24c9f42bdb333bacbe06a2821e6942f2 (patch)
tree49f5eb77bb6d1dc38188352f1045fcaa301fa3fd /writerperfect
parentd10a61fe36760336842cbfa7f8f77e1fb9a475a5 (diff)
EPUB export: start creating XML and CSS files
Though at the moment all of them are empty. Change-Id: I4e53c81df2d709f06eb2a1df814b887181ae84c9 Reviewed-on: https://gerrit.libreoffice.org/40840 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerperfect')
-rw-r--r--writerperfect/source/writer/EPUBPackage.cxx37
-rw-r--r--writerperfect/source/writer/EPUBPackage.hxx5
2 files changed, 35 insertions, 7 deletions
diff --git a/writerperfect/source/writer/EPUBPackage.cxx b/writerperfect/source/writer/EPUBPackage.cxx
index 54300c2fbf0a..060c3828a4de 100644
--- a/writerperfect/source/writer/EPUBPackage.cxx
+++ b/writerperfect/source/writer/EPUBPackage.cxx
@@ -9,23 +9,39 @@
#include "EPUBPackage.hxx"
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+
+#include <comphelper/storagehelper.hxx>
+#include <unotools/mediadescriptor.hxx>
+
using namespace com::sun::star;
namespace writerperfect
{
-EPUBPackage::EPUBPackage(const uno::Reference<uno::XComponentContext> &xContext, const uno::Sequence<beans::PropertyValue> &/*rDescriptor*/)
+EPUBPackage::EPUBPackage(const uno::Reference<uno::XComponentContext> &xContext, const uno::Sequence<beans::PropertyValue> &rDescriptor)
: mxContext(xContext)
{
+ // Extract the output stream from the descriptor.
+ utl::MediaDescriptor aMediaDesc(rDescriptor);
+ auto xStream = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_STREAMFOROUTPUT(), uno::Reference<io::XStream>());
+ const sal_Int32 nOpenMode = embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE;
+ mxStorage.set(comphelper::OStorageHelper::GetStorageOfFormatFromStream(ZIP_STORAGE_FORMAT_STRING, xStream, nOpenMode, mxContext), uno::UNO_QUERY);
}
EPUBPackage::~EPUBPackage()
{
+ uno::Reference<embed::XTransactedObject> xTransactedObject(mxStorage, uno::UNO_QUERY);
+ xTransactedObject->commit();
}
void EPUBPackage::openXMLFile(const char *pName)
{
- SAL_WARN("writerperfect", "EPUBPackage::openXMLFile, " << pName << ": implement me");
+ assert(pName);
+ assert(!mxOutputStream.is());
+
+ mxOutputStream.set(mxStorage->openStreamElementByHierarchicalName(OUString::fromUtf8(pName), embed::ElementModes::READWRITE), uno::UNO_QUERY);
}
void EPUBPackage::openElement(const char *pName, const librevenge::RVNGPropertyList &/*rAttributes*/)
@@ -45,12 +61,19 @@ void EPUBPackage::insertCharacters(const librevenge::RVNGString &rCharacters)
void EPUBPackage::closeXMLFile()
{
- SAL_WARN("writerperfect", "EPUBPackage::closeXMLFile: implement me");
+ assert(mxOutputStream.is());
+
+ uno::Reference<embed::XTransactedObject> xTransactedObject(mxOutputStream, uno::UNO_QUERY);
+ xTransactedObject->commit();
+ mxOutputStream.clear();
}
void EPUBPackage::openCSSFile(const char *pName)
{
- SAL_WARN("writerperfect", "EPUBPackage::openCSSFile, " << pName << ": implement me");
+ assert(pName);
+ assert(!mxOutputStream.is());
+
+ mxOutputStream.set(mxStorage->openStreamElementByHierarchicalName(OUString::fromUtf8(pName), embed::ElementModes::READWRITE), uno::UNO_QUERY);
}
void EPUBPackage::insertRule(const librevenge::RVNGString &/*rSelector*/, const librevenge::RVNGPropertyList &/*rProperties*/)
@@ -60,7 +83,11 @@ void EPUBPackage::insertRule(const librevenge::RVNGString &/*rSelector*/, const
void EPUBPackage::closeCSSFile()
{
- SAL_WARN("writerperfect", "EPUBPackage::closeCSSFile: implement me");
+ assert(mxOutputStream.is());
+
+ uno::Reference<embed::XTransactedObject> xTransactedObject(mxOutputStream, uno::UNO_QUERY);
+ xTransactedObject->commit();
+ mxOutputStream.clear();
}
void EPUBPackage::openBinaryFile(const char *pName)
diff --git a/writerperfect/source/writer/EPUBPackage.hxx b/writerperfect/source/writer/EPUBPackage.hxx
index 48c1f8a035e0..9d8ff8eef543 100644
--- a/writerperfect/source/writer/EPUBPackage.hxx
+++ b/writerperfect/source/writer/EPUBPackage.hxx
@@ -13,7 +13,7 @@
#include <libepubgen/EPUBPackage.h>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
@@ -24,7 +24,8 @@ namespace writerperfect
class EPUBPackage : public libepubgen::EPUBPackage
{
css::uno::Reference<css::uno::XComponentContext> mxContext;
- css::uno::Reference<css::embed::XStorage> mxStorage;
+ css::uno::Reference<css::embed::XHierarchicalStorageAccess> mxStorage;
+ css::uno::Reference<css::io::XOutputStream> mxOutputStream;
public:
explicit EPUBPackage(const css::uno::Reference<css::uno::XComponentContext> &xContext, const css::uno::Sequence<css::beans::PropertyValue> &rDescriptor);