diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-03 16:49:14 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-03 17:22:00 +0100 |
commit | eb2b7d243dc75578c76b8e5801a63b9a93389bb7 (patch) | |
tree | 72704e80979a55c7f1ee239dc0fb01e31ab6c2c1 | |
parent | f2945255df273404ee2457dcf761cb8f334b732b (diff) |
oox: fix handling of noop parent transformation from DOCX
It seems that in Word, a zero parent transformation, like:
<a:chOff x="0" y="0"/>
<a:chExt cx="0" cy="0"/>
means the child shapes will have an absolute position / size. We
actually use this feature in the exporter, but so far the importer
didn't handle this.
Change-Id: I250784a3dddd23649e391b548fc128dfdf153614
-rw-r--r-- | oox/source/drawingml/shape.cxx | 21 | ||||
-rw-r--r-- | oox/source/shape/WpgContext.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/relorientation.docx | bin | 22602 -> 22931 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 8 |
4 files changed, 23 insertions, 8 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 46dedecf6682..b42e27e579c9 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -345,17 +345,22 @@ void Shape::addChildren( aChildTransformation.translate(-maChPosition.X, -maChPosition.Y); aChildTransformation.scale(1/(maChSize.Width ? maChSize.Width : 1.0), 1/(maChSize.Height ? maChSize.Height : 1.0)); - aChildTransformation *= aTransformation; + + // 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. + if (!mbWps || maChPosition.X || maChPosition.Y || maChSize.Width || maChSize.Height) + aChildTransformation *= aTransformation; SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "parent matrix:\n" - << aChildTransformation.get(0, 0) - << aChildTransformation.get(0, 1) + << aChildTransformation.get(0, 0) << " " + << aChildTransformation.get(0, 1) << " " << aChildTransformation.get(0, 2) << "\n" - << aChildTransformation.get(1, 0) - << aChildTransformation.get(1, 1) - << aChildTransformation.get(1, 2) - << aChildTransformation.get(2, 0) - << aChildTransformation.get(2, 1) + << aChildTransformation.get(1, 0) << " " + << aChildTransformation.get(1, 1) << " " + << aChildTransformation.get(1, 2) << "\n" + << aChildTransformation.get(2, 0) << " " + << aChildTransformation.get(2, 1) << " " << aChildTransformation.get(2, 2)); std::vector< ShapePtr >::iterator aIter( rMaster.maChildren.begin() ); diff --git a/oox/source/shape/WpgContext.cxx b/oox/source/shape/WpgContext.cxx index d66b51864eb8..8e6c8ea429b3 100644 --- a/oox/source/shape/WpgContext.cxx +++ b/oox/source/shape/WpgContext.cxx @@ -22,6 +22,7 @@ WpgContext::WpgContext(ContextHandler2Helper& rParent) : ContextHandler2(rParent) { mpShape.reset(new oox::drawingml::Shape("com.sun.star.drawing.GroupShape")); + mpShape->setWps(true); } WpgContext::~WpgContext() @@ -56,6 +57,7 @@ oox::core::ContextHandlerRef WpgContext::onCreateContext(sal_Int32 nElementToken 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); } break; diff --git a/sw/qa/extras/ooxmlexport/data/relorientation.docx b/sw/qa/extras/ooxmlexport/data/relorientation.docx Binary files differindex d71148b11d46..22a04538bd69 100644 --- a/sw/qa/extras/ooxmlexport/data/relorientation.docx +++ b/sw/qa/extras/ooxmlexport/data/relorientation.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 23a8e6fe4784..aab75ab7e106 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2175,6 +2175,14 @@ DECLARE_OOXMLEXPORT_TEST(testRelorientation, "relorientation.docx") // This resulted in lang::IndexOutOfBoundsException, as nested groupshapes weren't handled. uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroup->getByIndex(0), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), xShapeDescriptor->getShapeType()); + + // Right after import we get a rounding error: 8662 vs 8664. + if (m_bExported) + { + uno::Reference<drawing::XShape> xYear(xGroup->getByIndex(1), uno::UNO_QUERY); + // This was 2, due to incorrect handling of parent transformations inside DML groupshapes. + CPPUNIT_ASSERT_EQUAL(sal_Int32(8664), xYear->getSize().Width); + } } DECLARE_OOXMLEXPORT_TEST(testBezier, "bezier.odt") |