Repository navigation
fix(docx): seat a list's items where the page sets them, as a paragraph's - #883
Merged
Merged
Conversation
…ph's - A list item's exact lines were never seated: Word stands the baseline four fifths of the way down, the page its face's ascent down, and an item's text stood where Word put it. seatTheItem runs it through the paragraph's seat: a line set low rises into the gap above it as far as the gap goes and owes as much below, the item under it rising into that; under half a point, one opening a cell takes the rest from the cell's padding or the space above its row of columns; what is left of half a point and more is the text's position. - Not raised into the gap: an item the layout opens a page with, the first of a list it starts on a new page or one on a later page than the item before it, and an item of a list in a cell broken over a page. ItemText carries the page it was set on. - An item whose marker Word draws keeps no position: LibreOffice does not move a Word list's marker by the mark's position, and the text would stand off its bullet there. - shiftToThePagesBaseline takes the lines and their gap, and raiseIntoTheSpaceAbove whether the line stays on its page, so a paragraph and an item share one seat. - Baselines: Word and LibreOffice on Windows rewritten from the corpus; the Word export companion re-rendered. - Tests: DocxListItemSeatTest; DocxVerticalSpacingTest's list counts its items' raise.
…hange's CI run - The Linux baseline was last written for the composed chip's label seat. The text cells beside composed ones, the first lines of cells and now the list items have moved lines since, each inside the gate's half point, so it held them to their old places. - Taken from the DOCX Fidelity artifact of this change's CI run. Against the run before it, 3 documents moved nearer by median, none further; 76 lines nearer, none further; 52 of 62 still pass.
… and say so - A list's item in a cell is raised into the space above it where its list is on one page; whether its row is kept whole adds nothing, as a row of columns never crosses a page and a list in a table's composed cell lays out no lines to seat it by. - Javadoc and docs: the items not raised into the space above still take a position where they take one; the list, not its cell, is what the layout sets over two pages; what is left goes to the position where the whole difference is half a point or more. - Tests: a list in a composed cell is held to having no exact line, an item of runs to being tabbed to its text's column.
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 paragraph's exact line is seated on the page's baseline. Word and LibreOffice stand it four fifths of the way down the line, the page at the face's ascent, and the export moves the line up into the space above it, or by its position. A list item's line got none of that:
writeListLineandwriteRichListLinenever called the seat, so every item stood where Word put it.By the export's own measure of Word's seat, 68 items of the corpus stood low by under half a point (median 0.22pt) and 16 high by half a point and more. Measured, they stood about where it put them.
BoxedSections' skills, 0.18pt low by it, stood 0.23–0.28pt low in Word and LibreOffice.MidnightNavy's two-line duties, 0.9pt high by it, stood 0.76–1.06pt high.What changed
seatTheItemseats an item through the paragraph's seat, from the lines the layout set it on (ItemText) and the list's line gap:ItemTextnow carries the page the item was set on.w:position.MidnightNavy's bullet stood at y=248.20 in LibreOffice and its text at 249.35. In Word both stood at 249.14 (PDF glyphs).MidnightNavy's andNavySidebar's duties, set high, stand as before.shiftToThePagesBaselinenow takes the lines and their gap, andraiseIntoTheSpaceAbovetakes whether the line stays on its page instead of the node. The paragraph overload computes both exactly as before, so a paragraph's own seat is unchanged. A paragraph after a raised item now takes back what the item owes above it, as it does after a raised paragraph.SlateOrange's certifications are an example: a list in a table's composed cell. They are written without a line height at all, which is a separate defect.Corpus
Word and LibreOffice on Windows measured against the committed baselines; LibreOffice 24.2 is this PR's CI run against the previous head's:
How far the items moved:
ClassicInvoiceBoxedSections,ModernProfessionalExecutiveThe Word and LibreOffice-on-Windows baselines are rewritten from this measurement, and change only in the eight documents that moved. The Linux LibreOffice baseline is rewritten from this PR's CI artifact (a commit of its own), which also takes in the lines the two seats before this one moved inside the gate's half point; 52 of 62 documents still pass. The report's notes are unchanged: 969, byte-identical.
assets/readme/examples/word-export-companion.docxis re-rendered: its lists move.Verification
./mvnw -B -ntp clean verify→ BUILD SUCCESS.DocxListItemSeatTest(new, 13 tests), raising into the space above:DocxListItemSeatTest, position:DocxListItemSeatTest, not raised:DocxVerticalSpacingTest: the list's items now count their raise.Lane: shared-engine — DOCX semantic backend (
render-docx), no public API change.