summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-08-31 18:32:58 +0200
committerJan Holesovsky <kendy@collabora.com>2017-09-01 14:30:19 +0200
commite06ef6f42e47780b26f6f3424bb2053e0490d8e3 (patch)
tree42d9d18ebee7713f5e01e9b3129ac5893dc71ec3 /oox
parent029f2fdc2a164ca5ab2ecb9e2d4b9cf5112083b4 (diff)
tdf#111884: Implement export of group shapes in pptx.
Change-Id: If12984c0670db6396cbfd0dcb8ae1f5a9b591705 Reviewed-on: https://gerrit.libreoffice.org/41766 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx18
-rw-r--r--oox/source/export/shapes.cxx55
2 files changed, 52 insertions, 21 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 3d5a7ace8262..3e66a504aa14 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1154,8 +1154,8 @@ void DrawingML::WriteStretch( const css::uno::Reference< css::beans::XPropertySe
mpFS->endElementNS( XML_a, XML_stretch );
}
-void DrawingML::WriteTransformation( const tools::Rectangle& rRect,
- sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, sal_Int32 nRotation )
+void DrawingML::WriteTransformation(const tools::Rectangle& rRect,
+ sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, sal_Int32 nRotation, bool bIsGroupShape)
{
mpFS->startElementNS( nXmlNamespace, XML_xfrm,
@@ -1175,6 +1175,12 @@ void DrawingML::WriteTransformation( const tools::Rectangle& rRect,
mpFS->singleElementNS( XML_a, XML_off, XML_x, IS( oox::drawingml::convertHmmToEmu( nLeft ) ), XML_y, IS( oox::drawingml::convertHmmToEmu( nTop ) ), FSEND );
mpFS->singleElementNS( XML_a, XML_ext, XML_cx, IS( oox::drawingml::convertHmmToEmu( rRect.GetWidth() ) ), XML_cy, IS( oox::drawingml::convertHmmToEmu( rRect.GetHeight() ) ), FSEND );
+ if (GetDocumentType() != DOCUMENT_DOCX && bIsGroupShape)
+ {
+ mpFS->singleElementNS(XML_a, XML_chOff, XML_x, IS(oox::drawingml::convertHmmToEmu(nLeft)), XML_y, IS(oox::drawingml::convertHmmToEmu(nTop)), FSEND);
+ mpFS->singleElementNS(XML_a, XML_chExt, XML_cx, IS(oox::drawingml::convertHmmToEmu(rRect.GetWidth())), XML_cy, IS(oox::drawingml::convertHmmToEmu(rRect.GetHeight())), FSEND);
+ }
+
mpFS->endElementNS( nXmlNamespace, XML_xfrm );
}
@@ -1186,7 +1192,7 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
awt::Point aPos = rXShape->getPosition();
awt::Size aSize = rXShape->getSize();
- if (m_xParent.is())
+ if (GetDocumentType() == DOCUMENT_DOCX && m_xParent.is())
{
awt::Point aParentPos = m_xParent->getPosition();
aPos.X -= aParentPos.X;
@@ -1223,7 +1229,11 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
if(bSuppressFlipping)
bFlipH = bFlipV = false;
- WriteTransformation( tools::Rectangle( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) ), nXmlNamespace, bFlipH, bFlipV, OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(nRotation) );
+ uno::Reference<lang::XServiceInfo> xServiceInfo(rXShape, uno::UNO_QUERY_THROW);
+ bool bIsGroupShape = (xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"));
+
+ WriteTransformation(tools::Rectangle(Point(aPos.X, aPos.Y), Size(aSize.Width, aSize.Height)), nXmlNamespace,
+ bFlipH, bFlipV, OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(nRotation), bIsGroupShape);
}
void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool bIsField, sal_Int32 nElement, bool bCheckDirect,
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index df34231a225b..60bd7d0a80cf 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -497,13 +497,32 @@ ShapeExport& ShapeExport::WriteOpenPolyPolygonShape( const Reference< XShape >&
ShapeExport& ShapeExport::WriteGroupShape(const uno::Reference<drawing::XShape>& xShape)
{
FSHelperPtr pFS = GetFS();
- bool bToplevel = !m_xParent.is();
- if (!bToplevel)
- mnXmlNamespace = XML_wpg;
- pFS->startElementNS(mnXmlNamespace, (bToplevel ? XML_wgp : XML_grpSp), FSEND);
+
+ sal_Int32 nGroupShapeToken = XML_grpSp;
+ if (GetDocumentType() == DOCUMENT_DOCX)
+ {
+ if (!m_xParent.is())
+ nGroupShapeToken = XML_wgp; // toplevel
+ else
+ mnXmlNamespace = XML_wpg;
+ }
+
+ pFS->startElementNS(mnXmlNamespace, nGroupShapeToken, FSEND);
// non visual properties
- pFS->singleElementNS(mnXmlNamespace, XML_cNvGrpSpPr, FSEND);
+ if (GetDocumentType() != DOCUMENT_DOCX)
+ {
+ pFS->startElementNS(mnXmlNamespace, XML_nvGrpSpPr, FSEND);
+ pFS->singleElementNS(mnXmlNamespace, XML_cNvPr,
+ XML_id, I32S(GetNewShapeID(xShape)),
+ XML_name, IDS(Group),
+ FSEND);
+ pFS->singleElementNS(mnXmlNamespace, XML_cNvGrpSpPr, FSEND);
+ WriteNonVisualProperties(xShape );
+ pFS->endElementNS(mnXmlNamespace, XML_nvGrpSpPr);
+ }
+ else
+ pFS->singleElementNS(mnXmlNamespace, XML_cNvGrpSpPr, FSEND);
// visual properties
pFS->startElementNS(mnXmlNamespace, XML_grpSpPr, FSEND);
@@ -519,17 +538,20 @@ ShapeExport& ShapeExport::WriteGroupShape(const uno::Reference<drawing::XShape>&
sal_Int32 nSavedNamespace = mnXmlNamespace;
uno::Reference<lang::XServiceInfo> xServiceInfo(xChild, uno::UNO_QUERY_THROW);
- if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
- mnXmlNamespace = XML_pic;
- else
- mnXmlNamespace = XML_wps;
+ if (GetDocumentType() == DOCUMENT_DOCX)
+ {
+ if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
+ mnXmlNamespace = XML_pic;
+ else
+ mnXmlNamespace = XML_wps;
+ }
WriteShape(xChild);
mnXmlNamespace = nSavedNamespace;
}
m_xParent = xParent;
- pFS->endElementNS(mnXmlNamespace, (bToplevel ? XML_wgp : XML_grpSp));
+ pFS->endElementNS(mnXmlNamespace, nGroupShapeToken);
return *this;
}
@@ -1371,7 +1393,7 @@ ShapeExport& ShapeExport::WriteRectangleShape( const Reference< XShape >& xShape
typedef ShapeExport& (ShapeExport::*ShapeConverter)( const Reference< XShape >& );
typedef std::unordered_map< const char*, ShapeConverter, rtl::CStringHash, rtl::CStringEqual> NameToConvertMapType;
-static const NameToConvertMapType& lcl_GetConverters(DocumentType eDocumentType)
+static const NameToConvertMapType& lcl_GetConverters()
{
static bool shape_map_inited = false;
static NameToConvertMapType shape_converters;
@@ -1387,12 +1409,13 @@ static const NameToConvertMapType& lcl_GetConverters(DocumentType eDocumentType)
shape_converters[ "com.sun.star.drawing.GraphicObjectShape" ] = &ShapeExport::WriteGraphicObjectShape;
shape_converters[ "com.sun.star.drawing.LineShape" ] = &ShapeExport::WriteLineShape;
shape_converters[ "com.sun.star.drawing.OpenBezierShape" ] = &ShapeExport::WriteOpenPolyPolygonShape;
- shape_converters[ "com.sun.star.drawing.PolyPolygonShape" ] = &ShapeExport::WriteClosedPolyPolygonShape;
- shape_converters[ "com.sun.star.drawing.PolyLineShape" ] = &ShapeExport::WriteClosedPolyPolygonShape;
+ shape_converters[ "com.sun.star.drawing.PolyPolygonShape" ] = &ShapeExport::WriteClosedPolyPolygonShape;
+ shape_converters[ "com.sun.star.drawing.PolyLineShape" ] = &ShapeExport::WriteClosedPolyPolygonShape;
shape_converters[ "com.sun.star.drawing.RectangleShape" ] = &ShapeExport::WriteRectangleShape;
shape_converters[ "com.sun.star.drawing.OLE2Shape" ] = &ShapeExport::WriteOLE2Shape;
shape_converters[ "com.sun.star.drawing.TableShape" ] = &ShapeExport::WriteTableShape;
shape_converters[ "com.sun.star.drawing.TextShape" ] = &ShapeExport::WriteTextShape;
+ shape_converters[ "com.sun.star.drawing.GroupShape" ] = &ShapeExport::WriteGroupShape;
shape_converters[ "com.sun.star.presentation.GraphicObjectShape" ] = &ShapeExport::WriteGraphicObjectShape;
shape_converters[ "com.sun.star.presentation.OLE2Shape" ] = &ShapeExport::WriteOLE2Shape;
@@ -1406,8 +1429,6 @@ static const NameToConvertMapType& lcl_GetConverters(DocumentType eDocumentType)
shape_converters[ "com.sun.star.presentation.OutlinerShape" ] = &ShapeExport::WriteTextShape;
shape_converters[ "com.sun.star.presentation.SlideNumberShape" ] = &ShapeExport::WriteTextShape;
shape_converters[ "com.sun.star.presentation.TitleTextShape" ] = &ShapeExport::WriteTextShape;
- if (eDocumentType == DOCUMENT_DOCX)
- shape_converters[ "com.sun.star.drawing.GroupShape" ] = &ShapeExport::WriteGroupShape;
shape_map_inited = true;
return shape_converters;
@@ -1417,8 +1438,8 @@ ShapeExport& ShapeExport::WriteShape( const Reference< XShape >& xShape )
{
OUString sShapeType = xShape->getShapeType();
SAL_INFO("oox.shape", "write shape: " << sShapeType);
- NameToConvertMapType::const_iterator aConverter = lcl_GetConverters(GetDocumentType()).find( USS( sShapeType ) );
- if( aConverter == lcl_GetConverters(GetDocumentType()).end() )
+ NameToConvertMapType::const_iterator aConverter = lcl_GetConverters().find(USS(sShapeType));
+ if (aConverter == lcl_GetConverters().end())
{
SAL_INFO("oox.shape", "unknown shape");
return WriteUnknownShape( xShape );