sw/qa/extras/ooxmlexport/data/position-and-rotation.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 11 +++++++++++ writerfilter/source/dmapper/GraphicImport.cxx | 14 ++++++++++++++ 3 files changed, 25 insertions(+)
New commits: commit 36ac7749523e0c6f40a77beac278bd9e7a667a9b Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Sep 24 17:53:38 2014 +0200 DOCX import: make sure rotation does not affect shape position Change-Id: I7916a24d63bb7c995267059e9bedbf1f08adc152 diff --git a/sw/qa/extras/ooxmlexport/data/position-and-rotation.docx b/sw/qa/extras/ooxmlexport/data/position-and-rotation.docx new file mode 100644 index 0000000..d883ad3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/position-and-rotation.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index d45db67..af4e9dd 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -272,6 +272,17 @@ DECLARE_OOXMLEXPORT_TEST(testChartDupe, "chart-dupe.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xEmbeddedObjects->getCount()); } +DECLARE_OOXMLEXPORT_TEST(testPositionAndRotation, "position-and-rotation.docx") +{ + // The document should look like: "This line is tricky, <image> because only 'This line is tricky,' is on the left." + // But the image was pushed down, so it did not break the line into two text portions. + uno::Reference<drawing::XShape> xShape = getShape(1); + // Should be 1559, was -5639 + CPPUNIT_ASSERT(xShape->getPosition().X > 1500); + // Should be 88, was 473 + CPPUNIT_ASSERT(xShape->getPosition().Y < 100); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index eb920bb..e2ad109 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -779,9 +779,23 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) if (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape") || xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape")) { + // You would expect that position and rotation are + // independent, but they are not. Till we are not + // there yet to handle all scaling, translation and + // rotation with a single transformation matrix, + // make sure there is no rotation set when we set + // the position. + sal_Int32 nRotation = 0; + xShapeProps->getPropertyValue("RotateAngle") >>= nRotation; + if (nRotation) + xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(sal_Int32(0))); + // Position of the groupshape should be set after children have been added. // fdo#80555: also set position for graphic shapes here m_xShape->setPosition(awt::Point(m_pImpl->nLeftPosition, m_pImpl->nTopPosition)); + + if (nRotation) + xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(nRotation)); } m_pImpl->applyRelativePosition(xShapeProps); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits