Kaydet (Commit) 076dd5d5 authored tarafından Vasily Melenchuk's avatar Vasily Melenchuk Kaydeden (comit) Thorsten Behrens

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: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 5113d2f4
......@@ -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>
......
......@@ -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>
......
......@@ -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);
......
......@@ -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();
......
......@@ -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
......
......@@ -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];
......
......@@ -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);
......
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