sw/qa/extras/odfimport/odfimport.cxx | 3 +++ sw/source/core/doc/docnew.cxx | 3 +++ 2 files changed, 6 insertions(+)
New commits: commit 5025a70cae87a46df210408f86da082aecd2a354 Author: Michael Stahl <[email protected]> Date: Fri Nov 3 21:48:37 2017 +0100 sw: ODF import: prevent shapes from inheriting paragraph default margins The problem is that even with the vertical-pos default fix, we don't render ShapesWithWrapping.odt the same as Word does: https://beta.opendocumentformat.org/rendercompare/upload/223/86/191/1 The shape still has a spurious bottom margin, which should not exist. This has a surprising cause: the default-style family="paragraph" has the attribute fo:margin-bottom="0.1388in" on paragraph-properties, which gets imported as the pool's default item of RES_UL_SPACE; there is nothing that prevents the shape from using this pool default item if it doesn't have a margin set on itself. Prevent that by overriding the pool default in SwDoc::mpDfltFrameFormat, which already carries a XFillStyleItem for similar reasons. The mpDfltFrameFormat is used by a lot more than just shapes, but none of that stuff should inherit paragraph defaults. As an aside the fo:margin-* properties are also allowed on style:graphic-properties, but it turns out that the implementation of the default-style family="graphic", in SvxUnoDrawPool/SwSvxUnoDrawPool, does not have the corresponding properties, hence cannot import these. Not sure if it would be better to have multiple SvxULSpace items with different IDs, so the paragraphs and shapes and etc. can have separate defaults. Change-Id: Ie6a196db567beb7a48b4176f383c88490dcfb8e7 (cherry picked from commit 2e39e519767d58a20829baca2fb0a2418b70f772) Reviewed-on: https://gerrit.libreoffice.org/44287 Tested-by: Jenkins <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index f51e22b6db11..f502531f8485 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -799,6 +799,9 @@ DECLARE_ODFIMPORT_TEST(testWordAsCharShape, "Word2010AsCharShape.odt") uno::Reference<drawing::XShape> const xShape(getShape(1)); CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, getProperty<text::TextContentAnchorType>(xShape, "AnchorType")); CPPUNIT_ASSERT_EQUAL(text::VertOrientation::TOP, getProperty<sal_Int16>(xShape, "VertOrient")); + // also, the paragraph default fo:bottom-margin was wrongly applied to + // the shape + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xShape, "BottomMargin")); } DECLARE_ODFIMPORT_TEST(testTdf100033_2, "tdf100033_2.odt") diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 3d7b813fe964..f69b35dac309 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -283,6 +283,9 @@ SwDoc::SwDoc() // it is possible to set this attribute here. It will be not reset when importing. mpDfltTextFormatColl->SetFormatAttr(XFillStyleItem(drawing::FillStyle_NONE)); mpDfltFrameFormat->SetFormatAttr(XFillStyleItem(drawing::FillStyle_NONE)); + // prevent paragraph default margins being applied to everything + mpDfltFrameFormat->SetFormatAttr(SvxULSpaceItem(RES_UL_SPACE)); + mpDfltFrameFormat->SetFormatAttr(SvxLRSpaceItem(RES_LR_SPACE)); /* * DefaultFormats and DefaultFormatCollections (FormatColl) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
