[Libreoffice-commits] core.git: filter/source oox/source sd/qa sd/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Dec 20 18:26:48 UTC 2018


 filter/source/config/fragments/types/MS_PowerPoint_2007_XML_Template.xcu     |    2 
 filter/source/config/fragments/types/impress_OOXML_Presentation_Template.xcu |    2 
 oox/source/ppt/pptimport.cxx                                                 |    1 
 sd/qa/unit/export-tests-ooxml2.cxx                                           |   23 ++++++++
 sd/qa/unit/sdmodeltestbase.hxx                                               |    3 +
 sd/source/filter/eppt/epptooxml.hxx                                          |    3 +
 sd/source/filter/eppt/pptx-epptooxml.cxx                                     |   26 ++++++++--
 7 files changed, 55 insertions(+), 5 deletions(-)

New commits:
commit 076dd5d5ddac1c65264ad14270f21fda14c793f3
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Thu Dec 20 10:24:54 2018 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Thu Dec 20 19:26:21 2018 +0100

    sd: support for saving into .potx file
    
    MS PowerPoint template format now supported not only for import,
    but for export too.
    
    Change-Id: Ib61798b5fe966b895ed850f4b4ad7d7d06740adc
    Reviewed-on: https://gerrit.libreoffice.org/65475
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/filter/source/config/fragments/types/MS_PowerPoint_2007_XML_Template.xcu b/filter/source/config/fragments/types/MS_PowerPoint_2007_XML_Template.xcu
index 1589c6fdac5b..fa5d33a2b74f 100644
--- a/filter/source/config/fragments/types/MS_PowerPoint_2007_XML_Template.xcu
+++ b/filter/source/config/fragments/types/MS_PowerPoint_2007_XML_Template.xcu
@@ -18,7 +18,7 @@
 <node oor:name="MS PowerPoint 2007 XML Template" 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>potm potx</value></prop>
+    <prop oor:name="Extensions"><value>potx potm</value></prop>
     <prop oor:name="MediaType"><value>application/vnd.openxmlformats-officedocument.presentationml.template</value></prop>
     <prop oor:name="Preferred"><value>true</value></prop>
     <prop oor:name="PreferredFilter"><value>Impress MS PowerPoint 2007 XML Template</value></prop>
diff --git a/filter/source/config/fragments/types/impress_OOXML_Presentation_Template.xcu b/filter/source/config/fragments/types/impress_OOXML_Presentation_Template.xcu
index 02ff99e70449..c34d39541b8c 100644
--- a/filter/source/config/fragments/types/impress_OOXML_Presentation_Template.xcu
+++ b/filter/source/config/fragments/types/impress_OOXML_Presentation_Template.xcu
@@ -18,7 +18,7 @@
 <node oor:name="Office Open XML Presentation Template" 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>potm potx</value></prop>
+    <prop oor:name="Extensions"><value>potx potm</value></prop>
     <prop oor:name="MediaType"><value>application/vnd.openxmlformats-officedocument.presentationml.template</value></prop>
     <prop oor:name="Preferred"><value>true</value></prop>
     <prop oor:name="PreferredFilter"><value>Impress Office Open XML Template</value></prop>
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 2ce9ac4ea0ea..22f661d95546 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -217,6 +217,7 @@ sal_Bool SAL_CALL PowerPointImport::filter( const Sequence< PropertyValue >& rDe
         uno::Sequence<uno::Any> aArguments(comphelper::InitAnyPropertySequence(
         {
             {"IsPPTM", uno::makeAny(exportVBA())},
+            {"IsTemplate", uno::makeAny(isExportTemplate())},
         }));
 
         Reference<css::lang::XMultiServiceFactory> aFactory(getComponentContext()->getServiceManager(), UNO_QUERY_THROW);
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 62014c9ee7a0..a472b0ef20fa 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -68,6 +68,7 @@
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/table/XTable.hpp>
 #include <com/sun/star/table/XMergeableCell.hpp>
+#include <com/sun/star/frame/XLoadable.hpp>
 
 #include <svx/svdotable.hxx>
 #include <config_features.h>
@@ -196,6 +197,7 @@ public:
     void testTdf118825();
     void testTdf119118();
     void testTdf99213();
+    void testPotxExport();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -275,6 +277,7 @@ public:
     CPPUNIT_TEST(testTdf118825);
     CPPUNIT_TEST(testTdf119118);
     CPPUNIT_TEST(testTdf99213);
+    CPPUNIT_TEST(testPotxExport);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -2043,6 +2046,26 @@ void SdOOXMLExportTest2::testTdf99213()
     xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest2::testPotxExport()
+{
+    // Create new document
+    sd::DrawDocShellRef xDocShRef
+        = new sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, false, DocumentType::Draw);
+    uno::Reference<frame::XLoadable> xLoadable(xDocShRef->GetModel(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xLoadable.is());
+    xLoadable->initNew();
+
+    // Export as a POTM template
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), POTX, &tempFile);
+    xDocShRef->DoClose();
+
+    // Load and check content type
+    xmlDocPtr pContentTypes = parseExport(tempFile, "[Content_Types].xml");
+    CPPUNIT_ASSERT(pContentTypes);
+    assertXPath(pContentTypes, "/ContentType:Types/ContentType:Override[@PartName='/ppt/presentation.xml']",
+        "ContentType", "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml");
+}
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index 153798399cb1..922ed9df6285 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -62,6 +62,7 @@ struct FileFormat
 #define SXI_FORMAT_TYPE  (SfxFilterFlags::IMPORT | SfxFilterFlags::TEMPLATE | SfxFilterFlags::OWN | SfxFilterFlags::ALIEN | SfxFilterFlags::PREFERED | SfxFilterFlags::ENCRYPTION)
 #define ODG_FORMAT_TYPE  ( SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::TEMPLATE | SfxFilterFlags::OWN | SfxFilterFlags::DEFAULT | SfxFilterFlags::ENCRYPTION | SfxFilterFlags::PREFERED )
 #define PPTM_FORMAT_TYPE ( SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::STARONEFILTER | SfxFilterFlags::PREFERED )
