Bug 170119 - DOCX LAYOUT: top margin after continuous-section break should be "reduced" by the sectPr's bottom margin
Summary: DOCX LAYOUT: top margin after continuous-section break should be "reduced" by...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bisected, filter:docx
Depends on:
Blocks: DOCX-Paragraph
  Show dependency treegraph
 
Reported: 2025-12-24 19:24 UTC by Justin L
Modified: 2025-12-28 12:43 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
170119_continuousSectionNoGap.docx: 1 page document (12.96 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-12-24 19:28 UTC, Justin L
Details
170119_continuousSectionNoGap_word2024.pdf: how it looks in MS Word (43.41 KB, application/pdf)
2025-12-24 19:32 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2025-12-24 19:24:26 UTC
There are two (related) parts to this bug.

First, something that has never worked is the general case that a continuous section break's below spacing should be used to consolidate the top margin of the following paragraph.

This is rather complicated, because the sectPr paragraph doesn't actually exist in Writer, and even in MS Word, the above and below spacing doesn't directly affect the layout. (For example, if a continuous sectPr has below spacing of 100pt, it wouldn't produce a large gap.)
HOWEVER, if the following paragraph had a 100pt top margin, then the sectPr's below spacing would "swallow up" the top margin, and there would still not be any gap in the layout.

Currently in Writer we have no way of swallowing up that gap, so we show it.

Secondly however, as in bug 166510, this can be emulated IF the continuous section is connected with a page break. This was working from 25.2.4 - 25.2.6.
It broke in 25.2.6 with commit 74c29345a7c179b048c157582a1145e381616e5c
Author: Justin Luth on Mon Jul 28 09:29:51 2025 +0200
    tdf#167657 writerfilter: only move sectPr bottomMargin after pageBreak
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188298
Comment 1 Justin L 2025-12-24 19:28:39 UTC
Created attachment 204796 [details]
170119_continuousSectionNoGap.docx: 1 page document

This document is an example of the generic situation. The sectPr has belowSpacing of 200pt. However, that doesn't produce a gap.

The paragraph before the section break has a 200pt above spacing. LibreOffice is showing that gap (by pushing the content to page 2).
Comment 2 Justin L 2025-12-24 19:32:19 UTC
Created attachment 204797 [details]
170119_continuousSectionNoGap_word2024.pdf: how it looks in MS Word
Comment 3 Regina Henschel 2025-12-24 21:14:36 UTC
Please have a look at bug 107497, bug 84248 and bug 124637. Has this bug a underlying problem that is common with them?
Comment 4 Justin L 2025-12-24 21:26:32 UTC
(In reply to Regina Henschel from comment #3)
> Please have a look at bug 107497, bug 84248 and bug 124637. Has this bug a
> underlying problem that is common with them?

No, it doesn't seem to be related to any of these. (This is an MSO-only issue)
Comment 5 Commit Notification 2025-12-25 02:38:47 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/582c032aaa4524abf5b5a630400cf7ecdc2acf8a

tdf#170119 writerfilter: cont-sectPr w/ pgbrk == emulate bottomSpacing

It will be available in 26.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Justin L 2025-12-25 02:41:53 UTC
Comment 5's patch depends on bu 170003. It does NOT fix the first, general case, but it does resolve the 'regression' when there is an accompanying general page break.
Comment 7 Commit Notification 2025-12-28 00:56:06 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

https://git.libreoffice.org/core/commit/ed5aaa03906807c93fe6847f66f847007777174d

tdf#170119 writerfilter: cont-sectPr w/ pgbrk == emulate bottomSpacing

It will be available in 26.2.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.