[Libreoffice-commits] core.git: Branch 'distro/collabora/cd-5.3' - 5 commits - configure.ac desktop/source filter/Configuration_filter.mk filter/source include/comphelper oox/source sd/source sd/util

Jan Holesovsky kendy at collabora.com
Thu Jul 20 15:15:07 UTC 2017


 configure.ac                                                                  |    2 
 desktop/source/lib/init.cxx                                                   |    3 
 filter/Configuration_filter.mk                                                |    2 
 filter/source/config/fragments/filters/impress_MS_PowerPoint_2007_XML.xcu     |    2 
 filter/source/config/fragments/filters/impress_MS_PowerPoint_2007_XML_VBA.xcu |   30 ++
 filter/source/config/fragments/types/MS_PowerPoint_2007_XML.xcu               |    2 
 filter/source/config/fragments/types/MS_PowerPoint_2007_XML_VBA.xcu           |   28 ++
 include/comphelper/propertysequence.hxx                                       |   19 +
 oox/source/core/filterdetect.cxx                                              |    6 
 oox/source/ppt/pptimport.cxx                                                  |   18 +
 oox/source/ppt/presentationfragmenthandler.cxx                                |   37 ++-
 sd/source/filter/eppt/epptooxml.hxx                                           |   10 
 sd/source/filter/eppt/pptx-epptooxml.cxx                                      |  102 +++++-----
 sd/source/ui/docshell/docshel4.cxx                                            |    5 
 sd/util/sdfilt.component                                                      |    2 
 15 files changed, 194 insertions(+), 74 deletions(-)

New commits:
commit 4313d7ed27a332dfe01ecca5652f4c8a366386d0
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jul 19 19:40:52 2017 +0100

    Bump version to 5.3-21.
    
    This does not have all the patches that the 5.3-21 will have, but those that
    are relevant for the Online are going to be present in both.
    
    Change-Id: I9231cc0b3a691096eb7c183acd344e4b4b55f22a

diff --git a/configure.ac b/configure.ac
index 6342cdb95749..c21b6875d58d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,7 +9,7 @@ dnl in order to create a configure script.
 # several non-alphanumeric characters, those are split off and used only for the
 # ABOUTBOXPRODUCTVERSIONSUFFIX in openoffice.lst. Why that is necessary, no idea.
 
