summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-07-19 16:35:10 +0200
committerJan Holesovsky <kendy@collabora.com>2017-07-21 19:48:29 +0200
commitee6f8f1982d666f8fcda96d2141a9332a10b8273 (patch)
tree91e0be943b7ea20f5fca5b6eeee64f1756cf6996 /sd
parentf7c3dafac4545c99e3ea4e469c23f7c7b7359807 (diff)
sd pptm: Preserve the VBA stream on export.
This actually implements the reading of the VBA stream in Impress too, so the user will get a warning when opening such a file (that the it contains macros). Change-Id: I1638199529196ed217cbd9ebef88eb7c88f2179a Reviewed-on: https://gerrit.libreoffice.org/40197 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk> Reviewed-on: https://gerrit.libreoffice.org/40267 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/filter/eppt/epptooxml.hxx3
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx35
2 files changed, 37 insertions, 1 deletions
diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx
index cc60f76d8089..aa27ad8adf19 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -157,6 +157,9 @@ private:
AuthorsMap maAuthors;
void WriteAuthors();
+
+ /// If this is PPTM, output the VBA stream.
+ void WriteVBA();
};
}
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index c359859358a6..ebf122d8a34c 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -28,12 +28,14 @@
#include <oox/export/shapes.hxx>
#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/storagehelper.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <cppuhelper/factory.hxx>
#include <sax/fshelper.hxx>
#include <rtl/ustrbuf.hxx>
#include <filter/msfilter/escherex.hxx>
#include <tools/poly.hxx>
+#include <unotools/ucbstreamhelper.hxx>
#include <com/sun/star/animations/AnimationAdditiveMode.hpp>
#include <com/sun/star/animations/AnimationCalcMode.hpp>
@@ -55,6 +57,7 @@
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/RectanglePoint.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/geometry/RealPoint2D.hpp>
#include <com/sun/star/office/XAnnotationEnumeration.hpp>
#include <com/sun/star/office/XAnnotationAccess.hpp>
@@ -69,6 +72,7 @@
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <utility>
// presentation namespaces
@@ -399,6 +403,8 @@ bool PowerPointExport::exportDocument()
WriteAuthors();
+ WriteVBA();
+
mPresentationFS->endElementNS( XML_p, XML_presentation );
mPresentationFS.reset();
// Free all FSHelperPtr, to flush data before committing storage
@@ -1439,7 +1445,8 @@ void PowerPointExport::WriteAuthors()
sal_Int32 PowerPointExport::GetAuthorIdAndLastIndex( const OUString& sAuthor, sal_Int32& nLastIndex )
{
- if ( maAuthors.count( sAuthor ) <= 0 ) {
+ if (maAuthors.count(sAuthor) <= 0)
+ {
struct AuthorComments aAuthorComments;
aAuthorComments.nId = maAuthors.size();
@@ -1513,6 +1520,32 @@ bool PowerPointExport::WriteComments( sal_uInt32 nPageNum )
return false;
}
+void PowerPointExport::WriteVBA()
+{
+ if (!mbPptm)
+ return;
+
+ uno::Reference<document::XStorageBasedDocument> xStorageBasedDocument(getModel(), uno::UNO_QUERY);
+ if (!xStorageBasedDocument.is())
+ return;
+
+ uno::Reference<embed::XStorage> xDocumentStorage(xStorageBasedDocument->getDocumentStorage(), uno::UNO_QUERY);
+ OUString aMacrosName("_MS_VBA_Macros");
+ if (!xDocumentStorage.is() || !xDocumentStorage->hasByName(aMacrosName))
+ return;
+
+ const sal_Int32 nOpenMode = embed::ElementModes::READ;
+ uno::Reference<io::XInputStream> xMacrosStream(xDocumentStorage->openStreamElement(aMacrosName, nOpenMode), uno::UNO_QUERY);
+ if (!xMacrosStream.is())
+ return;
+
+ uno::Reference<io::XOutputStream> xOutputStream = openFragmentStream("ppt/vbaProject.bin", "application/vnd.ms-office.vbaProject");
+ comphelper::OStorageHelper::CopyInputToOutput(xMacrosStream, xOutputStream);
+
+ // Write the relationship.
+ addRelation(mPresentationFS->getOutputStream(), "http://schemas.microsoft.com/office/2006/relationships/vbaProject", "vbaProject.bin");
+}
+
void PowerPointExport::ImplWriteSlide( sal_uInt32 nPageNum, sal_uInt32 nMasterNum, sal_uInt16 /* nMode */,
bool bHasBackground, Reference< XPropertySet > const & aXBackgroundPropSet )
{