[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - filter/source oox/source sd/qa sd/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Dec 30 23:35:27 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                                           |   24 +++++++++
 sd/qa/unit/sdmodeltestbase.hxx                                               |    3 +
 sd/source/filter/eppt/epptooxml.hxx                                          |    3 +
 sd/source/filter/eppt/pptx-epptooxml.cxx                                     |   26 ++++++++--
 7 files changed, 56 insertions(+), 5 deletions(-)

New commits:
commit e9adb0201c52777ff2db221e0a249df24a34568d
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: Mon Dec 31 00:35:06 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>
    Reviewed-on: https://gerrit.libreoffice.org/65703
    Tested-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 41733e1f2825..452ff324ff0f 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -235,6 +235,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 77ce54891494..21edfb943f5d 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>
@@ -147,6 +148,7 @@ public:
     void testTdf104789();
     void testOpenDocumentAsReadOnly();
     void testTdf116350TextEffects();
+    void testPotxExport();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -216,6 +218,7 @@ public:
     CPPUNIT_TEST(testTdf104789);
     CPPUNIT_TEST(testOpenDocumentAsReadOnly);
     CPPUNIT_TEST(testTdf116350TextEffects);
+    CPPUNIT_TEST(testPotxExport);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1806,6 +1809,27 @@ void SdOOXMLExportTest2::testTdf116350TextEffects()
     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 a51bc3c260a1..0da43ea36ce1 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -60,6 +60,7 @@ struct FileFormat
 #define FODP_FORMAT_TYPE  (SfxFilterFlags::STARONEFILTER | SfxFilterFlags::OWN | SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT)
 #define SXI_FORMAT_TYPE  (SfxFilterFlags::IMPORT | SfxFilterFlags::TEMPLATE | SfxFilterFlags::OWN | SfxFilterFlags::ALIEN | SfxFilterFlags::PREFERED | SfxFilterFlags::ENCRYPTION)
 #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.
 
@@ -81,6 +82,7 @@ FileFormat aFileFormats[] =
     { "sxi",  "StarOffice XML (Impress)", "OpenOffice.org 1.0 Presentation", "", SXI_FORMAT_TYPE },
     { "odg",  "draw8", "draw8", "", ODP_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 }
 };
 
@@ -94,6 +96,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 7fff989cc23d..6836e9d47e65 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -138,6 +138,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 a4e95a6224ee..bb9990493859 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -345,6 +345,7 @@ PowerPointExport::PowerPointExport(const Reference< XComponentContext >& rContex
 {
     comphelper::SequenceAsHashMap aArgumentsMap(rArguments);
     mbPptm = aArgumentsMap.getUnpackedValueOrDefault("IsPPTM", false);
+    mbExportTemplate = aArgumentsMap.getUnpackedValueOrDefault("IsTemplate", false);
 }
 
 PowerPointExport::~PowerPointExport()
@@ -391,10 +392,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