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 9c7539af6810b51b3be8c738e702622658cf1d23 Author: László Németh <[email protected]> AuthorDate: Tue Feb 25 02:43:06 2025 +0100 Commit: Adolfo Jayme Barrientos <[email protected]> CommitDate: Wed Feb 26 13:24:20 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 <[email protected]> (cherry picked from commit 33e54802ee31d4c76e7e41b714f5bfeed484bbd2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182172 Reviewed-by: Adolfo Jayme Barrientos <[email protected]> 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 f749d188694d..8bed38e930a4 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 9f7b2b0219b3..c5982ec10090 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -2802,6 +2802,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; }
