sw/qa/extras/layout/data/tdf164903.docx |binary sw/qa/extras/layout/layout5.cxx | 12 ++++++++++++ sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 13 +++++++++++++ 3 files changed, 25 insertions(+)
New commits: commit 33e54802ee31d4c76e7e41b714f5bfeed484bbd2 Author: László Németh <nem...@numbertext.org> AuthorDate: Tue Feb 25 02:43:06 2025 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Feb 25 14:19:06 2025 +0100 tdf#164903 sw inline heading: fix DOCX layout by zeroing top margin Skip top margin of the paragraph of the inline heading by direct paragraph formatting to fix DOCX layout interoperability. Regression from commit 56588663a0fddc005c12afaa7d3f8874d036875f "tdf#131728 sw inline heading: fix DOCX paragraph layout interoperability". Change-Id: I9fb485b08b4f3fd7506562e636151ccb6ee7b0a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182138 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/layout/data/tdf164903.docx b/sw/qa/extras/layout/data/tdf164903.docx new file mode 100644 index 000000000000..a7f7f4dac518 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf164903.docx differ diff --git a/sw/qa/extras/layout/layout5.cxx b/sw/qa/extras/layout/layout5.cxx index 85bf7e107aab..f1f7a60e1a98 100644 --- a/sw/qa/extras/layout/layout5.cxx +++ b/sw/qa/extras/layout/layout5.cxx @@ -1219,6 +1219,18 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf164932) assertXPath(pDump, "//SwLineLayout", 2); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf164903) +{ + // ignore top margin of inline heading, like MSO does + createSwDoc("tdf164903.docx"); + auto pDump = parseLayoutDump(); + auto nInlineHeadingHeight + = getXPath(pDump, "/root/page[1]/body/txt[6]/infos/bounds", "height").toInt32(); + // This was 493 (adding top margin to the height of the Inline Heading frame) + CPPUNIT_ASSERT_GREATER(sal_Int32(250), nInlineHeadingHeight); + CPPUNIT_ASSERT_LESS(sal_Int32(260), nInlineHeadingHeight); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf135991) { createSwDoc("tdf135991.odt"); diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 8e04f5b259ed..a57d02af3d7a 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -2831,6 +2831,19 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con // its default "anchored as character" setting xFrameProps->setPropertyValue(getPropertyName(PROP_ANCHOR_TYPE), uno::Any(text::TextContentAnchorType_AS_CHARACTER)); + // tdf#164903 empty top and bottom margins to emulate the behaviour of style separators + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xFrame, uno::UNO_QUERY); + if ( xParaEnumAccess.is() && !pParaContext->isSet(PROP_PARA_TOP_MARGIN) ) + { + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + if ( xParaEnum.is() ) + { + uno::Reference<beans::XPropertySet> xParaProps(xParaEnum->nextElement(), uno::UNO_QUERY); + if ( xParaProps.is() ) + xParaProps->setPropertyValue(u"ParaTopMargin"_ustr, uno::Any(sal_Int32(0))); + } + } + m_StreamStateStack.top().bIsInlineParagraph = false; m_StreamStateStack.top().bIsPreviousInlineParagraph = true; }