Repository navigation
fix(docx): hold the space above a list, a line pair and a band's table on a new page - #935
Merged
Merged
Conversation
…e on a new page Word drops the space above a paragraph at the top of a page. A paragraph, a picture and a spacer the layout moves to a new page already hold theirs in a line kept with them; a list, a title and its dates set as one line, and a table, a row or a panel opening a band did not. Measured in Word and LibreOffice, a list with a 14pt margin stood 14pt high, one padded 10pt or opening a section padded 10pt stood 10pt high, and so did one opening a stack of one layer or a band with a 14pt margin, and such a line pair. A row, a table or a panel opening a band with a 14pt margin stood 14pt high: the band's margin was left at the foot of the page above. A list and a line pair now hold their top edge as a paragraph does, in the flow, in a stack of one layer and first in a band opening its page, and a list's wrapped first item takes the gap between its lines out of that line. A pair whose text starts above its overlay's top is left as it was. A table, a row or a panel opening such a band carries the band's own top edge down and holds it with its own, as one in the flow holds the edges of the containers opening with it. The page above keeps what the block before the band owes below itself, and only that. Each now stands within 0.1pt of the same block, or a paragraph, moved to a new page in the flow.
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
Word drops the space above a paragraph at the top of a page. A paragraph, a picture and a spacer
the layout moves to a new page already hold that space in an exact line kept with them
(
holdAParagraphsTopEdgeOnItsPage,holdTheGapAboveInTheLine). Three kinds of block did not.Measured in Word 16 and LibreOffice on Windows, against the PDF. Word and LibreOffice set every line
on these pages 0.9pt above the PDF, so a block is measured against that:
DocxLinePair) in a stack with a 14pt margin stood14pt high, in the flow and opening a band.
the band had a 14pt margin.
leaveThePageAbovewrote the band's whole resumed space, its marginincluded, as the space below the last line of the page above.
What changed
writeList: a list that opens its page in the flow (opensItsPageInTheFlow, the same test aparagraph uses) holds its top edge through
holdTheTopEdgeAboveItsLine. That method wraps theparagraph hold for a block that writes its own edge above its first line. It returns how much of
that edge the line took, and the list no longer owes that part above its first item. A margin
below zero is still owed, as a paragraph's is.
applyItemLineGap: a list's wrapped first item takes the gap between its lines out of the lineholding the list's edge (
listEdgeLine), as a paragraph does throughtopEdgeLineOver. Left inthe item's lines, a first item with a 4pt gap stood 2.2pt low. It now stands where a paragraph
moved the same way does.
writeLinePair: a pair that opens its page in the flow holds its edge the same way. The holdcovers the overlay's margin and the room above the line inside it (
pair.above()). A pair whosetext the page sets above its overlay's top has no such room to hold, and is left as it was.
leaveThePageAboveTheBand, used bywriteTableWithItsOwnSpacingandwritePanelfor aband's first block where the band opens its page:
bandGapBefore,recorded where the band measures its space), as for such a block moved in the flow;
holdTheSpaceAboveOnItsPageholds it with the block's own. The edge is the space the pageleaves above the block's own margin there (
spaceAboveOnItsPage).The block writes those itself, so that part of the resume is not owed again.
holdAParagraphsTopEdgeOnItsPagenow returns whether it wrote a line, for the new wrapper.Nothing else changes for its existing callers.
Verification
Probe, 23 cases, each moved to a new page, in Word and LibreOffice. The base was measured from
a separate checkout of
2.5-dev. Every number below is the editor's distance from the PDF; theparagraph control stands at −0.9 in both.
The controls (a paragraph, a row, a table and a panel in the flow, a row and a table in a stack of
one layer, a painted row) are byte-identical to the base. The page above a panel opening a band
ended with 20pt below its last line, the band's margin and the panel's own padding; it now ends
with none, as nothing above the band owed any.
Corpus: all 62 DOCX byte-identical to
2.5-dev, and the 1246 notes unchanged.Tests:
DocxBlockOpeningAPageTest(new, 19 tests):table, a row with its own padding, and a panel with its own margin;
drops it:
DocxListItemLowerTestnow assert that the line holds it, and that the first item isstill not lowered;
DocxBandRaiseTestandDocxLinePairRaiseTestnow assert the line holds it, andthat the first line is still not raised.
and the guard against raising into it is still tested.
15 sabotages, all caught, each by a test that names it:
list's edge owed twice;
carried down; the band flag not checked after a backdrop; the whole resume, or nothing, left on
the page above; no panel hold;
Gate:
./mvnw -B -ntp clean verifyon the reactor: BUILD SUCCESS (render-docx 1943, qa 1828),plus the JDK 17 knowledge checks and core Javadoc.
Known, not changed here
drops at a page top. The hold would cover the overlay's margin, not the space above the text.
and on the branch, with nothing named. The panel itself now stands where it should.
columns, a rule, a barcode, a contents line, a chart's fallback. None of these was measured.
Lane: shared-engine (render-docx semantic backend): DOCX export only, no public API change.