Repository navigation
fix(docx): keep the space above a spacer opening a stack of one layer - #930
Merged
Merged
Conversation
A spacer the layout moves to a new page holds the space above it in its line, but only outside every stack. A stack of one layer opening with a spacer, moved to a new page, lost the space above its text: measured in Word and LibreOffice, a stack with a 14pt margin and an 8pt spacer before its text stood 22.9pt high, the spacer written at the foot of the page above. The spacer's line now holds that space there, less its layer's offset, which is named, and the spacer is kept with what follows it in the stack, which the layout moves whole.
DemchaAV
marked this pull request as draft
October 20, 2026 14:21
A spacer opening a stack of one layer inside another was kept only with what follows it in the inner stack. The layout moves the outer stack whole, so a spacer closing the inner one was not kept with the outer stack's text after it, on the same page. It is now kept with anything that follows it up to the outermost stack of one layer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A spacer the layout moves to a new page holds the space the layout leaves above it in its own
line (
writeSpacer→holdTheGapAboveInTheLine), since Word drops a paragraph's space above atthe top of a page. That was gated on
overlayDepth == 0, outside every stack. #929 held a stackof one layer's first paragraph or picture, but not its first spacer.
Measured in Word 16 and LibreOffice on Windows: a stack with a 14pt margin, its layer a section
of an 8pt spacer and a paragraph, moved whole to page 2.
Before, the space above the text was gone: the stack's margin and the spacer's height, 22.9pt
in all. Nothing was named. With the spacer's line holding 14pt alone, Word set that line at the
foot of page 1 and the text at page 2's top as before. The layout moves the stack, an atomic
node, whole, but Word breaks between its paragraphs.
What changed
writeSpacerholds the gap above in its line whereoverlayDepth == oneLayerDepth, astack of one layer's included, as fix(docx): keep the space above a stack of one layer opening a page #929 does for a paragraph and a picture. A band is left as
it was.
holdTheGapAboveInTheLinetakes off the layer's offset in its stack, which is named andnot written (
layerOffsetNotWritten, 0 in the flow).(
w:keepNext), via a newfollowedInItsStack.layer. Examples: a spacer closing a section that the layer's text follows, or one closing a
stack inside the stack. The layout moves the outermost stack whole.
Verification
are identical.
word-export-companion.docxwas regenerated. It differs from the committed one onlyin
docProps/core.xml, the export's time.DocxStackOfOneLayerOnANewPageTest, 6 new tests:DocxSpaceAboveOnANewPageTest: a flow spacer opening a page is still not kept with whatfollows.
./mvnw -B -ntp clean verify: BUILD SUCCESS.javadoc passes with no warnings.
What this leaves, each recorded as a separate step:
page 100.2, Word and LibreOffice 85.3). A band in the flow does the same, so it goes with the
band step.
and the first block. Word can still split a stack whose start fits at the foot of the page
above, as it could before. Not measured.
Lane: render-docx (semantic backend). DOCX output changes only for a spacer opening a stack
of one layer that the layout moves to a new page.