fix(docx): give a table's rules out of its cells' padding where Word makes room for them - #790
Merged
Merged
Conversation
…makes room for them Word makes room in a table for its horizontal rules: a rule between two rows half in each, the rules above and below the table whole in their row. The page does not, so every ruled table grew row by row. A table that states no rule is written with the engine's default 1pt rule, as the page draws it.
… differently Measured, Word makes room at a shared edge for the lower row's rule: a 1.5pt header over 0.5pt rows steps as 0.5pt rules do. A cell's padding below now gives up half the rule of the row under it.
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
In Word, every ruled table ran taller than on the page, row by row.
EditorialProposal's timeline and investment tables pushed its investment block, with the acceptance under it, onto a third page.NorthlineProposal's acceptance heading stood 12pt below its badge, which is drawn where the page puts it.The page draws a cell's rules on its edges and steps its rows by padding and content alone. Word makes room for a table's horizontal rules. Measured through Word COM on a probe of 12.35pt text with 7pt padding:
So a rule between two rows takes half its width from each, and the rules above and below the table take their whole width from their row. Between two rows ruled differently, Word makes room for the lower row's rule: a 1.5pt header over 0.5pt rows stepped as 0.5pt rules do, and a 1.5pt row under 0.5pt ones as 1.5pt rules do.
A table that states no rule was left on Word's own grid. That grid is thinner than the engine's default 1pt black rule the page draws, and gives its rows other heights.
What changed
clearOfTheRules. A table cell's padding gives up, above and below, the room Word makes for the rules there. That is half the rule between two rows (the lower row's where the two differ), and the whole rule above the first row and below the last. In a table ruled alike throughout, with padding enough, every row then steps and stands as the page sets it. A padding thinner than its share gives what it has, and its row stands that much taller. The sides keep their padding, as the columns' widths are fixed.resolveCellStroke/ENGINE_DEFAULT_CELL_STROKE. A table that states no rule is written with the engine's default 1pt black rule, asresolveCellPaddingand the cell fill already fall back to the engine's defaults. This is a visible change for such tables: their rules in Word are now the page's weight.CHANGELOG.md, the tables row ofdocs/recipes/docx-export.mdand the table-rows row ofbackend-capability-matrix.mdare updated. The committedword-export-companion.docxpreview is re-rendered, as its table is ruled.Verification
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 (1791 + 127 tests). After install, examples are green (93 tests, with the refreshed preview), and the knowledge checks andextract-api --checkpass.DocxCellPaddingTest:TableCellLayoutStyle.DEFAULT.DocxComposedCellTest: the row-height hold subtracts the margins as now written.Template corpus (62 documents), converted to PDF by Word, baselines matched by text:
NorthlineProposalInvoiceClassiclongInvoiceModernlongEditorialProposalis 2 pages in Word again; it was 3. In LibreOffice the corpus median falls from 1.59pt to 0.55.InvoiceWorkspace's median rises from 3.8 to 4.8pt. Its table now stands level; its rows had been growing by as much as its bill-to block runs 10pt high, and that block is a separate defect.Word on screen: a capture of Word's window shows
NorthlineProposal's investment, terms and acceptance headings level with their badges, andEditorialProposalon two pages.Lane: shared-engine (render-docx). No public API change.