Repository navigation
fix(docx): hold an auto column's editor slack in its cells' margins - #944
Merged
Merged
Conversation
- A table column sized to its content gives its text a point of slack so an editor's face keeps the page's line breaks. It widened the column, moving every rule and fill right of it, and the table's right end, a point right of the page's. It now comes out of the column's text cells' margins, on the side their text does not lean on, and the column keeps the page's width. - A cell spanning more than one such column shares its margin among them. A composed cell keeps its margins; what a column's cells do not hold widens it and is named (right end). - An indented table is indented by the margin its first cell keeps, which both editors measure the indent to. - Measured on Windows: Word stood the rules right of the auto column 0.94 to 1.06pt right of the page's, now within 0.12pt; LibreOffice 0.66 to 1.06pt, now with the tables' other rules. No line breaks change in either editor. - Tests: margins by alignment, direction, span, header and thin padding, a composed cell widening its column with the note, an indented table's tblInd; cell padding tests expect the right margin less the slack.
DemchaAV
marked this pull request as draft
October 22, 2026 20:22
…slack - A side of a text cell gives an auto column's slack only past the inner half of the cell's rule, as wide as Word draws it: taken further, a line an editor's face sets wider would run onto the rule. What it cannot give widens the column, named (right end). - Re-render the Word export example's DOCX preview: its quarterly table's three auto columns are a point narrower each, the point in their cells' right margins. - Tests: a 1pt padding beside a 1pt rule gives half a point; a cell spanning two rows gives the point in the merge's covered position; the thin-padding tests are unruled.
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 table column sized to its content (
DocumentTableColumn.auto()) is exactly as wide as its widest unwrapped cell. An editor setting that cell in its own face can wrap it, so the export gives each auto column's text a point of slack (withEditorSlack). The slack widened the column. Every rule and fill right of it, the text of the columns after it, and the table's right end stood a point right of the page's. The report did not say so.Measured against the page on Windows:
What changed
slackTheMarginsHold,givingTheSlack):leanOf, the cell's anchor read with its direction). Its text keeps the room the slack gave it, so the line breaks are the same. The column keeps the page's width.measureAtWordsSize). With the margin taken, it would run past the cell's edge, where Word cuts it off.ruleTwips). Taken further, a line an editor's face sets wider would run onto the rule: a cell padded 1pt beside a 1pt rule gives half a point.right endnote (applyTableWidth): a table whose auto columns are widened by a tenth of a point or more, in all, is named. Its right end, and what stands right of them, is up to that much further right. It is named whether or not the table paints there, since the text of the columns after a widened one moves with it. In the corpus, these are Orange Ops's aside headings: one-column tables with no padding, a composed heading over a filled accent rule. Word draws their rules 0.98 to 1.05pt longer than the page.applyTableWidthreturns what each column's cells' margins hold, and the row loop writes each cell's padding less its share.indentTable) is indented by its first cell's written left margin, as before, now less what that cell gives. Word and LibreOffice measure the indent to that cell's text. Measured in a section padded 20pt, with the first auto column set right, centred and left: the left rule stood 0.06pt right of the page's in Word and on it in LibreOffice, in all three.assets/readme/examples/word-export-companion.docxis re-rendered.WordExportExample's quarterly table has three auto columns. Its grid and its cells' right margins are a point narrower each, and nothing else in the document changes.DocumentTableColumn.type,DocumentTableColumn.Type.AUTOandTableNode.columnsname the margins and theright endnote;DocumentTableStyle.paddingsays a text cell's padding in an auto column is written less the slack.Verification
DocxEditorSlackTest(+12 table tests, two rewritten):w:tblIndis the inset and the margin its set-right first cell keeps.DocxCellPaddingTest:SLACK). Their vertical margins are unchanged.CommittedAssetDriftTest(examples) passes with the re-rendered DOCX, and failed without it.right end../mvnw -B -ntp clean verify -pl <core, render-pdf, render-docx, render-pptx, templates, testing, qa, coverage> -am→ BUILD SUCCESS: core 821, render-pdf 339, render-docx 2062, testing 5, render-pptx 142, templates 127, qa 1828. The JDK 17 knowledge checks pass, and core javadoc has 0 warnings../mvnw -f examples/pom.xml test→ BUILD SUCCESS, 93 tests.Lane: shared-engine (render-docx): no public API change.