+#define POTX_FORMAT_TYPE ( SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::TEMPLATE | SfxFilterFlags::STARONEFILTER | SfxFilterFlags::PREFERED )
 
 /** List of file formats we support in Impress unit tests.
 
@@ -83,6 +84,7 @@ FileFormat aFileFormats[] =
     { "sxi",  "StarOffice XML (Impress)", "impress_StarOffice_XML_Impress", "", SXI_FORMAT_TYPE },
     { "odg",  "draw8", "draw8", "", ODG_FORMAT_TYPE },
     { "pptm", "Impress MS PowerPoint 2007 XML VBA", "MS PowerPoint 2007 XML VBA", "", PPTM_FORMAT_TYPE },
+    { "potx", "Impress Office Open XML Template", "Office Open XML Presentation Template", "", POTX_FORMAT_TYPE },
     { nullptr, nullptr, nullptr, nullptr, SfxFilterFlags::NONE }
 };
 
@@ -96,6 +98,7 @@ FileFormat aFileFormats[] =
 #define SXI  7
 #define ODG  8
 #define PPTM 9
+#define POTX 10
 
 /// Base class for filter tests loading or roundtriping a document, and asserting the document model.
 class SdModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest
diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx
index a9b26576d5b6..52289a48b11f 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -124,6 +124,9 @@ private:
     /// Should we export as .pptm, ie. do we contain macros?
     bool mbPptm;
 
+    // Export as a template
+    bool mbExportTemplate;
+
     ::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 d72cc548d6db..d2a5231c7d2e 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -333,6 +333,7 @@ PowerPointExport::PowerPointExport(const Reference< XComponentContext >& rContex
 {
     comphelper::SequenceAsHashMap aArgumentsMap(rArguments);
     mbPptm = aArgumentsMap.getUnpackedValueOrDefault("IsPPTM", false);
+    mbExportTemplate = aArgumentsMap.getUnpackedValueOrDefault("IsTemplate", false);
 }
 
 PowerPointExport::~PowerPointExport()
@@ -379,10 +380,29 @@ bool PowerPointExport::exportDocument()
 
     addRelation(oox::getRelationship(Relationship::OFFICEDOCUMENT), "ppt/presentation.xml");
 
-    // PPTM needs a different media type for the presentation.xml stream.
-    OUString aMediaType("application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml");
+    OUString aMediaType;
     if (mbPptm)
-        aMediaType = "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml";
+    {
+        if (mbExportTemplate)
+        {
+            aMediaType = "application/vnd.ms-powerpoint.template.macroEnabled.main+xml";
+        }
+        else
+        {
+            aMediaType = "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml";
+        }
+    }
+    else
+    {
+        if (mbExportTemplate)
+        {
+            aMediaType = "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml";
+        }
+        else
+        {
+            aMediaType = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
+        }
+    }
 
     mPresentationFS = openFragmentStreamWithSerializer("ppt/presentation.xml", aMediaType);
 


More information about the Libreoffice-commits mailing list