Repository navigation
fix(docx): indent a paragraph's lines by its bulletOffset, as the page sets them - #818
Merged
Merged
Conversation
…he page sets them
…letOffset, and take the Linux 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
A paragraph's
bulletOffsetis text the page sets before its first line, its wrapped lines or both, asindentStrategysays. It is not part of the paragraph's text, and the DOCX export did not write it at all.EditorialProposal's bullets are a dot, three spaces and the text, withbulletOffset(" ")andFROM_SECOND_LINE, so the page sets each wrapped line after a prefix of three spaces in the paragraph's style, under the text. In Word those lines started under the dot, 11.6pt left of the page's: "mobile" at 292.9pt where the page has 304.5, "project" at 388.8 where it has 400.3.What changed
indentAsThePrefixDoes. A prefix of spaces is only a distance, so it is written as one. It is measured in the paragraph's style, not its runs', with the fonts the layout measured with (styleWidth); that is the style the page draws the prefix in.FROM_SECOND_LINE: left indent and an equal hanging indent.FIRST_LINE: first-line indent.ALL_LINES: left indent.w:left, which is the start of the flow in either direction and the side a hanging indent is measured from.ParagraphWrapping.computeIndentFromPrefix).spacesCoveringcounts them the same way, so the wrapped lines get that indent. The letters are text the export does not write, so the first line is not moved for them.styleMetrics(). The measured-font metrics, built on first use, are now shared bystyleLineHeightandstyleWidth.word-windowsandlibreoffice-windowsare rewritten forEditorialProposal, the one document whose numbers this moves.libreoffice-linuxis rewritten from this PR's CI run (docx-fidelity-37013712496). It also takes in the lines fix(docx): keep a row's fixed columns at their widths when they leave the rest of the row empty #817 moved on Linux, which that baseline did not carry:PaymentsInvoicefinds 104 of 104 where it found 100, and its median drift falls from 14.34pt to 0.32pt.CHANGELOG.md, the Paragraphs row ofdocs/recipes/docx-export.md, and the paragraph row ofdocs/architecture/backend-capability-matrix.md.Verification
Template corpus, re-measured in full against
2.5-dev's baselines. Both gates pass, and no other document's numbers change in either editor.EditorialProposalEditorialProposalWrapped lines in Word now start where the page starts them: "mobile" at 304.49 against 304.5, and "project" at 400.39 against 400.31.
NorthlineProposal's wrapped bullets move as well. In Word they start at 387.91 against the page's 387.81. Its line breaks already matched the page, and the gate measures where lines break and how far they drift down, not their x, so its numbers do not change.The two newly found lines break where the page breaks them now. They are "transfers to Astera Health Co. after" and "full payment is received.", and both stand about 4pt low in Word. That is drift the terms list already had, growing down the list: "50%" is 1.1pt low and "major" 2.7pt.
NorthlineProposal's list drifts the same way. "Final files and handoff delivered upon" is still not found, because Word breaks its first line before "upon"; that line has no prefix, and the miss is older than this change.New test class,
DocxGeneratedIndentTest, ten tests. Three Helvetica spaces at 10pt are 167 twips."-"prefix withFROM_SECOND_LINEorALL_LINESgives left 167 and hanging 167:"- "is 2.2 spaces, so three. The layout's wrapped line starts with exactly three spaces.FIRST_LINEa"-"prefix writes no indent, and neither doesNONE.Each rule fails the tests when taken out.
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 804 tests, qa 1814.Known limits
bulletOffsetare still not written, and a first line is not moved for them.Lane: shared-engine (render-docx). No public API change.