diff options
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf120551.docx | bin | 0 -> 31758 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 27 |
3 files changed, 33 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf120551.docx b/sw/qa/extras/ooxmlimport/data/tdf120551.docx Binary files differnew file mode 100644 index 000000000000..0fc0057c4e03 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf120551.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 743ed626fe8b..8466180c7903 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -92,6 +92,14 @@ DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx") getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontNameAsian")); } +DECLARE_OOXMLIMPORT_TEST(test120551, "tdf120551.docx") +{ + auto nHoriOrientPosition = getProperty<sal_Int32>(getShape(1), "HoriOrientPosition"); + // Without the accompanying fix in place, this test would have failed with + // 'Expected: 436, Actual : -2542'. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(436), nHoriOrientPosition); +} + DECLARE_OOXMLIMPORT_TEST(testTdf111550, "tdf111550.docx") { // The test document has following ill-formed structure: diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 1e070a3e2a2c..9f188d88b499 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -66,11 +66,27 @@ #include "WrapPolygonHandler.hxx" #include "util.hxx" +using namespace css; + +namespace +{ +bool isTopGroupObj(const uno::Reference<drawing::XShape>& xShape) +{ + SdrObject* pObject = GetSdrObjectFromXShape(xShape); + if (!pObject) + return false; + + if (pObject->getParentSdrObjectFromSdrObject()) + return false; + + return pObject->IsGroupObject(); +} +} + namespace writerfilter { namespace dmapper { -using namespace css; class XInputStreamHelper : public cppu::WeakImplHelper<io::XInputStream> { @@ -800,8 +816,15 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(sal_Int32(0))); // Position of the groupshape should be set after children have been added. + // Long-term we should get rid of positioning group + // shapes, though. Do it for top-level ones with + // absolute page position as a start. // fdo#80555: also set position for graphic shapes here - m_xShape->setPosition(awt::Point(m_pImpl->nLeftPosition, m_pImpl->nTopPosition)); + if (!isTopGroupObj(m_xShape) + || m_pImpl->nHoriRelation != text::RelOrientation::PAGE_FRAME + || m_pImpl->nVertRelation != text::RelOrientation::PAGE_FRAME) + m_xShape->setPosition( + awt::Point(m_pImpl->nLeftPosition, m_pImpl->nTopPosition)); if (nRotation) xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(nRotation)); |