[Libreoffice-commits] core.git: writerperfect/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Aug 8 08:11:46 UTC 2017


 writerperfect/source/writer/EPUBPackage.cxx |    9 +++++++++
 1 file changed, 9 insertions(+)

New commits:
commit 06283dcba13ee18716da9eee728210a00bcb5b97
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Aug 8 09:16:04 2017 +0200

    EPUB export: write mime type
    
    libepubgen won't emit calls on the package interface to do this, it
    turns out.
    
    Change-Id: Ib9826f1df348fd7afbccdc5d5a92a6d94f8aa9af
    Reviewed-on: https://gerrit.libreoffice.org/40862
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/writerperfect/source/writer/EPUBPackage.cxx b/writerperfect/source/writer/EPUBPackage.cxx
index 060c3828a4de..bf9c03089708 100644
--- a/writerperfect/source/writer/EPUBPackage.cxx
+++ b/writerperfect/source/writer/EPUBPackage.cxx
@@ -28,6 +28,15 @@ EPUBPackage::EPUBPackage(const uno::Reference<uno::XComponentContext> &xContext,
     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);
+
+    // The zipped content represents an EPUB Publication.
+    mxOutputStream.set(mxStorage->openStreamElementByHierarchicalName("mimetype", embed::ElementModes::READWRITE), uno::UNO_QUERY);
+    const OString aMimeType("application/epub+zip");
+    uno::Sequence<sal_Int8> aData(reinterpret_cast<const sal_Int8 *>(aMimeType.getStr()), aMimeType.getLength());
+    mxOutputStream->writeBytes(aData);
+    uno::Reference<embed::XTransactedObject> xTransactedObject(mxOutputStream, uno::UNO_QUERY);
+    xTransactedObject->commit();
+    mxOutputStream.clear();
 }
 
 EPUBPackage::~EPUBPackage()


More information about the Libreoffice-commits mailing list