Repository navigation
fix(docx): keep a stack of one layer on the page the layout puts it on - #931
Merged
Merged
Conversation
The layout moves a layer stack to a new page whole, but its one layer is written in the flow as plain paragraphs, and Word was told nothing. Measured in Word and LibreOffice, a stack of three lines that the page moved to the next page stood with two of them at the foot of the page above; so did one opening with a spacer or with a margin. A stack of one layer in the flow is now kept on its page as a block kept together is, through keepOnOnePage. The spacer's own keep added for a stack opening a page is gone with it, as the stack's keep holds every paragraph but its last to the next.
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 layer stack is atomic in the layout, so a page break moves it whole. A stack of one layer is
written in the flow as plain paragraphs, and nothing told Word to keep them together. Word broke
between them, which left part of a stack the page sets on the next page at the foot of the page
above.
Measured in Word 16 and LibreOffice on Windows: a stack whose layer is a section of three lines,
"Opening", "Body" and "Tail", that the page moves to page 2 (baselines; p = page).
Nothing was named. A stack that stays on its page stood where the page sets it before, and still
does.
What changed
writePlacedNodekeeps a stack of one layer in the flow on its page as it keeps a blockthat asks for
keepTogether(): throughkeepOnOnePage, when the layout put it on one page.it is chained row by row.
followedInItsStackfor a spacer opening sucha stack on a new page. The stack's keep now holds every paragraph but its last to the next, so
the separate keep is gone. The spacer's line still holds the space above it.
Verification
Corpus, 62 DOCX before and after: all 62 are byte-identical, and the report's 1246 notes
are identical. A corpus document with a stack of one layer in the flow would have gained its
keeps, so none of the 62 has one.
Example:
word-export-companion.docxwas regenerated. It differs from the committed one onlyin
docProps/core.xml, the export's time.fix(docx): keep the space above a spacer opening a stack of one layer #930's spacer cases, measured again on this code in both editors: the text stands at 107.0
where the page sets it at 108.2, as before.
DocxKeepTogetherTest, 5 new tests:The fix(docx): keep the space above a spacer opening a stack of one layer #930 spacer tests in
DocxStackOfOneLayerOnANewPageTestpass through the stack's keep.4 sabotages, all caught:
./mvnw -B -ntp clean verify: BUILD SUCCESS.do the knowledge checks.
What this leaves, each recorded as a separate step:
and the stack there is not kept. Whether Word holds a cell's paragraph keeps in a row that may
break is not measured.
own step.
Lane: render-docx (semantic backend). DOCX output changes only for a stack of one layer in
the flow, outside any cell.