drawingML import: fix position of cildren in shape groups
Translate component of parent shapes' transformation have to be applied to children when there is no explicit child transformation. Note. Export also use this concept. Change-Id: I51bd3325fb53ee250402326ee361c8f07038ed07
This commit is contained in:
parent
94af3bc2a4
commit
c9b1fd6345
@ -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) << " "
|
||||
|
@ -45,6 +45,8 @@ ShapeGroupContext::ShapeGroupContext( ContextHandler2Helper& rParent, ShapePtr p
|
||||
, mpGroupShapePtr( pGroupShapePtr )
|
||||
, mpMasterShapePtr( pMasterShapePtr )
|
||||
{
|
||||
if( pMasterShapePtr )
|
||||
mpGroupShapePtr->setWps(pMasterShapePtr->getWps());
|
||||
}
|
||||
|
||||
ShapeGroupContext::~ShapeGroupContext()
|
||||
|
@ -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:
|
||||
|
BIN
sw/qa/extras/ooxmlexport/data/dml-groupshape-childposition.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/dml-groupshape-childposition.docx
Normal file
Binary file not shown.
@ -3300,6 +3300,25 @@ DECLARE_OOXMLEXPORT_TEST(testFloatingTablePosition, "floating-table-position.doc
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(8133), getProperty<sal_Int32>(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<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
|
||||
uno::Reference<drawing::XShape> 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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user