Repository navigation
fix(docx): count a spacer's hairline in its height - #826
Merged
Merged
Conversation
…inux LibreOffice baseline from CI
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
writeSpacerwrites aSpacerNodeas an empty paragraph held to an exact line of a tenth of a point (holdToHairline). That keeps Word from giving it a line of text. Then it owed the spacer's whole height as the space above the next block, so every spacer stood 0.1pt taller than the page's.Word keeps a line that short. In a hand-made document, eleven exact 12pt lines with a 2-twip empty paragraph between each pair are set 12.098pt apart on average in Word, against 12.002pt without the paragraphs. It is the same in the body and in a table cell, with or without an empty run in the paragraph.
EditorialBlueshows the effect most.separateFromTheTableAbovealready takes its 0.1pt out of the gap it stands in.What changed
writeSpacer. The spacer owes its height less its hairline (SEPARATOR_POINTS), floored at 0. The hang and pull reductions after it are unchanged.DocxContainerSpacingTest.aSpacerOverATableHoldsTheRestOfItsHeightBelowItsHairline: a 10pt spacer over a table writes 2 twips of line and 198 below it, the spacer's 200. Nothing between them takes the hairline out a second time.aSpacerUnderATableInACellIsTheTablesCloserAndItsHeightOnce: in a card's cell, the paragraph closing the table becomes the spacer's. Line and space come to 200 twips, with no separator.aSpacerIsItsHeightAndNotALineOfTextAsWellnow pins the line at exactly 2 twips.DocxContainerSpacingTest.aSpacerIsItsHeightAndNotALineOfTextAsWell: the hairline and the space above the next entry add up to the spacer's 4.5pt.DocxVerticalSpacingTest.aPullComesOutOfASpacerUnderIt.DocxSpaceAboveOnANewPageTest's filler spacer, through anowed(points)helper.word-windows,libreoffice-windowsand their-linesfiles are rewritten. 17 of the 62 documents move in Word (16 in LibreOffice), each line by a tenth of a point per spacer above it on its page: exact multiples of −0.1pt in LibreOffice, and steps of 0.12pt in Word.libreoffice-linuxand its-linesfile are taken from this PR's CI run (docx-fidelity-37112941286, on 855d2c3; the review commit changes only tests and a comment).EditorialBluehad already been at 0 lines past 2pt on Linux since fix(docx): keep the space above a paragraph or spacer the layout moves to a new page #825; its page 1 now moves too (p90 0.45 → 0.30pt).MinimalUnderlined's existing 13.4pt jump.CHANGELOG.md, the Spacers row ofdocs/recipes/docx-export.md, and the Javadoc ofholdsNothing. A spacer's paragraph carries an empty run, so it counts as content in a cell.Verification
Template corpus, re-measured in full in both editors.
EditorialBluepast 2ptPage counts are unchanged, and no line is lost.
EditorialBluenow has all 82 of its lines matched in both editors (81 before), because the heading is back on page 1.The biggest gains in Word are
EditorialBlue(mean |drift| 1.62 → 0.38pt),CenteredHeadline(0.34 → 0.13),ClassicSerif(0.31 → 0.16),InvoiceConsulting(1.00 → 0.85) andPanel(0.50 → 0.36).Documents that get worse in Word.
MinimalUnderlined: mean 0.56 → 0.65pt. It already stood high, by an offset that starts above its first spacer and that the extra tenth per spacer partly cancelled. Its entries now step as the page does.ProfessionalSidebar: mean 0.12 → 0.17pt.BoxedSectionsandExecutive: mean 0.29 → 0.30pt and 0.20 → 0.22pt. Both show the same pattern asMinimalUnderlined: the steps flatten over an offset of about 0.2pt high that is already there.Each test fails when the change is taken out. With the spacer's whole height owed again, the three
DocxContainerSpacingTestspacer tests andDocxVerticalSpacingTest.aPullComesOutOfASpacerUnderItfail.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 -amgives BUILD SUCCESS. render-docx runs 835 tests, qa 1814.Known limits
MinimalUnderlinedstarts with, andProfessionalSidebar's per-block deficit, are not found yet.MinimalUnderlined's summary already stands 0.57pt high. Both are next in the queue.Lane: shared-engine (render-docx). No public API change.