summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-09-24 17:53:38 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-09-24 18:02:42 +0200
commit36ac7749523e0c6f40a77beac278bd9e7a667a9b (patch)
treeffb71be02ed4ce516d40510e1daa1f799d36943d
parent2916dfdb2361e68a6bbbcb0b0e9e114e052cb6d5 (diff)
DOCX import: make sure rotation does not affect shape position
Change-Id: I7916a24d63bb7c995267059e9bedbf1f08adc152
-rw-r--r--sw/qa/extras/ooxmlexport/data/position-and-rotation.docxbin0 -> 18502 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx11
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx14
3 files changed, 25 insertions, 0 deletions
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 000000000000..d883ad32e75e
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/position-and-rotation.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index d45db672738e..af4e9dd304b4 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 eb920bb157f3..e2ad1093fea2 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);