-AC_INIT([Collabora Office],[5.3.10.19],[],[],[https://collaboraoffice.com/])
+AC_INIT([Collabora Office],[5.3.10.21],[],[],[https://collaboraoffice.com/])
 
 AC_PREREQ([2.59])
 
commit 8e4fd745192aed492e0111e20283f463d4374af8
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jul 19 16:35:10 2017 +0200

    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

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 )
 {
commit 6468a2ad9a5dcc6a0f3d174314ee94eecf9426f3
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jul 19 08:46:22 2017 +0200

    lok: Add docm/xlsm/pptm filters to be known by LOK.
    
    Change-Id: I4995498132b832ce783efc9740f1d7129f085a01

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 32034e72f229..9d9749469420 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -136,6 +136,7 @@ typedef struct
 static const ExtensionMap aWriterExtensionMap[] =
 {
     { "doc",   "MS Word 97" },
+    { "docm",  "MS Word 2007 XML VBA" },
     { "docx",  "MS Word 2007 XML" },
     { "fodt",  "OpenDocument Text Flat XML" },
     { "html",  "HTML (StarWriter)" },
@@ -158,6 +159,7 @@ static const ExtensionMap aCalcExtensionMap[] =
     { "pdf",   "calc_pdf_Export" },
     { "xhtml", "XHTML Calc File" },
     { "xls",   "MS Excel 97" },
+    { "xlsm",  "Calc MS Excel 2007 VBA XML" },
     { "xlsx",  "Calc MS Excel 2007 XML" },
     { "png",   "calc_png_Export" },
     { nullptr, nullptr }
@@ -173,6 +175,7 @@ static const ExtensionMap aImpressExtensionMap[] =
     { "pdf",   "impress_pdf_Export" },
     { "potm",  "Impress MS PowerPoint 2007 XML Template" },
     { "pot",   "MS PowerPoint 97 Vorlage" },
+    { "pptm",  "Impress MS PowerPoint 2007 XML VBA" },
     { "pptx",  "Impress MS PowerPoint 2007 XML" },
     { "pps",   "MS PowerPoint 97 Autoplay" },
     { "ppt",   "MS PowerPoint 97" },
commit 8891d6bd2bbd8983d79d21893aee3371c39932e4
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jul 19 08:42:36 2017 +0200

    sd pptm: Add a separate PPTM filter.
    
    Similarly to commit 697173f6fdfae581022cfdb5ec5171c5a3be58f0, we have to
    preserve the correct content-type which is not the same for PPTX and PPTM.
    
    This commit also changes sdfilt.component to use the constructor feature.
    
    Change-Id: I4b334540ec07a53d308e6b9dd6403294842bddf8

diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index 9c25d1543e9f..48d1ffef02ff 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -598,6 +598,7 @@ $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_impress_types.xc
 	MS_PowerPoint_2007_XML \
 	MS_PowerPoint_2007_XML_AutoPlay \
 	MS_PowerPoint_2007_XML_Template \
+	MS_PowerPoint_2007_XML_VBA \
 	impress_OOXML_Presentation \
 	impress_OOXML_Presentation_Template \
 	impress_OOXML_Presentation_AutoPlay \
@@ -622,6 +623,7 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_impress_filter
 	impress_MS_PowerPoint_2007_XML \
 	impress_MS_PowerPoint_2007_XML_AutoPlay \
 	impress_MS_PowerPoint_2007_XML_Template \
+	impress_MS_PowerPoint_2007_XML_VBA \
 	impress_OOXML \
 	impress_OOXML_Template \
 	impress_OOXML_AutoPlay \
diff --git a/filter/source/config/fragments/filters/impress_MS_PowerPoint_2007_XML.xcu b/filter/source/config/fragments/filters/impress_MS_PowerPoint_2007_XML.xcu
index 8814d1e4413d..08d17d688a3b 100644
--- a/filter/source/config/fragments/filters/impress_MS_PowerPoint_2007_XML.xcu
+++ b/filter/source/config/fragments/filters/impress_MS_PowerPoint_2007_XML.xcu
@@ -27,4 +27,4 @@
     <prop oor:name="UIName">
         <value xml:lang="en-US">Microsoft PowerPoint 2007-2013 XML</value>
     </prop>
-    </node>
+</node>
diff --git a/filter/source/config/fragments/filters/impress_MS_PowerPoint_2007_XML_VBA.xcu b/filter/source/config/fragments/filters/impress_MS_PowerPoint_2007_XML_VBA.xcu
new file mode 100644
index 000000000000..3f52eea5eea8
--- /dev/null
+++ b/filter/source/config/fragments/filters/impress_MS_PowerPoint_2007_XML_VBA.xcu
@@ -0,0 +1,30 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<node oor:name="Impress MS PowerPoint 2007 XML VBA" oor:op="replace">
+    <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER PREFERRED ENCRYPTION PASSWORDTOMODIFY SUPPORTSSIGNING</value></prop>
+    <prop oor:name="UIComponent"/>
+    <prop oor:name="FilterService"><value>com.sun.star.comp.oox.ppt.PowerPointImport</value></prop>
+    <prop oor:name="UserData"><value>macro-enabled</value></prop>
+    <prop oor:name="FileFormatVersion"/>
+    <prop oor:name="Type"><value>MS PowerPoint 2007 XML VBA</value></prop>
+    <prop oor:name="TemplateName"/>
+    <prop oor:name="DocumentService"><value>com.sun.star.presentation.PresentationDocument</value></prop>
+    <prop oor:name="UIName">
+        <value xml:lang="en-US">Microsoft PowerPoint 2007-2013 XML VBA</value>
+    </prop>
+</node>
diff --git a/filter/source/config/fragments/types/MS_PowerPoint_2007_XML.xcu b/filter/source/config/fragments/types/MS_PowerPoint_2007_XML.xcu
index b709d6b8804d..5c3fdc2e4c31 100644
--- a/filter/source/config/fragments/types/MS_PowerPoint_2007_XML.xcu
+++ b/filter/source/config/fragments/types/MS_PowerPoint_2007_XML.xcu
@@ -18,7 +18,7 @@
 <node oor:name="MS PowerPoint 2007 XML" oor:op="replace" >
     <prop oor:name="DetectService"><value>com.sun.star.comp.oox.FormatDetector</value></prop>
     <prop oor:name="URLPattern"/>
-    <prop oor:name="Extensions"><value>pptx pptm</value></prop>
+    <prop oor:name="Extensions"><value>pptx</value></prop>
     <prop oor:name="MediaType"><value>application/vnd.openxmlformats-officedocument.presentationml.presentation</value></prop>
     <prop oor:name="Preferred"><value>true</value></prop>
     <prop oor:name="PreferredFilter"><value>Impress MS PowerPoint 2007 XML</value></prop>
diff --git a/filter/source/config/fragments/types/MS_PowerPoint_2007_XML_VBA.xcu b/filter/source/config/fragments/types/MS_PowerPoint_2007_XML_VBA.xcu
new file mode 100644
index 000000000000..4e4519f29794
--- /dev/null
+++ b/filter/source/config/fragments/types/MS_PowerPoint_2007_XML_VBA.xcu
@@ -0,0 +1,28 @@
+
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<node oor:name="MS PowerPoint 2007 XML VBA" oor:op="replace" >
+    <prop oor:name="DetectService"><value>com.sun.star.comp.oox.FormatDetector</value></prop>
+    <prop oor:name="URLPattern"/>
+    <prop oor:name="Extensions"><value>pptm</value></prop>
+    <prop oor:name="MediaType"><value>application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml</value></prop>
+    <prop oor:name="Preferred"><value>true</value></prop>
+    <prop oor:name="PreferredFilter"><value>Impress MS PowerPoint 2007 XML VBA</value></prop>
+    <prop oor:name="UIName"><value xml:lang="en-US">Microsoft PowerPoint 2007-2013 XML VBA</value></prop>
+    <prop oor:name="ClipboardFormat"/>
+</node>
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index 88d3926a2656..3b7fe2bfa737 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -197,10 +197,12 @@ OUString FilterDetectDocHandler::getFilterNameFromContentType( const OUString& r
     if ( rContentType == "application/vnd.ms-excel.sheet.binary.macroEnabled.main" )
         return OUString( "MS Excel 2007 Binary" );
 
-    if( rContentType == "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml" ||
-        rContentType == "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml" )
+    if (rContentType == "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml")
         return OUString( "MS PowerPoint 2007 XML" );
 
+    if (rContentType == "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml")
+        return OUString( "MS PowerPoint 2007 XML VBA" );
+
     if( rContentType == "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml" ||
         rContentType == "application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml" )
         return OUString( "MS PowerPoint 2007 XML AutoPlay" );
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 2b2619acd749..920aa43e60fc 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -21,6 +21,7 @@
 
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
+#include <comphelper/propertysequence.hxx>
 #include <osl/diagnose.h>
 #include <vcl/msgbox.hxx>
 #include <vcl/svapp.hxx>
@@ -175,14 +176,23 @@ sal_Bool SAL_CALL PowerPointImport::filter( const Sequence< PropertyValue >& rDe
     if( XmlFilterBase::filter( rDescriptor ) )
         return true;
 
-    if( isExportFilter() ) {
-        Reference< XExporter > xExporter( Reference<css::lang::XMultiServiceFactory>(getComponentContext()->getServiceManager(), UNO_QUERY_THROW)->createInstance( "com.sun.star.comp.Impress.oox.PowerPointExport" ), UNO_QUERY );
+    if (isExportFilter())
+    {
+        uno::Sequence<uno::Any> aArguments(comphelper::InitAnySequence(
+        {
+            {"IsPPTM", uno::makeAny(exportVBA())},
+        }));
+
+        Reference<css::lang::XMultiServiceFactory> aFactory(getComponentContext()->getServiceManager(), UNO_QUERY_THROW);
+        Reference< XExporter > xExporter(aFactory->createInstanceWithArguments("com.sun.star.comp.Impress.oox.PowerPointExport", aArguments), UNO_QUERY);
 
-        if( xExporter.is() ) {
+        if (xExporter.is())
+        {
             Reference< XComponent > xDocument( getModel(), UNO_QUERY );
             Reference< XFilter > xFilter( xExporter, UNO_QUERY );
 
-            if( xFilter.is() ) {
+            if (xFilter.is())
+            {
                 xExporter->setSourceDocument( xDocument );
                 if( xFilter->filter( rDescriptor ) )
                     return true;
diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx
index 178261b7e449..4a794e6e4d33 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -39,8 +39,6 @@ namespace oox {
     }
 namespace core {
 
-class PowerPointShapeExport;
-
 struct LayoutInfo
 {
     std::vector< sal_Int32 > mnFileIdArray;
@@ -65,7 +63,7 @@ class PowerPointExport : public XmlFilterBase, public PPTWriterBase
     friend class PowerPointShapeExport;
 public:
 
-    PowerPointExport( const css::uno::Reference< css::uno::XComponentContext > & rxCtxt  );
+    PowerPointExport(const css::uno::Reference<css::uno::XComponentContext> & rContext, const css::uno::Sequence<css::uno::Any>& rArguments);
 
     virtual ~PowerPointExport() override;
 
@@ -134,6 +132,9 @@ private:
 
     virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException, std::exception) override;
 
+    /// Should we export as .pptm, ie. do we contain macros?
+    bool mbPptm;
+
     ::sax_fastparser::FSHelperPtr mPresentationFS;
 
     LayoutInfo mLayoutInfo[EPP_LAYOUT_SIZE];
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 03ddcd056e3f..2319b431ee8a 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -26,6 +26,7 @@
 #include <epptdef.hxx>
 #include <oox/export/shapes.hxx>
 
+#include <comphelper/sequenceashashmap.hxx>
 #include <cppuhelper/implementationentry.hxx>
 #include <cppuhelper/factory.hxx>
 #include <sax/fshelper.hxx>
@@ -91,7 +92,9 @@ using ::com::sun::star::beans::XPropertySet;
 using ::com::sun::star::beans::XPropertySetInfo;
 using ::com::sun::star::container::XIndexAccess;
 using ::sax_fastparser::FSHelperPtr;
-
+using namespace oox;
+using namespace oox::drawingml;
+using namespace oox::core;
 
 #if OSL_DEBUG_LEVEL > 1
 void dump_pset(Reference< XPropertySet > const & rXPropSet);
@@ -99,10 +102,6 @@ void dump_pset(Reference< XPropertySet > const & rXPropSet);
 
 #define IDS(x) OString(OStringLiteral(#x " ") + OString::number( mnShapeIdMax++ )).getStr()
 
-namespace oox {
-    using namespace drawingml;
-    namespace core {
-
 class PowerPointShapeExport : public ShapeExport
 {
     PowerPointExport&   mrExport;
@@ -313,8 +312,8 @@ ShapeExport& PowerPointShapeExport::WriteUnknownShape( const Reference< XShape >
     return *this;
 }
 
-PowerPointExport::PowerPointExport( const Reference< XComponentContext > & rxCtxt  )
-    : XmlFilterBase(rxCtxt)
+PowerPointExport::PowerPointExport(const Reference< XComponentContext > & rContext, const uno::Sequence<uno::Any>& rArguments)
+    : XmlFilterBase(rContext)
     , PPTWriterBase()
     , mnLayoutFileIdMax(1)
     , mnSlideIdMax(1 << 8)
@@ -323,6 +322,9 @@ PowerPointExport::PowerPointExport( const Reference< XComponentContext > & rxCtx
     , mbCreateNotes(false)
 {
     memset( mLayoutInfo, 0, sizeof(mLayoutInfo) );
+
+    comphelper::SequenceAsHashMap aArgumentsMap(rArguments);
+    mbPptm = aArgumentsMap.getUnpackedValueOrDefault("IsPPTM", false);
 }
 
 PowerPointExport::~PowerPointExport()
@@ -357,8 +359,12 @@ bool PowerPointExport::exportDocument() throw (css::uno::RuntimeException, std::
 
     addRelation( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", "ppt/presentation.xml" );
 
-    mPresentationFS = openFragmentStreamWithSerializer( "ppt/presentation.xml",
-                                                    "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml" );
+    // PPTM needs a different media type for the presentation.xml stream.
+    OUString aMediaType("application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml");
+    if (mbPptm)
+        aMediaType = "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml";
+
+    mPresentationFS = openFragmentStreamWithSerializer("ppt/presentation.xml", aMediaType);
 
     addRelation( mPresentationFS->getOutputStream(),
                  "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
@@ -2288,50 +2294,17 @@ bool PowerPointExport::ImplCreateMainNotes()
     return true;
 }
 
-OUString SAL_CALL PowerPointExport_getImplementationName() throw()
-{
-    return OUString( "com.sun.star.comp.Impress.oox.PowerPointExport" );
-}
-
-uno::Sequence< OUString > SAL_CALL PowerPointExport_getSupportedServiceNames() throw()
-{
-    return Sequence< OUString >();
-}
-
-uno::Reference< uno::XInterface > SAL_CALL PowerPointExport_createInstance(const uno::Reference< XComponentContext > & rxCtxt ) throw( uno::Exception )
-{
-    return static_cast<cppu::OWeakObject*>(new PowerPointExport( rxCtxt ));
-}
-
 OUString PowerPointExport::getImplementationName() throw (css::uno::RuntimeException, std::exception)
 {
-    return PowerPointExport_getImplementationName();
-}
-}
+    return OUString("com.sun.star.comp.Impress.oox.PowerPointExport");
 }
 
 // UNO component
-
-static const struct cppu::ImplementationEntry g_entries[] =
-{
-    {
-        oox::core::PowerPointExport_createInstance,
-        oox::core::PowerPointExport_getImplementationName,
-       oox::core::PowerPointExport_getSupportedServiceNames,
-        cppu::createSingleComponentFactory,
-        nullptr , 0
-    },
-    { nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
-};
-
-extern "C"
-{
-
-SAL_DLLPUBLIC_EXPORT void* SAL_CALL sdfilt_component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey )
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* SAL_CALL
+css_comp_Impress_oox_PowerPointExport(uno::XComponentContext* rxCtxt,
+                                      uno::Sequence<css::uno::Any> const& rArguments)
 {
-    return cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries );
-}
-
+    return cppu::acquire(new PowerPointExport(rxCtxt, rArguments));
 }
 
 #if OSL_DEBUG_LEVEL > 1
diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx
index b3b6bd475fa8..395bda129fa2 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -386,8 +386,9 @@ bool DrawDocShell::ImportFrom(SfxMedium &rMedium,
         uno::Reference<text::XTextRange> const& xInsertPosition)
 {
     const OUString aFilterName( rMedium.GetFilter()->GetFilterName() );
-    if( aFilterName == "Impress MS PowerPoint 2007 XML" ||
-        aFilterName == "Impress MS PowerPoint 2007 XML AutoPlay" )
+    if (aFilterName == "Impress MS PowerPoint 2007 XML" ||
+        aFilterName == "Impress MS PowerPoint 2007 XML AutoPlay" ||
+        aFilterName == "Impress MS PowerPoint 2007 XML VBA")
     {
         // As this is a MSFT format, we should use the "MS Compat"
         // mode for spacing before and after paragraphs.
diff --git a/sd/util/sdfilt.component b/sd/util/sdfilt.component
index aca7724c625a..134a79f2d30a 100644
--- a/sd/util/sdfilt.component
+++ b/sd/util/sdfilt.component
@@ -9,5 +9,5 @@
 -->
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
     prefix="sdfilt" xmlns="http://openoffice.org/2010/uno-components">
-  <implementation name="com.sun.star.comp.Impress.oox.PowerPointExport"/>
+  <implementation name="com.sun.star.comp.Impress.oox.PowerPointExport" constructor="css_comp_Impress_oox_PowerPointExport"/>
 </component>
commit 8284f39cf94980c734bcca7f1e885fe6b608caac
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jul 19 08:35:26 2017 +0200

    comphelper: Allow initializer lists for Sequences of NamedValues.
    
    This is particularly useful for creation of sequences that are later
    unwrapped using comphelper::SequenceAsHashMap.
    
    Eg.
    
        uno::Sequence<uno::Any> aArguments(comphelper::InitAnySequence(
        {
            {"SomethingNamed", uno::makeAny(true)},
        }));
    
        Reference<XExporter> xExporter(aFactory->createInstanceWithArguments(..., aArguments), UNO_QUERY);
    
    and in the implementation:
    
        comphelper::SequenceAsHashMap aArgumentsMap(rArguments);
        mbSomething = aArgumentsMap.getUnpackedValueOrDefault("SomethingNamed", false);
    
    Change-Id: Ib1135078a99ca08f50bf51184f2ec7d13f5e6b4d

diff --git a/include/comphelper/propertysequence.hxx b/include/comphelper/propertysequence.hxx
index 28561a6904d7..6af5bcccc6fc 100644
--- a/include/comphelper/propertysequence.hxx
+++ b/include/comphelper/propertysequence.hxx
@@ -14,10 +14,12 @@
 #include <initializer_list>
 #include <com/sun/star/uno/Any.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/NamedValue.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 
 namespace comphelper
 {
+    /// Init list for property sequences.
     inline css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(
         ::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
     {
@@ -33,6 +35,23 @@ namespace comphelper
         }
         return vResult;
     }
+
+    /// Init list for property sequences that wrap the NamedValues in Anys.
+    ///
+    /// This is particularly useful for creation of sequences that are later
+    /// unwrapped using comphelper::SequenceAsHashMap.
+    inline css::uno::Sequence< css::uno::Any > InitAnySequence(
+        ::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
+    {
+        css::uno::Sequence<css::uno::Any> vResult{static_cast<sal_Int32>(vInit.size())};
+        size_t nCount{0};
+        for(const auto& aEntry : vInit)
+        {
+            vResult[nCount] = css::uno::makeAny(css::beans::NamedValue(aEntry.first, aEntry.second));
+            ++nCount;
+        }
+        return vResult;
+    }
 }   // namespace comphelper
 
 


More information about the Libreoffice-commits mailing list