Kaydet (Commit) 5d0901a7 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

sd pptm: Add a separate PPTM filter.

Similarly to commit 697173f6, 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
Reviewed-on: https://gerrit.libreoffice.org/40195Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Reviewed-on: https://gerrit.libreoffice.org/40265Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst 7b0607aa
......@@ -597,6 +597,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 \
......
......@@ -27,4 +27,4 @@
<prop oor:name="UIName">
<value xml:lang="en-US">Microsoft PowerPoint 2007-2013 XML</value>
</prop>
</node>
</node>
<!--
* 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>
......@@ -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>
......
<!--
* 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>
......@@ -192,10 +192,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" );
......
......@@ -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>
......@@ -216,14 +217,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;
......
......@@ -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() override;
/// Should we export as .pptm, ie. do we contain macros?
bool mbPptm;
::sax_fastparser::FSHelperPtr mPresentationFS;
LayoutInfo mLayoutInfo[EPP_LAYOUT_SIZE];
......@@ -146,8 +147,6 @@ private:
bool mbCreateNotes;
static sal_Int32 nStyleLevelToken[5];
::oox::drawingml::ShapeExport::ShapeHashMap maShapeMap;
struct AuthorComments {
......
......@@ -27,6 +27,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>
......@@ -95,15 +96,15 @@ 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::drawingml;
using namespace oox::core;
#if OSL_DEBUG_LEVEL > 1
void dump_pset(Reference< XPropertySet > const & rXPropSet);
#endif
namespace oox {
using namespace drawingml;
namespace core {
namespace core {
class PowerPointShapeExport : public ShapeExport
{
......@@ -124,6 +125,9 @@ public:
bool WritePlaceholder( const Reference< XShape >& xShape, PlaceholderType ePlaceholder, bool bMaster );
};
}
}
enum PPTXLayout {
LAYOUT_BLANK,
LAYOUT_TITLE_SLIDE,
......@@ -315,8 +319,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)
......@@ -324,6 +328,8 @@ PowerPointExport::PowerPointExport( const Reference< XComponentContext > & rxCtx
, mnAnimationNodeIdMax(1)
, mbCreateNotes(false)
{
comphelper::SequenceAsHashMap aArgumentsMap(rArguments);
mbPptm = aArgumentsMap.getUnpackedValueOrDefault("IsPPTM", false);
}
PowerPointExport::~PowerPointExport()
......@@ -358,8 +364,12 @@ bool PowerPointExport::exportDocument()
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",
......@@ -1658,15 +1668,6 @@ void PowerPointExport::AddLayoutIdAndRelation( const FSHelperPtr& pFS, sal_Int32
FSEND );
}
sal_Int32 PowerPointExport::nStyleLevelToken[5] =
{
XML_lvl1pPr,
XML_lvl2pPr,
XML_lvl3pPr,
XML_lvl4pPr,
XML_lvl5pPr
};
void PowerPointExport::ImplWriteSlideMaster( sal_uInt32 nPageNum, Reference< XPropertySet > const & aXBackgroundPropSet )
{
SAL_INFO("sd.eppt", "write slide master: " << nPageNum << "\n--------------");
......@@ -2286,51 +2287,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 >();
}
/// @throws uno::Exception
uno::Reference< uno::XInterface > SAL_CALL PowerPointExport_createInstance(const uno::Reference< XComponentContext > & rxCtxt )
{
return static_cast<cppu::OWeakObject*>(new PowerPointExport( rxCtxt ));
}
OUString PowerPointExport::getImplementationName()
{
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"
extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* SAL_CALL
css_comp_Impress_oox_PowerPointExport(uno::XComponentContext* rxCtxt,
uno::Sequence<css::uno::Any> const& rArguments)
{
SAL_DLLPUBLIC_EXPORT void* SAL_CALL sdfilt_component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey )
{
return cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries );
}
return cppu::acquire(new PowerPointExport(rxCtxt, rArguments));
}
#if OSL_DEBUG_LEVEL > 1
......
......@@ -387,8 +387,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.
......
......@@ -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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment