diff options
-rw-r--r-- | oox/source/ppt/presentationfragmenthandler.cxx | 37 | ||||
-rw-r--r-- | sd/source/filter/eppt/epptooxml.hxx | 3 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-epptooxml.cxx | 35 |
3 files changed, 63 insertions, 12 deletions
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index 6f5f690088c9..41a283a445d1 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/drawing/XDrawPages.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XMasterPageTarget.hpp> +#include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> @@ -34,16 +35,18 @@ #include <com/sun/star/presentation/XPresentationPage.hpp> #include <com/sun/star/task/XStatusIndicator.hpp> -#include "oox/drawingml/theme.hxx" -#include "oox/drawingml/drawingmltypes.hxx" -#include "oox/drawingml/themefragmenthandler.hxx" -#include "drawingml/textliststylecontext.hxx" +#include <oox/drawingml/theme.hxx> +#include <oox/drawingml/drawingmltypes.hxx> +#include <oox/drawingml/themefragmenthandler.hxx> +#include <drawingml/textliststylecontext.hxx> #include <oox/helper/attributelist.hxx> -#include "oox/ppt/pptshape.hxx" -#include "oox/ppt/presentationfragmenthandler.hxx" -#include "oox/ppt/slidefragmenthandler.hxx" -#include "oox/ppt/layoutfragmenthandler.hxx" -#include "oox/ppt/pptimport.hxx" +#include <oox/ole/olestorage.hxx> +#include <oox/ole/vbaproject.hxx> +#include <oox/ppt/pptshape.hxx> +#include <oox/ppt/presentationfragmenthandler.hxx> +#include <oox/ppt/slidefragmenthandler.hxx> +#include <oox/ppt/layoutfragmenthandler.hxx> +#include <oox/ppt/pptimport.hxx> #include <oox/token/namespaces.hxx> #include <oox/token/tokens.hxx> @@ -398,8 +401,8 @@ void PresentationFragmentHandler::finalizeImport() StringRangeEnumerator aRangeEnumerator( aPageRange, 0, nPageCount - 1 ); StringRangeEnumerator::Iterator aIter = aRangeEnumerator.begin(); StringRangeEnumerator::Iterator aEnd = aRangeEnumerator.end(); - if(aIter!=aEnd) { - + if (aIter!=aEnd) + { // todo: localized progress bar text const Reference< task::XStatusIndicator >& rxStatusIndicator( getFilter().getStatusIndicator() ); if ( rxStatusIndicator.is() ) @@ -431,6 +434,18 @@ void PresentationFragmentHandler::finalizeImport() if ( rxStatusIndicator.is() ) rxStatusIndicator->end(); } + + // open the VBA project storage + OUString aVbaFragmentPath = getFragmentPathFromFirstType(CREATE_MSOFFICE_RELATION_TYPE("vbaProject")); + if (!aVbaFragmentPath.isEmpty()) + { + uno::Reference<io::XInputStream> xInStrm = getFilter().openInputStream(aVbaFragmentPath); + if (xInStrm.is()) + { + StorageRef xPrjStrg(new oox::ole::OleStorage(getFilter().getComponentContext(), xInStrm, false)); + getFilter().getVbaProject().importVbaProject(*xPrjStrg); + } + } } // CT_Presentation diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx index 4a794e6e4d33..1134daf6cb7a 100644 --- a/sd/source/filter/eppt/epptooxml.hxx +++ b/sd/source/filter/eppt/epptooxml.hxx @@ -159,6 +159,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 2319b431ee8a..68b8372f2777 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -27,12 +27,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> @@ -53,6 +55,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> @@ -66,6 +69,7 @@ #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/document/XStorageBasedDocument.hpp> // presentation namespaces #define PNMSS FSNS(XML_xmlns, XML_a), "http://schemas.openxmlformats.org/drawingml/2006/main", \ @@ -395,6 +399,8 @@ bool PowerPointExport::exportDocument() throw (css::uno::RuntimeException, std:: WriteAuthors(); + WriteVBA(); + mPresentationFS->endElementNS( XML_p, XML_presentation ); mPresentationFS.reset(); // Free all FSHelperPtr, to flush data before committing storage @@ -1437,7 +1443,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(); @@ -1511,6 +1518,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 ) { |