From 5d0901a75e7ef96dc722b5277450cc18ad163f7b Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Wed, 19 Jul 2017 08:42:36 +0200 Subject: 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 Reviewed-on: https://gerrit.libreoffice.org/40195 Reviewed-by: Miklos Vajna Tested-by: Miklos Vajna Reviewed-on: https://gerrit.libreoffice.org/40265 Tested-by: Jenkins Reviewed-by: Jan Holesovsky --- sd/source/filter/eppt/epptooxml.hxx | 9 ++-- sd/source/filter/eppt/pptx-epptooxml.cxx | 77 +++++++++----------------------- sd/source/ui/docshell/docshel4.cxx | 5 ++- sd/util/sdfilt.component | 2 +- 4 files changed, 30 insertions(+), 63 deletions(-) (limited to 'sd') diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx index 2c486a778ce1..cc60f76d8089 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 & rContext, const css::uno::Sequence& 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 { diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 5795a339ce23..c359859358a6 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -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& 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(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 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 diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx index c124c564a5a1..6c077ab3ae1a 100644 --- a/sd/source/ui/docshell/docshel4.cxx +++ b/sd/source/ui/docshell/docshel4.cxx @@ -387,8 +387,9 @@ bool DrawDocShell::ImportFrom(SfxMedium &rMedium, uno::Reference 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 @@ --> - + -- cgit