summaryrefslogtreecommitdiffstats
path: root/sd
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2018-12-20 10:24:54 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-12-20 19:26:21 +0100
commit076dd5d5ddac1c65264ad14270f21fda14c793f3 (patch)
tree5e6329af8c1606d1a0c73f711623a9806c22898b /sd
parentuset https:// instead of git:// for submodules (diff)
downloadcore-076dd5d5ddac1c65264ad14270f21fda14c793f3.tar.gz
core-076dd5d5ddac1c65264ad14270f21fda14c793f3.zip
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@CIB.de>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx23
-rw-r--r--sd/qa/unit/sdmodeltestbase.hxx3
-rw-r--r--sd/source/filter/eppt/epptooxml.hxx3
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx26
4 files changed, 52 insertions, 3 deletions
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);