sw/qa/extras/ooxmlexport/data/tdf170119_bottomSpacing.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 8 +++++ sw/source/writerfilter/dmapper/PropertyMap.cxx | 19 +++++++++++++ 3 files changed, 27 insertions(+)
New commits: commit 36b72f093986aff323a527d6e7989f4d3c2e9f6e Author: Justin Luth <[email protected]> AuthorDate: Wed Dec 24 17:13:44 2025 -0500 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Jan 5 14:49:07 2026 +0100 tdf#170119 writerfilter: cont-sectPr w/ pgbrk == emulate bottomSpacing Technically this is a 25.2.6 regression from my commit 74c29345a7c179b048c157582a1145e381616e5c tdf#167657 writerfilter: only move sectPr bottomMargin after pageBreak Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188298 It was just lucky before that it worked for that particular instance, and it only worked since 25.2.4... make CppunitTest_sw_ooxmlexport25 \ CPPUNIT_TEST_NAME=testTdf170119_bottomSpacing Change-Id: I9d0ae90087d79887489357eaa00eeabe53bcb58c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196205 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196440 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/data/tdf170119_bottomSpacing.docx b/sw/qa/extras/ooxmlexport/data/tdf170119_bottomSpacing.docx new file mode 100644 index 000000000000..74e9de4f5272 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf170119_bottomSpacing.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx index dd23fb1419af..684429610dda 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -73,6 +73,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf170003_bottomSpacing, "tdf170003_bottomSpacing.d getProperty<sal_Int32>(getParagraph(1), u"ParaBottomMargin"_ustr)); } +DECLARE_OOXMLEXPORT_TEST(testTdf170119_bottomSpacing, "tdf170119_bottomSpacing.docx") +{ + // Given a document with a page break and a sectPr with a huge bottom spacing + + // Without the fix, page 2 started with a 150pt gap, pushing content to the third page. + CPPUNIT_ASSERT_EQUAL(2, getPages()); +} + DECLARE_OOXMLEXPORT_TEST(testTdf167657_sectPr_bottomSpacing, "tdf167657_sectPr_bottomSpacing.docx") { // given with a continuous break sectPr with no belowSpacing diff --git a/sw/source/writerfilter/dmapper/PropertyMap.cxx b/sw/source/writerfilter/dmapper/PropertyMap.cxx index 0bfb0bffe411..6af004c1887e 100644 --- a/sw/source/writerfilter/dmapper/PropertyMap.cxx +++ b/sw/source/writerfilter/dmapper/PropertyMap.cxx @@ -1560,6 +1560,22 @@ void SectionPropertyMap::EmulateSectPrBelowSpacing(DomainMapper_Impl& rDM_Impl) // to the last paragraph in that section. // This emulation works because below spacing before a page break normally has no relevance. + if (m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_continuous) + { + // The complication with continuous breaks is that the below spacing of a sectPr + // does NOT directly affect the layout. + // [So (except before a page break) it MUST NOT be applied to the previous para.] + // However, it IS (indirectly) used to reduce the top margin of the following paragraph. + uno::Reference<beans::XPropertySet> const xPSet(m_xStartingRange, uno::UNO_QUERY); + if (!xPSet) + return; // TODO tdf#170119: emulation not possible without a page break + + style::BreakType eBreakType(style::BreakType_NONE); + xPSet->getPropertyValue(u"BreakType"_ustr) >>= eBreakType; + if (eBreakType != style::BreakType_PAGE_BEFORE) + return; // emulation not possible without a page break. + } + // m_xPreStartingRange may have skipped over a table as the last thing before the break! // If so, then the below spacing can be ignored since tables don't have below spacing. // Also, if m_xStartingRange starts with a table (which also doesn't have above spacing) @@ -1690,6 +1706,9 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) setHeaderFooterProperties(rDM_Impl); InheritOrFinalizePageStyles( rDM_Impl ); ApplySectionProperties( xSection, rDM_Impl ); //depends on InheritOrFinalizePageStyles + + EmulateSectPrBelowSpacing(rDM_Impl); + uno::Reference< beans::XPropertySet > xRangeProperties( lcl_GetRangeProperties( m_bIsFirstSection, rDM_Impl, m_xStartingRange ) ); if ( m_bIsFirstSection && !m_sPageStyleName.isEmpty() && xRangeProperties.is() ) {
