summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-07-19 08:42:36 +0200
committerAndras Timar <andras.timar@collabora.com>2017-07-19 19:31:11 +0100
commit8891d6bd2bbd8983d79d21893aee3371c39932e4 (patch)
tree7f6e2efca698733f6145ad8a1d386855fd78ac9a
parent8284f39cf94980c734bcca7f1e885fe6b608caac (diff)
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
-rw-r--r--filter/Configuration_filter.mk2
-rw-r--r--filter/source/config/fragments/filters/impress_MS_PowerPoint_2007_XML.xcu2
-rw-r--r--filter/source/config/fragments/filters/impress_MS_PowerPoint_2007_XML_VBA.xcu30
-rw-r--r--filter/source/config/fragments/types/MS_PowerPoint_2007_XML.xcu2
-rw-r--r--filter/source/config/fragments/types/MS_PowerPoint_2007_XML_VBA.xcu28
-rw-r--r--oox/source/core/filterdetect.cxx6
-rw-r--r--oox/source/ppt/pptimport.cxx18
-rw-r--r--sd/source/filter/eppt/epptooxml.hxx7
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx67
-rw-r--r--sd/source/ui/docshell/docshel4.cxx5
-rw-r--r--sd/util/sdfilt.component2
11 files changed, 108 insertions, 61 deletions
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>