diff options
author | Jan Holesovsky <kendy@collabora.com> | 2017-08-31 18:32:58 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-09-07 10:18:20 +0200 |
commit | 7b65e7eea560da718c3cbc76a049a8d60b2809e9 (patch) | |
tree | a2a6d5f09fce606a5d32107bf7861a448f8f1d5c /oox | |
parent | 4e80c53e20845e0ffcdbd890bd0c3730c15dff42 (diff) |
tdf#111884: Implement export of group shapes in pptx.
Contains also:
tdf#111884: Unit test.
related tdf#111884: GroupShapes are now handled in oox.
Change-Id: If12984c0670db6396cbfd0dcb8ae1f5a9b591705
Reviewed-on: https://gerrit.libreoffice.org/41766
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/41997
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/drawingml.cxx | 18 | ||||
-rw-r--r-- | oox/source/export/shapes.cxx | 55 |
2 files changed, 52 insertions, 21 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index c8d148aeb1c2..bb90a48eb96d 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1142,8 +1142,8 @@ void DrawingML::WriteStretch( const css::uno::Reference< css::beans::XPropertySe mpFS->endElementNS( XML_a, XML_stretch ); } -void DrawingML::WriteTransformation( const Rectangle& rRect, - sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, sal_Int32 nRotation ) +void DrawingML::WriteTransformation(const Rectangle& rRect, + sal_Int32 nXmlNamespace, bool bFlipH, bool bFlipV, sal_Int32 nRotation, bool bIsGroupShape) { mpFS->startElementNS( nXmlNamespace, XML_xfrm, XML_flipH, bFlipH ? "1" : nullptr, @@ -1162,6 +1162,12 @@ void DrawingML::WriteTransformation( const 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 ); } @@ -1173,7 +1179,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; @@ -1202,7 +1208,11 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa if (xPropertySetInfo->hasPropertyByName("RotateAngle")) xPropertySet->getPropertyValue("RotateAngle") >>= nRotation; } - WriteTransformation( 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( 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 1d4f4a20a217..3391ae3d1ec1 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -494,13 +494,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); @@ -516,17 +535,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; } @@ -1373,7 +1395,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; @@ -1389,12 +1411,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; @@ -1408,8 +1431,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; @@ -1419,8 +1440,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 ); |