Repository navigation
fix(docx): write a chip's side padding as the room it takes on the page - #844
Merged
Merged
Conversation
…, and report each side as written
…tatus-chip # Conflicts: # CHANGELOG.md
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 chip's fill is written as run shading (
w:shd), and shading covers only the letters. So a chip's horizontal padding, which widens its run on the page, was not in the file.ModernReceipt's status chip is right-aligned, with 9pt of padding on each side. In Word it stood 9.16pt right of the page's position; it was the corpus's largest remaining across offset in Word.What changed
DocxSemanticBackendwrites the padding as character spacing (w:spacing), on the paragraph path and the list path alike.spaceAfterTheLastLetterputs the room after a run's last letter.rPr, so the letters before it keep their spacing.w:hyperlink(runAfter), so a linked phrase stays one link.BreakIterator), so an accent stays with its letter.roomAfterdecides how much room goes after a run's last letter:lastSpaceableLettersays where no space can be written:BreakIteratordoes not keep a flag or a joined emoji sequence whole.setTheLineAsWideAsThePagenow adds its letter spacing to what a run already carries instead of overwriting it. This changes nothing for other lines:twentiethsToThePagereturns 0 for tracked lines and lines with shapes, which are the only lines that already carry spacing.widthAtWordsSizeno longer scales a chip's padding to Word's half-point type size, because the padding is now written in points.chipLostsays, chip by chip, how each side was written. The left padding is unshaded space, space in the fill of the chip before it, or not in the file (leftPaddingAs). The right padding is reported where it is not written. The padding above and below the letters is reported as before. This replaces the old "its padding is not in the file". A chip's own text never holds a line break:InlineRun.textRunsturns one into a space.The Javadoc, the recipe's chip section, the capability matrix row and CHANGELOG are updated.
Verification
Word corpus.
scripts/docx-visual/word-fidelity.ps1 -Update(Word 16) → BUILD SUCCESS.ModernReceipt's status chip: +9.16 → +0.16pt across.LibreOffice (Windows). The same chip goes 9.21 → 9.26pt; no other row changes. LibreOffice sets no spacing after the last letter of a line, and this chip ends its line.
Mid-line chips. The corpus has no chip with side padding other than this one, so mid-line chips were measured on an ad-hoc right-aligned document of five lines, not committed. The chips there had 9pt padding:
The line ending in a chip stayed at 9.23pt in LibreOffice with the change.
LibreOffice (Linux). This PR's CI artifact matches the committed Linux baseline line for line, so that baseline is unchanged.
Tests:
DocxInlineBackgroundTest, 15 new tests.w:hyperlinkholding two runs.éstays whole.DocxRunStyleTestandDocxPanelEdgeCasesTestnow expect the chip's last letter in its own run.Sabotage. Each change fails a test:
render-docx. 909 tests green.
Full reactor gate.
./mvnw -B -ntp clean verify -pl :graph-compose-core,:graph-compose-render-pdf,:graph-compose-render-docx,:graph-compose-render-pptx,:graph-compose-templates,:graph-compose-testing,:graph-compose-qa,:graph-compose-coverage -am→ BUILD SUCCESS (qa 1820 tests).Examples.
CommittedAssetDriftTest→ 3/3 green.Notes
Lane: shared-engine (render-docx).