Repository navigation
fix(layout): keep the size of a picture or shape composed in a table cell - #928
Merged
Merged
Conversation
…cell A table cell gave the node composed in it the cell's inner width and the height it measured. In a 120pt column padded 4pt, the page drew a picture fitted to 100pt in a box 112pt wide, 112x56 for 100x50, a 20pt circle as an ellipse 112pt wide and a 60pt picture stretched to 112x60, while Word and LibreOffice drew the pictures at their own size. A node of a size of its own is now laid out at the width it measured, as the flow and a row slot lay one out, held to the cell's inner width where it measures wider. Text, which aligns in the width it is given, and a composite keep the cell's inner box. The DOCX export measures a composed shape's corners against its own width.
DemchaAV
marked this pull request as draft
October 20, 2026 07:18
…ipe lines The composed-cell paragraph added to docs/recipes/tables.md moved the lines its claims point at; the claims and proofs indexes follow them.
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 cell lays out the node composed in it (
DocumentTableCell.node) in a placement thatNodeDefinitionSupport.emitComposedCellFragmentsbuilds. Its width was the cell's inner widthand its height was what the node measured. Every drawn node fills the width it is given, so one
of a size of its own was stretched across the cell.
In a 120pt column padded 4pt (
fixed(120)), this is what the page drew:fitToBounds(100, 100)size(60, 60)circle(20)The DOCX export already wrote the pictures at their own size, so they stood where the page now
draws them. It drew the circle and the shape from the page's fragments, stretched as the page
was.
Elsewhere a leaf is laid out at the width it measured:
LayoutCompiler.compileAtomicLeaf,SplittableLeafCompilerand a row slot's leaf all use it. No layout test pinned the stretch.Two things leaned on it:
What changed
emitComposedCellFragments: a leaf of a size of its own is placed at the width itmeasured, held to the cell's inner width where it measures wider. It starts at the cell's
content edge as before, since the horizontal anchor is still not read. This covers a picture,
a shape, a circle, a barcode, a line, a path, a polygon and a nested table.
reference (
alignsInTheWidthItIsGiven). Text aligns in that width, and a page numbermeasures only as wide as its digits: set right, at its own width, it would leave the cell's
right edge.
DocxSemanticBackend.cornersDiffer: a composed shape's radii are now measured againstits own width, held to half its shorter side, rather than against an unbounded width.
laid out at the cell's width;
docs/recipes/tables.md(composed cells);docs/recipes/docx-export.md(corners).Verification
Corpus, 62 DOCX before and after: all 62 are byte-identical, and the report's 1246 notes
are identical. No corpus document composes a drawn node directly in a cell.
Reach, from a temporary trace, removed before commit, of every leaf the change gives a
narrower box, across the qa, templates and examples suites:
TimelineSplitSpikeTest, an 8pt circle drawn 16×8 before.No template and no example composes a picture or shape in a cell.
ComposedCellLeafWidthTest(new, qa, 8 tests):target/visual-tests/table/.DocxCarriedWithoutReportTest: the composed-shape corners case now pins its own width.10 and 12 on a 40×40 shape are named, and on a 20×40 one both are held at 10, as the page
draws them, and are not named.
5 sabotages, 4 caught:
Not caught: a composite given its measured width rather than the cell's box. A composite
lays its children out at their own widths inside the box, so in every suite this gives the
same output.
./mvnw -B -ntp clean verify: BUILD SUCCESS, including every visual and layout-snapshotbaseline in qa.
Knowledge pack: the claims and proofs indexes were regenerated for the lines the recipe
moved. The API surfaces, stability doc, claims and routes checks all pass, and core javadoc
passes with no warnings.
Lane: shared-engine (
document.layout), with the render-docx report following it. PDF outputchanges only for a node of a size of its own composed directly in a table cell narrower than the
cell's inner width.