Skip to content

fix(docx): take text hanging past a block out of the space above a band that follows - #830

Merged
DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-consulting
Oct 3, 2026
Merged

DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-consulting

Conversation

@DemchaAV

@DemchaAV DemchaAV commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Why

Text that runs past the foot of the block it stands in leaves that reach in hangingBelow, for the space above what follows to give back. That covers:

A paragraph or a table that follows takes it out of its space above.

A stack written as a band dropped it. writeOverlayBand seeds the space above its first block (resumeSpacing) from the gap the page measures. Its first block then resumes that space (resumeHere) and forgets the hang.

ConsultingInvoice.

  • Its masthead stacks the supplier's contacts as bands, an icon beside the text in each.
  • The address, two lines (20.3pt), runs 2.3pt past its 18pt band.
  • The phone band under it opened 3.7pt below the address paragraph instead of 1.4pt. In Word the phone, mail and web lines stood 2.9pt low, while their icons, anchored where the page draws them, stayed put.
  • Those are the 3 lines more than 2pt off in the invoice and in its long version.

What changed

  • writeOverlayBand. When a band opens (not inside a band already writing), the hang comes off the space above its first block, as far as that space goes. A band the layout starts on a new page leaves the hang on the page above, as a paragraph (fix(docx): keep the space above a paragraph or spacer the layout moves to a new page #825) and a table (fix(docx): keep a table's top edge on the page the layout moves it to #821) there do.
  • Baselines. word-windows, libreoffice-windows and their -lines files are rewritten for the six lines this moves.
    • libreoffice-linux and its -lines file are taken from this PR's CI run (docx-fidelity-37134178025).
    • On Linux the same six lines move, from +2.81 to +0.51pt; lines past 2pt there fall from 732 to 726. No other document changes, MerchantInvoice included: its Linux baseline already matched.
  • Docs. CHANGELOG.md, and the paragraph on pulls and overhangs in docs/recipes/docx-export.md.

Verification

  • Template corpus, re-measured in full in both editors on Windows. Only ConsultingInvoice and its long version move: three contact lines each. No line is lost, and page counts are unchanged.

    Document Editor Past 2pt Contact lines
    ConsultingInvoice Word 3 → 0 +2.91 → +0.51pt
    ConsultingInvoice, long Word 3 → 0 +2.91 → +0.51pt
    ConsultingInvoice LibreOffice (Windows) 3 → 0
    ConsultingInvoice, long LibreOffice (Windows) 3 → 0

    Across the corpus, lines past 2pt fall from 11 to 5 in Word, and from 614 to 608 in LibreOffice (Windows). The 5 left in Word are VioletGrid's.

  • New test, DocxOverlayBandTest.textHangingBelowABandTakesItsPlaceOutOfTheSpaceAboveTheNextBand.

    • Setup: a stack whose last layer runs 4pt past its foot, then a second stack, 10pt apart.
    • The second stack's first paragraph has 6pt above it (120 twips).
    • Without the change it has the gap whole, 200 twips.
  • New test, DocxOverlayBandTest.aBandOpeningTheNextPageLeavesTheHangAboveOnItsPage.

    • Setup: the same two stacks, the second opening the next page. The test checks that on the layout first.
    • The second stack's first paragraph keeps its space above whole, 200 twips, the hang not taken from it. Word drops that space at the page top; the test pins the arithmetic.
    • Without the guard it has 120.
  • Examples module (./mvnw -B -ntp test -f examples/pom.xml, 93 tests): BUILD SUCCESS. No committed preview moves.

  • 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 -am gives BUILD SUCCESS. render-docx runs 847 tests, qa 1814.

Known limits

  • A hang longer than the space above the band loses the rest, as before a table (newTable). A paragraph that follows instead takes the rest out of its own top edge (hangingOver).
  • A band nested in a one-layer stack wrapper on a new page still takes the hang from the space above it, which Word drops at the page top anyway. That is the same overlayDepth == 0 condition the paragraph path uses (fix(docx): keep the space above a paragraph or spacer the layout moves to a new page #825). The one-layer flow depth is left to the change that unifies it.

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

@DemchaAV
DemchaAV merged commit ad6a680 into 2.5-dev Oct 3, 2026
13 checks passed
@DemchaAV
DemchaAV deleted the fix/docx-consulting branch October 3, 2026 16:23
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