summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorGrzegorz Araminowicz <grzegorz.araminowicz@collabora.com>2019-03-13 10:49:30 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-04-08 10:07:35 +0200
commitaafaf1f55fa413ad49d4556cf7c0a713dd206ae4 (patch)
tree1cfe3368ee1aeec9fb45e081c89c7d59ecc1432f /sd
parent31ac398cfa30694b18240d31df17a58d699b5bf6 (diff)
PPTX export: save SmartArt as diagram instead of group of shapes
preserving SmartArt allows editing it in PowerPoint after saving as pptx file * moved common parts for docx and pptx export to oox/drawingml * fixed export tests that expected shapes on output Change-Id: I3e70a9f4177bebf5e1671232f4cd0ef0e7212626 Reviewed-on: https://gerrit.libreoffice.org/69598 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/pptx/group.pptxbin69168 -> 50247 bytes
-rw-r--r--sd/qa/unit/data/pptx/smartart-preserve.pptxbin0 -> 40598 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx62
-rw-r--r--sd/source/filter/eppt/epptooxml.hxx6
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx14
5 files changed, 77 insertions, 5 deletions
diff --git a/sd/qa/unit/data/pptx/group.pptx b/sd/qa/unit/data/pptx/group.pptx
index 8895fe2a2203..f0b739ee23ab 100644
--- a/sd/qa/unit/data/pptx/group.pptx
+++ b/sd/qa/unit/data/pptx/group.pptx
Binary files differ
diff --git a/sd/qa/unit/data/pptx/smartart-preserve.pptx b/sd/qa/unit/data/pptx/smartart-preserve.pptx
new file mode 100644
index 000000000000..6108a8c77819
--- /dev/null
+++ b/sd/qa/unit/data/pptx/smartart-preserve.pptx
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 06330de5101b..91929569f204 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -199,6 +199,7 @@ public:
void testTdf99213();
void testPotxExport();
void testTdf44223();
+ void testSmartArtPreserve();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
@@ -280,6 +281,7 @@ public:
CPPUNIT_TEST(testTdf99213);
CPPUNIT_TEST(testPotxExport);
CPPUNIT_TEST(testTdf44223);
+ CPPUNIT_TEST(testSmartArtPreserve);
CPPUNIT_TEST_SUITE_END();
@@ -304,6 +306,7 @@ public:
{ "a14", "http://schemas.microsoft.com/office/drawing/2010/main" },
{ "wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" },
{ "wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" },
+ { "dgm", "http://schemas.openxmlformats.org/drawingml/2006/diagram" },
};
for (size_t i = 0; i < SAL_N_ELEMENTS(namespaces); ++i)
{
@@ -1360,6 +1363,12 @@ void SdOOXMLExportTest2::testTdf104788()
void SdOOXMLExportTest2::testSmartartRotation2()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-rotation2.pptx"), PPTX);
+
+ // clear SmartArt data to check how group shapes with double-rotated children are exported, not smartart
+ uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
+ uno::Sequence<beans::PropertyValue> aInteropGrabBag;
+ xShape->setPropertyValue("InteropGrabBag", uno::makeAny(aInteropGrabBag));
+
utl::TempFile tempFile;
xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
xDocShRef->DoClose();
@@ -1413,10 +1422,10 @@ void SdOOXMLExportTest2::testGroupsPosition()
xDocShRef->DoClose();
xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
- assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "x", "4040640");
- assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "y", "4273920");
- assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "6796800");
- assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "4273920");
+ assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "x", "5004000");
+ assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "y", "3310560");
+ assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "7760160");
+ assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "3310560");
}
void SdOOXMLExportTest2::testGroupsRotatedPosition()
@@ -2105,6 +2114,51 @@ void SdOOXMLExportTest2::testTdf44223()
xDocShRef->DoClose();
}
+void SdOOXMLExportTest2::testSmartArtPreserve()
+{
+ ::sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-preserve.pptx"), PPTX);
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+
+ xmlDocPtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDoc, "//p:sld/p:cSld/p:spTree/p:graphicFrame/p:nvGraphicFramePr/p:cNvPr");
+ assertXPath(pXmlDoc, "//p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/dgm:relIds");
+ assertXPath(pXmlDoc, "//p:sld/p:cSld/p:spTree/p:graphicFrame/p:nvGraphicFramePr/p:nvPr/p:extLst/p:ext",
+ "uri", "{D42A27DB-BD31-4B8C-83A1-F6EECF244321}");
+ assertXPath(pXmlDoc, "//p:sld/p:cSld/p:spTree/p:graphicFrame/p:nvGraphicFramePr/p:nvPr/p:extLst/p:ext/p14:modId");
+
+ xmlDocPtr pXmlDocRels = parseExport(tempFile, "ppt/slides/_rels/slide1.xml.rels");
+ assertXPath(pXmlDocRels,
+ "(/rels:Relationships/rels:Relationship[@Target='../diagrams/layout1.xml'])[1]", "Type",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout");
+ assertXPath(pXmlDocRels,
+ "(/rels:Relationships/rels:Relationship[@Target='../diagrams/data1.xml'])[1]", "Type",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData");
+ assertXPath(pXmlDocRels,
+ "(/rels:Relationships/rels:Relationship[@Target='../diagrams/colors1.xml'])[1]", "Type",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors");
+ assertXPath(pXmlDocRels,
+ "(/rels:Relationships/rels:Relationship[@Target='../diagrams/quickStyle1.xml'])[1]", "Type",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle");
+
+ xmlDocPtr pXmlContentType = parseExport(tempFile, "[Content_Types].xml");
+ assertXPath(pXmlContentType,
+ "/ContentType:Types/ContentType:Override[@PartName='/ppt/diagrams/layout1.xml']",
+ "ContentType", "application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml");
+ assertXPath(pXmlContentType,
+ "/ContentType:Types/ContentType:Override[@PartName='/ppt/diagrams/data1.xml']",
+ "ContentType", "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml");
+ assertXPath(pXmlContentType,
+ "/ContentType:Types/ContentType:Override[@PartName='/ppt/diagrams/colors1.xml']",
+ "ContentType", "application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml");
+ assertXPath(pXmlContentType,
+ "/ContentType:Types/ContentType:Override[@PartName='/ppt/diagrams/quickStyle1.xml']",
+ "ContentType", "application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml");
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx
index 5791c0249b24..02b96def092f 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -50,6 +50,8 @@ enum PlaceholderType
Subtitle
};
+class PowerPointShapeExport;
+
class PowerPointExport final : public XmlFilterBase, public PPTWriterBase
{
friend class PowerPointShapeExport;
@@ -115,6 +117,8 @@ private:
virtual OUString SAL_CALL getImplementationName() override;
+ static void WriteDiagram(const FSHelperPtr& pFS, PowerPointShapeExport& rDML, const css::uno::Reference<css::drawing::XShape>& rXShape, int nDiagramId);
+
/// Should we export as .pptm, ie. do we contain macros?
bool mbPptm;
@@ -131,6 +135,8 @@ private:
sal_uInt32 mnSlideMasterIdMax;
sal_uInt32 mnAnimationNodeIdMax;
+ sal_uInt32 mnDiagramId;
+
bool mbCreateNotes;
::oox::drawingml::ShapeExport::ShapeHashMap maShapeMap;
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 0ac1ca406f06..cdc452b7c31d 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
, mnSlideIdMax(1 << 8)
, mnSlideMasterIdMax(1U << 31)
, mnAnimationNodeIdMax(1)
+ , mnDiagramId(1)
, mbCreateNotes(false)
{
comphelper::SequenceAsHashMap aArgumentsMap(rArguments);
@@ -1434,7 +1435,10 @@ void PowerPointExport::WriteShapeTree(const FSHelperPtr& pFS, PageType ePageType
if (GetShapeByIndex(GetCurrentGroupIndex(), true))
{
SAL_INFO("sd.eppt", "mType: " << mType);
- aDML.WriteShape(mXShape);
+ if (DrawingML::IsDiagram(mXShape))
+ WriteDiagram(pFS, aDML, mXShape, mnDiagramId++);
+ else
+ aDML.WriteShape(mXShape);
}
}
@@ -2031,6 +2035,14 @@ OUString PowerPointExport::getImplementationName()
return OUString("com.sun.star.comp.Impress.oox.PowerPointExport");
}
+void PowerPointExport::WriteDiagram(const FSHelperPtr& pFS, PowerPointShapeExport& rDML, const css::uno::Reference<css::drawing::XShape>& rXShape, int nDiagramId)
+{
+ SAL_INFO("sd.eppt", "writing Diagram " + OUString::number(nDiagramId));
+ pFS->startElementNS(XML_p, XML_graphicFrame, FSEND);
+ rDML.WriteDiagram(rXShape, nDiagramId);
+ pFS->endElementNS(XML_p, XML_graphicFrame);
+}
+
// UNO component
extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
css_comp_Impress_oox_PowerPointExport(uno::XComponentContext* rxCtxt,