diff options
Diffstat (limited to 'writerperfect')
-rw-r--r-- | writerperfect/source/writer/EPUBPackage.cxx | 37 | ||||
-rw-r--r-- | writerperfect/source/writer/EPUBPackage.hxx | 5 |
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); |