Kaydet (Commit) d220e476 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#120551 DOCX import: fix position of group shape with absolute position

Regression from commit af313fc1
(tdf#105143 DOCX import: enable DoNotCaptureDrawObjsOnPage layout compat
option, 2017-01-06), the group shape which covers most of the single
page in the document had a negative left position, while it should have
a small positive one (checking the drawingML markup).

This was a pre-existing problem, but now it's visible since we no longer
force objects to be on the page in Word compat mode.

Seeing the ODT import never positions group shapes (it's just a
container for child shapes), probably the DOCX import shouldn't do that
either. Start moving into this direction, first only for
absolute-positioned toplevel group shapes only, which already fixes the
bug.

Change-Id: I152ba06a81a2bd09195a4c724da4b8878b0457bb
Reviewed-on: https://gerrit.libreoffice.org/63606
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst 0c627e49
...@@ -92,6 +92,14 @@ DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx") ...@@ -92,6 +92,14 @@ DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx")
getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontNameAsian")); 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") DECLARE_OOXMLIMPORT_TEST(testTdf111550, "tdf111550.docx")
{ {
// The test document has following ill-formed structure: // The test document has following ill-formed structure:
......
...@@ -66,11 +66,27 @@ ...@@ -66,11 +66,27 @@
#include "WrapPolygonHandler.hxx" #include "WrapPolygonHandler.hxx"
#include "util.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 writerfilter {
namespace dmapper namespace dmapper
{ {
using namespace css;
class XInputStreamHelper : public cppu::WeakImplHelper<io::XInputStream> class XInputStreamHelper : public cppu::WeakImplHelper<io::XInputStream>
{ {
...@@ -800,8 +816,15 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) ...@@ -800,8 +816,15 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(sal_Int32(0))); xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(sal_Int32(0)));
// Position of the groupshape should be set after children have been added. // 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 // 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) if (nRotation)
xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(nRotation)); xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(nRotation));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment