diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-11-03 21:48:37 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-11-03 22:50:26 +0100 |
commit | 2e39e519767d58a20829baca2fb0a2418b70f772 (patch) | |
tree | e0c0b5aacfac457b1ff29aaf90ecfec1aa85b736 /sw | |
parent | fdcd11ff68fcd9e46aad6efc20779a063f4f6182 (diff) |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/odfimport/odfimport.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 365c01c21949..032a4a5da574 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -798,6 +798,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 24ad79bd6210..2fae0c3597d4 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -294,6 +294,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) |