Skip to content

fix(docx): set a panel set in from its cell's text where the page sets its text - #949

Merged
DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-charcoal-heading-offset
Oct 23, 2026
Merged

DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-charcoal-heading-offset

Conversation

@DemchaAV

@DemchaAV DemchaAV commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Why

A painted container in a table cell is written as a nested one-cell table (writePanelPiece). Its indent is its edge less half its left border (edge − halfLeft), and its left margin is its padding less that half (insideTheBorders).

In a cell, Word and LibreOffice set a nested table's left border with its outer edge at the cell's text, or as far in as a positive indent sets it. They set its text at that border's centre plus the cell's margin.

A panel hung on the cell's text is moved right by half its border, and the half its margin gave back puts its text where the page sets it. A bled one is moved by its bleed too, its text with it, which the report names (left edge). For a panel set in from the cell's text by half its border or more, nothing moves the table. Its border stood where the page draws it, and its text stood half that border left of the page's. A panel set in less stood its text as far left as it was set in.

Measured on Windows:

Panel Text, Word Text, LibreOffice
CharcoalGold's headings, set in from their layer stack column's edge (1.7pt accent) −0.72pt −0.71 to −0.81pt
synthetic: a card set in 5pt from a filled panel's text (2pt accent) −1.02pt −0.90pt
synthetic: the same set in 0.5pt, partly hung −0.48pt −0.40pt
synthetic: a heading set in 6pt from a stack column's edge (1.7pt accent) −0.71pt −0.75pt

The left end of the text measured within 0.13pt of the page's in three cases:

  • body panels;
  • panels hung on their cell's text, which covers every row cell's, as a row cell starts past its child's margin;
  • unbordered panels.

What changed

  • writePanelPiece keeps of the left border's half what the panel is set in by (setIn = min(halfLeft, max(0, edge))). In a cell its left margin is padding.left − halfLeft + setIn:
    • set in half its border or more: the whole padding;
    • set in less: what it is set in by of that half;
    • hung or bled: unchanged, the padding less the half.
    • Below zero, for a padding thinner than the half, setCellMargin writes none.
  • The hung-panel width give-up needs no change. For a panel set in less than half its border, its cap, no more than the editors move the table (halfLeft − indent), is now exactly what the table's left side gives its text.
  • The body is unchanged: it writes the whole padding, its indent placing its text.
  • Docs:
    • the recipe's panel passage and its Borders bullet;
    • the javadoc of writePanel;
    • the capability matrix's rectangle row;
    • the javadoc of insideTheBorders;
    • the CHANGELOG (Public API).

Verification

  • DocxContainerPaintTest (+4 new, 1 updated):
    • New: a card in a row's column, its margin 5pt, keeps the padding less half its border, as a row's cell starts past its child's margin.
    • Updated: a card set in 5pt from a filled panel's text keeps its whole 8pt padding as its margin. The test claimed the padding less half the border.
    • New: a card set in 0.5pt keeps 7.5pt; hung on the text and bled left it keeps 7pt.
    • New: a 4pt border over 1pt of padding keeps none set in 0.5 or 1pt, and all of it set in 3pt.
    • New: a heading in a layer stack column padded 23.7pt in from its edge, as CharcoalGold's main column is, keeps its 9pt padding.
  • Fail-closed: 5 sabotages, each run alone, all caught:
    • the half given back as before;
    • the whole half kept however far the panel is set in;
    • a bleed taken off the margin;
    • what it is set in by kept past the half;
    • set in counted from the panel's own margin rather than its edge.
      A fifth, writing a margin below zero, cannot change the file, as setCellMargin writes none.
  • Word and LibreOffice on Windows:
    • CharcoalGold's headings: text now +0.12pt in Word and +0.04 to +0.14pt in LibreOffice. Their rules now +0.13 to +0.16pt; they stood 0.7pt left with their words. Their bars are unchanged.
    • The synthetic cards: +0.06 and +0.10pt set in 5pt, 0.00 and +0.10pt set in 0.5pt, +0.13 and +0.10pt in the stack column.
    • The hung, body and unbordered cases do not move.
    • No line breaks differently or moves down in either editor; the 25 words of a wrapping paragraph moved together 0.5pt.
  • Corpus: 1 of 62 DOCX changes, cv-charcoal_gold: 7 heading words move 0.8 to 0.9pt right. Notes are unchanged, 1385.
  • Gate:
    • ./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 2086, 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.
    • After the last test and the wording fixes: ./mvnw verify -pl :graph-compose-render-docx → BUILD SUCCESS, 2087 tests, and the qa documentation guards → 150 tests, BUILD SUCCESS.

Lane: shared-engine (render-docx): no public API change.

…s its text

- In a cell, Word and LibreOffice set a nested table's left border with
  its outer edge at the cell's text, or as far in as its indent sets it,
  and its text that border's centre and the cell's margin in. A panel's
  margin was its padding less half that border, so a panel set in from
  its cell's text stood its text half that border left of the page's.
- It now keeps its whole left padding as its margin where it is set in
  half its border or more, and what it is set in by of that half where
  less. A panel hung out of its cell or bled left is unchanged.
- Measured on Windows: CharcoalGold's headings stood their text 0.72pt
  left of the page's in Word and 0.71 to 0.81pt in LibreOffice, now 0.12
  and 0.04 to 0.14pt right, their rules with them; a card set in 5pt
  from a filled panel's text 1 and 0.9pt left, now 0.06 and 0.1pt right.
  No line breaks differently in either editor.
- Tests: a nested card set in, set in half a point, hung and bled; a
  padding thinner than half its border; a heading set in from a stack's
  column edge.
@DemchaAV
DemchaAV marked this pull request as draft October 23, 2026 11:56
…argin

- A card in a row's column, set in by a margin on the page, stands on
  its cell's text, which starts past that margin, and keeps none of its
  border's half.
- The CHANGELOG and the comments say a panel hung on its cell's text is
  moved right by half its border, and a bled one by its bleed too, its
  text with it.
- The recipe's Borders bullet points to the left edge under Nesting, and
  its Measured bullet counts a card set in from a filled panel's text as
  measured.
@DemchaAV
DemchaAV marked this pull request as ready for review October 23, 2026 12:01
@DemchaAV
DemchaAV merged commit 8400edd into 2.5-dev Oct 23, 2026
13 checks passed
@DemchaAV
DemchaAV deleted the fix/docx-charcoal-heading-offset branch October 23, 2026 12:09
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