Skip to content

fix(docx): take a line's upward pull off the line above it when no space above can give it - #797

Merged
DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-pull-into-line-above
Sep 30, 2026
Merged

DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-pull-into-line-above

Conversation

@DemchaAV

@DemchaAV DemchaAV commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Why

CobaltRota's masthead stood about 7pt low in Word, and the whole rota under it with it.

What changed

  • standsIntoTheSpaceAbove. Where the space above still falls short after the pull is netted, a paragraph takes the rest in two steps.
    • takeFromTheLineAbove. It takes from the foot of the line written just before. That must be the Word paragraph writeParagraph wrote last (lastWrittenNode / lastWrittenParagraph), still lastBodyParagraph, and on the page the pulled paragraph starts on. It must also be one exact line of text, not one of a stack, with no space below it and no run shaded or underlined: shading fills the line, and an underline is drawn below the letters.
      • The line is written shorter by as much as its letters leave room below them where Word draws them, DocxStackedLines.INK_MARGIN clear. That room is read off Word's geometry: its baseline a fifth of the line above the foot, raised by the runs' written w:position, the letters' reach taken unseated from DocxInk.
      • Its runs are lowered by four fifths of that, as Word would raise its text with the baseline of a shorter exact line.
    • riseInsideItsOwnLine. It takes what is left from the top of the pulled line, as riseIntoItsLine does for a container's first line: a DocxStackedLines.Line limited by the room above its letters, seated where the page sets it.
  • A table, a page break or a new cell clears lastBodyParagraph, so the line above is never one across them. A line holding a picture has no ink DocxInk can read, so it is left whole.
  • Docs. CHANGELOG.md and the negative-edge paragraph of docs/recipes/docx-export.md are updated.

Verification

  • 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 (1791 + 127 tests).
    • After install, examples run 93 green.
    • The knowledge checks and extract-api --check pass.
    • render-docx runs 714 tests.
  • DocxSpaceAboveTest (new):
    • A subtitle pulled 2pt up under a 21pt wordmark in a row's cell: the wordmark's line is 2pt shorter, its text lowered 3 half points, and the subtitle's line whole.
    • A pull deeper than the letters above leave room for: the line above gives some, and the pulled line the rest.
    • A 3.5pt pull lowers the wordmark's text 6 half points, pinning the four fifths (three quarters would round to 5).
    • A line above whose text is shaded, or underlined, is left whole: its line and position equal a render without the pull.
  • Each step fails its own test when reverted: the take from the line above, the rise inside the pulled line, the shading and underline guards, and the four-fifths lowering (0.75 gives 5 half points, not 6).
  • Template corpus (62 documents), against 2.5-dev: only CobaltRota changes.
    • Its median drift falls from 8.9pt to 2.4 in Word and in LibreOffice.
    • Its lines more than 2pt off fall from 65 to 45 in Word, and from 62 to 47 in LibreOffice.
    • It stays one page.
    • On Word's screen at 300%, the wordmark's Q and the subtitle show whole.

Known limits

  • A pull the resumed space of a layered row would have absorbed is taken from the line above first, so a little of it can go unwritten.
  • A paragraph written a second time in a different context is not remembered as the container first line is.
  • CobaltRota's remaining drift is its outlined chips (1.1pt a row) and its group icons, anchored a row low.

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

@DemchaAV
DemchaAV merged commit a2365fd into 2.5-dev Sep 30, 2026
12 checks passed
@DemchaAV
DemchaAV deleted the fix/docx-pull-into-line-above branch September 30, 2026 23:34
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