Kaydet (Commit) 98a7251b authored tarafından Miklos Vajna's avatar Miklos Vajna

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/40840Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst d10a61fe
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment