Bug 167657 - FILEOPEN DOCX: Don't copy continuous section break bottom spacing to previous paragraph
Summary: FILEOPEN DOCX: Don't copy continuous section break bottom spacing to previous...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
25.2.4.3 release
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:26.2.0 target:25.8.1 target:25...
Keywords: bisected, regression
Depends on:
Blocks: DOCX-Paragraph
  Show dependency treegraph
 
Reported: 2025-07-23 20:41 UTC by Justin L
Modified: 2025-07-29 06:49 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
sectPr_belowSpacing_simple.docx: example document with a continuous section break (17.99 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-07-23 20:41 UTC, Justin L
Details
sectPr_belowSpacing.docx: a more complex example (18.01 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-07-23 20:56 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-07-23 20:41:19 UTC
Created attachment 201966 [details]
sectPr_belowSpacing_simple.docx: example document with a continuous section break

The problem is that the bottom spacing is lost after a continuous section break.

It started with 25.8 commit 5ff1fd13f1879105ecc0541c55f30cea32ae54f4
Author: Justin Luth on Fri May 16 11:43:06 2025 -0400
    tdf#166510 writerfilter: move empty sectPr bottom margin to prev para
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185424
which was backported to 25.2.4.

For section-PAGE breaks, the bottom spacing isn't seen since it is the last content on the page, so it doesn't hurt to clear the bottom spacing. But for section-CONTINUOUS breaks, the bottom spacing of the previous paragraph ALWAYS applies. In fact, it does NOT consolidate with the top spacing of the following paragraph. The top spacing consolidates with the CONTINUOUS break, but there is no layout implication of the CONTINUOUS break's bottom (or top) spacing by itself.

The problem is that at the sectPr talks about the section that has JUST FINISHED. So we can only know about how that section STARTED. (Things are confusing because MS Word labels that point as "continuous" or "next page", but that is not referring to THIS sectPr that just finished, but the next one - which we won't learn about until much, much later.)

So, we either need to do some extreme hackery and keep a pointer to this and process it much later when the section ends (to see if it is a real page break or not), or else we need to adjust the next paragraph's bottom margin to achieve the desired result. Both options are rather desperate... (remember, these are layout-time considerations that need to have roundtrip-able results).

Steps to reproduce:
-open sectPr_belowSpacing_simple.docx

As the document itself tells you, the second paragraph should be vertically centered.
Comment 1 Justin L 2025-07-23 20:56:22 UTC
Created attachment 201967 [details]
sectPr_belowSpacing.docx: a more complex example

The first example seems fairly straight forward to the normal human, who would wonder why it could have gotten messed up.

This one starts to show why.

Once again the first paragraph has 55pt below spacing that applies to the layout.

The second (continuous-sectPr pseudo-paragraph) has 160pt of below spacing, but that doesn't directly affect the layout in any way.

The third paragraph has 165pt of top spacing. That consolidates with the 2nd paragraph, so only 5pt of top spacing is added, making the total space between the two visible paragraphs to be 60pt.

So historically, LO has never handled this specific file properly, because it has lost this continuous-sectPr spacing that eats up most of that top margin.
Comment 2 Commit Notification 2025-07-24 18:31:39 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/74c29345a7c179b048c157582a1145e381616e5c

tdf#167657 writerfilter: only move sectPr bottomMargin after pageBreak

It will be available in 26.2.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 3 Justin L 2025-07-24 22:05:58 UTC
Oh yeah. Found by Collabora's mso-test.
Comment 4 Commit Notification 2025-07-28 07:30:51 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

https://git.libreoffice.org/core/commit/1326e09d019f05a82265f15c26288b4ffb7dc0c2

tdf#167657 writerfilter: only move sectPr bottomMargin after pageBreak

It will be available in 25.8.1.

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 5 Commit Notification 2025-07-29 06:49:27 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-25-2":

https://git.libreoffice.org/core/commit/71c924f6b2ce62cc67a4917ec9fd7ef7d492297d

tdf#167657 writerfilter: only move sectPr bottomMargin after pageBreak

It will be available in 25.2.6.

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.