Repository navigation
fix(docx): keep a table's and a row's own margins - #831
Merged
Merged
Conversation
…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
The DOCX export dropped a table's and a row's own margins.
indentTablewritesw:tblIndfrominsetLeftalone, and nothing added the table's or the row's ownmargin.leftto it. Every table or row with a left margin started that far left in Word:PaymentsInvoice's bank details stood 36.7pt left of the page's.VioletGridsets each education entry in a table held 51.3pt clear of a badge drawn beside it, and 2.3pt down. A table opening a band's layer never took the band's resumed space, sonewTable's ownresumeHere()later overwrote the 2.3pt the table owed. At the top of a cell nothing held that space either. In Word the lines started under the badge and stood 2.4pt high.What changed
The changes are in
DocxSemanticBackend.writeTableWithItsOwnSpacing, except the last one:margin.left/margin.righttoinsetLeft/insetRightwhile it is written, restored in afinallyblock, soindentTablecarries the margin intow:tblInd.leftMarginInCell). The column already starts past that margin, which is also whywriteParagraphandwriteListskip it.TableNodewritten while a band's or a column layer'sresumeSpacingis pending takes it first (resumeHere()), then owes its own top margin.holdTheSpaceAboveATable), as it already was for a row.RowNodedoes not take the resume: the band measures it to the first block inside the row, and the row's cells write what stands above that block. Letting rows take it moved the whole ofPaymentsInvoice10pt down.ObsidianInvoice's line items 6pt.nestedTableWidth()is the cell's width less what the table is now held in by. It was the whole cell, so a nested table indented by its margin, sized from it or given the editor's slack in it, ran that margin past the cell's right edge.docs/recipes/docx-export.mdand the CHANGELOG state both rules.Verification
scripts/docx-visual/word-fidelity.ps1(Word 16.0.20430) → BUILD SUCCESS, with the baseline rewritten by-Update.VioletGrid's three education lines moved vertically: −2.47 / −2.43 / −2.44pt → −0.07 / −0.03 / −0.04pt. Its lines more than 2pt off fall from 5 to 2.PaymentsInvoicebank details (theCardFieldsrow, left marginpx(65)= 36.7pt): 29 words moved, all of them nearer the PDF (−36.7pt → +0.1pt).VioletGrideducation lines (BADGE_COLUMN= 51.3pt): 19 words moved, all nearer (−51.4pt → +0.3pt at most).PlatformInvoicefooter (theFooterIdentityrow, left marginpx(1)= 0.56pt): 13 words moved, all 0.6pt nearer.-Dgraphcompose.docxFidelity=libreofficefailed only on the same threeVioletGridlines, now +2.4pt further: 19.08 → 21.48pt. LibreOffice already sets that CV on two pages, about 19pt off, so the right 2.4pt adds to an older offset. I rewrote the baseline withupdate=true. The Linux baseline is this PR's CI artifactdocx-fidelity-37139222719, which moved the same three lines and nothing else.DocxTableMarginsTest, 7 tests:w:tblInd;RowNodeplaces as a column is not indented twice (RowBuilderrefuses a table, the node API does not);resumedcondition from widening.resumeHere()call fails both band tests, dropping the hold for a resumed table fails 1 (and widening it to every table fails the no-hairline test), dropping the column guard fails 1, and the oldnestedTableWidth()fails the width test../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.CommittedAssetDriftTestinexamples→ 3/3 green, so no committed preview moved.Known limits
indentTable, while a row in the same place hangs throughwriteRow.Lane: shared-engine (render-docx) — DOCX export geometry only. No public API change.