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:
@@ -348,10 +348,19 @@ void Shape::addChildren(
|
|||||||
aChildTransformation.scale(1/(maChSize.Width ? maChSize.Width : 1.0), 1/(maChSize.Height ? maChSize.Height : 1.0));
|
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
|
// 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
|
// it like that, and in that case Word ignores the parent transformation
|
||||||
// seems.
|
// (excluding translate component).
|
||||||
if (!mbWps || maChPosition.X || maChPosition.Y || maChSize.Width || maChSize.Height)
|
if (!mbWps || maChPosition.X || maChPosition.Y || maChSize.Width || maChSize.Height)
|
||||||
|
{
|
||||||
aChildTransformation *= aTransformation;
|
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"
|
SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "parent matrix:\n"
|
||||||
<< aChildTransformation.get(0, 0) << " "
|
<< aChildTransformation.get(0, 0) << " "
|
||||||
|
@@ -45,6 +45,8 @@ ShapeGroupContext::ShapeGroupContext( ContextHandler2Helper& rParent, ShapePtr p
|
|||||||
, mpGroupShapePtr( pGroupShapePtr )
|
, mpGroupShapePtr( pGroupShapePtr )
|
||||||
, mpMasterShapePtr( pMasterShapePtr )
|
, mpMasterShapePtr( pMasterShapePtr )
|
||||||
{
|
{
|
||||||
|
if( pMasterShapePtr )
|
||||||
|
mpGroupShapePtr->setWps(pMasterShapePtr->getWps());
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeGroupContext::~ShapeGroupContext()
|
ShapeGroupContext::~ShapeGroupContext()
|
||||||
|
@@ -60,9 +60,7 @@ oox::core::ContextHandlerRef WpgContext::onCreateContext(sal_Int32 nElementToken
|
|||||||
break;
|
break;
|
||||||
case XML_grpSp:
|
case XML_grpSp:
|
||||||
{
|
{
|
||||||
oox::drawingml::ShapePtr pShape(new oox::drawingml::Shape("com.sun.star.drawing.GroupShape"));
|
return new oox::drawingml::ShapeGroupContext(*this, mpShape, oox::drawingml::ShapePtr(new oox::drawingml::Shape("com.sun.star.drawing.GroupShape")));
|
||||||
pShape->setWps(true);
|
|
||||||
return new oox::drawingml::ShapeGroupContext(*this, mpShape, pShape);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
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"));
|
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
|
#endif
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
Reference in New Issue
Block a user