Skip to content

fix(docx): keep a panel's padding round its outline - #925

Merged
DemchaAV merged 1 commit into
2.5-devfrom
fix/docx-composed-shape-padding
Oct 19, 2026
Merged

DemchaAV merged 1 commit into
2.5-devfrom
fix/docx-composed-shape-padding

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Why

The page sets a shape container's padding round its outline: it measures it as outline plus
padding, draws the outline in from the padding, and sets the layers in the outline itself
(ShapeContainerDefinition). Written as a panel in a table cell, the padding was the panel cell's
margins, inside the outline.

Measured in Word 16 and LibreOffice on Windows, a 100×60pt shape in an 80pt row:

Padding, layer Page Before, in Word / LibreOffice After, in Word / LibreOffice
10 all round, TOP_LEFT fill x 86, y 99; baseline 113.2 fill x 76 / 75.5, y 99; baseline 122.2 / 122.3 fill x 86.1 / 85.5, y 99 / 98.9; baseline 112.2 / 112.2
20 at the left, BOTTOM_RIGHT label x 142.3–196 x 122.3–176.1 / 121.9–175.5 x 142.4–196.2 / 141.9–195.5
10 all round, CENTER label x 124.7 x 114.7 / 114.3 x 124.7 / 124.3

None of it was named. The point left over vertically is Word's own: "Before", above the table,
stands 0.9pt higher too.

What changed

  • writePanelPiece: a shape's padding is added to its margin and written as a margin is:

    • the table's indent;
    • the space above it;
    • the space below it.

    The panel's cell margins are written as for no padding.

  • panelWidth counts the padding beside the outline, so a padded shape is held inside its
    cell. roomInItsPanel is the outline's width, where the page sets the layers.

  • setDownItsCell: both editors set a cell's content at its middle or its foot without the
    paragraph that closes the cell after a table, its space below included. Measured with 10pt above
    and below:

    • a centred cell set the shape 5pt low;
    • a cell set at its foot, 10pt low;
    • a cell set at its top, where the page sets it.

    Where the shape's table ends its composed cell (endsItsComposedCell: the cell's node, or the
    last child down unpainted sections, containers, alignments and stacks of one layer), in a row the
    layout holds at the page's height, a centred cell takes the space below off the space above.
    What it cannot take, and the space below in a cell set at its foot, is named on the shape
    (APPROXIMATED): it stands that much lower.

  • writeCellContent records the composed cell's node and its anchor down the row
    (composedCellContent, composedCellDown), or the top where the layout does not hold the row.

  • Docs:

    • the recipe's composed-panel paragraph;
    • the capability matrix's layer-stack row;
    • the padding and margin entries of DocxNodeFieldLedgerTest for the shape container;
    • CHANGELOG v2.5.0.

Verification

  • The cell's anchor, measured in Word and LibreOffice with a 10pt padding above and below:
    • a cell set at its top: the shape where the page sets it;
    • a centred cell: the shape where the page sets it;
    • 4pt above and 16pt below in a centred cell: 6pt low, as named;
    • a cell set at its foot: 10pt low, as named.
  • Padded chips as the composed-cell tests build them, rendered before and after:
    • Carlito with a 2pt padding: after, the fill and the label stand as far right of the page's as
      an unpadded chip's do in the same column (+1pt); before, they stood 1pt left of it.
    • Lato with a 2pt padding and a 1.1pt outline: the baseline on the page's within 0.1pt, before
      and after.
  • Corpus, 62 DOCX before and after: all 62 are byte-identical, and the report's 1246 notes are
    identical. The 123 shape containers composed in table cells have no padding and no margin.
  • DocxPanelPaddingTest (new, 10 tests):
    • the padding as the table's indent, the cell margins zero;
    • a centred cell giving the space below up from above, the space below still written;
    • a top cell keeping margin and padding above, summed;
    • more below than above, named;
    • a panel ending a section after a heading, set down as with no padding;
    • one something follows, unchanged;
    • one in a row the layout does not hold, unchanged;
    • a shape wider than its cell less its padding, held in;
    • a foot cell named, and the default anchor read as the foot.
  • Tests that pinned the padding inside the outline, updated with the measure above:
    • DocxComposedCellTest: aPaddedChipsLabelIsSeatedInItsOutline, and
      aPaddedChipsLabelItsOutlineHoldsIsSeatedOnTheOutlinesMiddle, whose line is now the 15.3pt
      its borders leave;
    • DocxPanelTailTest: aPaddedShapeHoldsItsOutlineLessBothBorders and
      aShapesHangingLineIsHeldInItsOutline;
    • DocxPanelLayerAlignTest: aPaddedShapesLayerIsHeldInItsOutline.
  • 11 sabotages, all caught:
    • the padding inside the outline;
    • not set down its cell;
    • a centred cell not given back;
    • lower unnamed;
    • the foot read as the middle;
    • only the cell's own node set down;
    • a top cell read as centred;
    • the room less the padding;
    • any panel set down;
    • a row not held set down;
    • the width without the padding.
  • ./mvnw -B -ntp clean verify: BUILD SUCCESS (core 821, render-docx 1841, examples 93, qa 1820).
    The knowledge pack's --check passes.

Lane: render-docx (semantic backend). DOCX output changes only for a shape container with
padding composed in a table cell.

The page sets a shape container's padding round its outline and its
layers in the outline itself. Written as a panel in a table cell, the
padding was the cell's margins, inside the outline: measured in Word
and LibreOffice, a 10pt padding stood the fill 10pt left of the page's
and a top-left label 9pt low.

The padding is now written as a margin is, the table's indent and the
space above and below it, the cell's margins as for no padding, and the
panel's width counts it beside the outline.

Both editors set a cell's content at its middle or foot without the
paragraph closing the cell after a table. Where the shape's table ends
its cell in a row held at the page's height, a centred cell takes the
space below off the space above; what it cannot, and the space below in
a cell set at its foot, is named on the shape.
@DemchaAV
DemchaAV merged commit 03e5f76 into 2.5-dev Oct 19, 2026
13 checks passed
@DemchaAV
DemchaAV deleted the fix/docx-composed-shape-padding branch October 19, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant