summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-02-03 11:44:21 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-02-03 12:36:08 +0100
commite034fa4607dfc732eaa82261755193fd781a2aad (patch)
tree50d0a747ff0a96c7640c2a6c7fbed217a059fc6e
parentdd6bb0aba7c3dbe5d7d337cbcca2fd343e04402f (diff)
DOCX import: make sure rotation is not changed when we alter size
Change-Id: I5dd344fe06a0b700cebccfece44b622d00adfb5f
-rw-r--r--sw/qa/extras/ooxmlimport/data/line-rotation.docxbin0 -> 14772 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx10
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx13
3 files changed, 22 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/line-rotation.docx b/sw/qa/extras/ooxmlimport/data/line-rotation.docx
new file mode 100644
index 000000000000..a2450c0c11b8
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/line-rotation.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 8af52d678796..6bfe06a08735 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1567,7 +1567,15 @@ DECLARE_OOXMLIMPORT_TEST(lineWpsOnly, "line-wps-only.docx")
{
uno::Reference<drawing::XShape> xShape = getShape(1);
// Check position, it was -7223 as it was set after the CustomShapeGeometry property.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(210), xShape->getPosition().X);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(208), xShape->getPosition().X);
+}
+
+DECLARE_OOXMLIMPORT_TEST(lineRotation, "line-rotation.docx")
+{
+ uno::Reference<drawing::XShape> xShape = getShape(3);
+ // This was 5096: the line was shifted towards the bottom, so the end of
+ // the 3 different lines wasn't at the same point.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4808), xShape->getPosition().Y);
}
DECLARE_OOXMLIMPORT_TEST(textboxWpsOnly, "textbox-wps-only.docx")
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index e615ddf9107a..41d9c7b366d1 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -671,11 +671,19 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
(text::TextContentAnchorType_AS_CHARACTER));
uno::Reference<lang::XServiceInfo> xServiceInfo(m_xShape, uno::UNO_QUERY_THROW);
+
+ // TextFrames can't be rotated. But for anything else,
+ // make sure that setting size doesn't affect rotation,
+ // that would not match Word's definition of rotation.
+ bool bKeepRotation = false;
if (!xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
+ {
+ bKeepRotation = true;
xShapeProps->setPropertyValue
(rPropNameSupplier.GetName(PROP_TEXT_RANGE),
uno::makeAny
(m_pImpl->rDomainMapper.GetCurrentTextRange()));
+ }
awt::Size aSize(m_xShape->getSize());
@@ -684,7 +692,12 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
if (m_pImpl->isYSizeValis())
aSize.Height = m_pImpl->getYSize();
+ uno::Any aRotation;
+ if (bKeepRotation)
+ aRotation = xShapeProps->getPropertyValue("RotateAngle");
m_xShape->setSize(aSize);
+ if (bKeepRotation)
+ xShapeProps->setPropertyValue("RotateAngle", aRotation);
m_pImpl->bIsGraphic = true;
}