diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index fb17f5de4e93..b3020107a9ff 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -348,10 +348,19 @@ void Shape::addChildren( aChildTransformation.scale(1/(maChSize.Width ? maChSize.Width : 1.0), 1/(maChSize.Height ? maChSize.Height : 1.0)); // Child position and size is typically non-zero, but it's allowed to have - // it like that, and in that case Word ignores the parent transformation, it - // seems. + // it like that, and in that case Word ignores the parent transformation + // (excluding translate component). if (!mbWps || maChPosition.X || maChPosition.Y || maChSize.Width || maChSize.Height) + { aChildTransformation *= aTransformation; + } + else + { + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aTransformation.decompose(aScale, aTranslate, fRotate, fShearX); + aChildTransformation.translate(aTranslate.getX(), aTranslate.getY()); + } SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "parent matrix:\n" << aChildTransformation.get(0, 0) << " " diff --git a/oox/source/drawingml/shapegroupcontext.cxx b/oox/source/drawingml/shapegroupcontext.cxx index 10e419f7edf9..d5eb50379404 100644 --- a/oox/source/drawingml/shapegroupcontext.cxx +++ b/oox/source/drawingml/shapegroupcontext.cxx @@ -45,6 +45,8 @@ ShapeGroupContext::ShapeGroupContext( ContextHandler2Helper& rParent, ShapePtr p , mpGroupShapePtr( pGroupShapePtr ) , mpMasterShapePtr( pMasterShapePtr ) { + if( pMasterShapePtr ) + mpGroupShapePtr->setWps(pMasterShapePtr->getWps()); } ShapeGroupContext::~ShapeGroupContext() diff --git a/oox/source/shape/WpgContext.cxx b/oox/source/shape/WpgContext.cxx index 6e3161269971..254d72fc812b 100644 --- a/oox/source/shape/WpgContext.cxx +++ b/oox/source/shape/WpgContext.cxx @@ -60,9 +60,7 @@ oox::core::ContextHandlerRef WpgContext::onCreateContext(sal_Int32 nElementToken break; case XML_grpSp: { - oox::drawingml::ShapePtr pShape(new oox::drawingml::Shape("com.sun.star.drawing.GroupShape")); - pShape->setWps(true); - return new oox::drawingml::ShapeGroupContext(*this, mpShape, pShape); + return new oox::drawingml::ShapeGroupContext(*this, mpShape, oox::drawingml::ShapePtr(new oox::drawingml::Shape("com.sun.star.drawing.GroupShape"))); } break; default: diff --git a/sw/qa/extras/ooxmlexport/data/dml-groupshape-childposition.docx b/sw/qa/extras/ooxmlexport/data/dml-groupshape-childposition.docx new file mode 100644 index 000000000000..a5c6bf99a186 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/dml-groupshape-childposition.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 60e0f4f22014..a588ce0dee70 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3300,6 +3300,25 @@ DECLARE_OOXMLEXPORT_TEST(testFloatingTablePosition, "floating-table-position.doc CPPUNIT_ASSERT_EQUAL(sal_Int32(8133), getProperty(xFrame, "VertOrientPosition")); } +DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeChildPosition, "dml-groupshape-childposition.docx") +{ + // Problem was parent transformation was ingnored fully, but translate component + // which specify the position must be also applied for children of the group. + + uno::Reference xGroup(getShape(1), uno::UNO_QUERY); + uno::Reference xChildGroup(xGroup->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? -2119 : -2121), xChildGroup->getPosition().X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? 11338 : 11335), xChildGroup->getPosition().Y); + + xGroup.set(xChildGroup, uno::UNO_QUERY); + xChildGroup.set(xGroup->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? -1856 : -1858), xChildGroup->getPosition().X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? 11338 : 11335), xChildGroup->getPosition().Y); + + xChildGroup.set(xGroup->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? -2119 : -2121), xChildGroup->getPosition().X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? 14028 : 14025), xChildGroup->getPosition().Y); +} #endif CPPUNIT_PLUGIN_IMPLEMENT();