Skip to content

test(docx): fail Word's restyle scenario when text is left without room for it - #854

Merged
DemchaAV merged 2 commits into
2.5-devfrom
test/docx-edit-protocol-restyle-clipping
Oct 5, 2026
Merged

DemchaAV merged 2 commits into
2.5-devfrom
test/docx-edit-protocol-restyle-clipping

Conversation

@DemchaAV

@DemchaAV DemchaAV commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Why

The restyle scenario passed documents whose text Word visibly breaks after the restyle. restyle-body-through-normal in scripts/docx-visual/edit-protocol-corpus.ps1 checked one thing: that the body's letters grew with Normal by 2pt. It passed every corpus document.

An exported DOCX sets almost every paragraph on an exact line (w:lineRule="exact"), and an exact line keeps its height when the letters grow. After Normal +2pt, Word sets cv-editorial_blue's profile in 11.5pt letters on the 10.3pt lines its 9.5pt letters had. The lines overlap, and on screen Word also cuts the letters' tops. Word's PDF export does not show the cut, so the fidelity gate cannot catch it either.

What changed

  • Restyle judges the room the grown letters get, wherever the restyle reaches.
    • Get-StoryParagraphs collects every paragraph Normal reaches: the main text, each section's own headers and footers, and the text drawings hold. Each is keyed by story and place, so the reopened document gives the same keys.

    • Before the edit it records each paragraph's largest letters (Get-LargestLetters) and the drawings whose text already overflows (Get-OverflowingFrames).

    • The scenario fails when a paragraph whose letters grew:

      • stands on exact lines shorter than 1.1× them, or
      • sits in a row or frame of exact height (Get-HeldBox);

      or when a drawing's text newly overflows it.

    • The detail counts each kind and names the first of each, for example 'Platform engineer with 1' (body 8) 9.5 -> 11.5pt letters on 10.3pt exact lines.

  • One threshold, the one the protocol already had. 1.1 is $EXACT_LINE_SHARE, which add-a-page uses for typed text.
  • Only grown paragraphs are judged. The page sets many exact lines tighter than 1.1× their own letters before any edit: all 74 exact paragraphs of cv-editorial_blue are. That spacing is the page's leading, not a cut the edit made.
  • A scenario with nothing to edit is recorded N/A with a reason from $NOT_APPLICABLE, instead of vanishing from edit-protocol-corpus.json.
    • N/A does not fail the run.
    • An edit counts as having nothing to edit only when it returns [bool] $false. PowerShell treats 0 -eq $false as true, so an edit ending on a call that returns 0 would otherwise turn into N/A.
    • drawings-follow-text is N/A when no drawing stands beside text, for example when the only drawings are page backgrounds.
  • One-scenario runs write a list. Invoke-Protocol's result is wrapped in @(...), because PowerShell hands a one-element array back as its element.
  • CONTRIBUTING's description of the protocol and a CHANGELOG Tests entry describe the checks.

Verification

Known-answer documents in Word 16.0 (16.0.20430), all scenarios:

Document restyle What it shows
Plain document Word wrote itself PASS Word's own line spacing passes
Word-written document: header line on exact lines (1.2× before the edit), text box its text just fills FAIL names header 1.1 1 (12 → 14pt on 14.4pt lines) and the overflowing drawing 1
Word-written document: footer line in a frame of exact height FAIL names it as grown in a frame of exact height
cv-editorial_blue FAIL 22 paragraphs
receipt-modern FAIL 9 paragraphs

On the exported documents the other scenarios keep the statuses an earlier run of the protocol gave them, including receipt-modern's add-a-page FAIL: text typed at its end goes into its closing table. The table, list and drawing scenarios are recorded N/A where a document has none.

Full corpus, 62 documents exported at 7c9808c7c, -Scenario restyle-body-through-normal:

  • FAIL in 60.
  • Of 1,989 paragraphs whose letters grew (body in all 62, footers in 2, text boxes in 3), 1,730 stand on exact lines too short for them. None is in a row or frame of exact height, and one drawing's text overflows.
  • MintEditorial and MintEditorialLetter pass: none of their exact lines falls below 1.1×.
  • The body follows Normal in all 62, and every document's scenarios is a list.

Documentation guards:

  • ./mvnw -B -ntp test -pl :graph-compose-core -Dtest='com.demcha.documentation.**' → BUILD SUCCESS, 166 tests.
  • ./mvnw -B -ntp test -f qa/pom.xml -Dtest='com.demcha.documentation.**' → BUILD SUCCESS, 28 tests.

No Java, POM or workflow file changes, so the full reactor gate was not run.

Lane: test — the local Word editing protocol (scripts/docx-visual) and its docs. No backend or public API change.

…oo short for it

restyle-body-through-normal checked only that the body's letters grew with
Normal by 2pt. An exported DOCX sets most paragraphs on exact lines, which keep
their height when the letters grow, so Word overlaps the lines and cuts the
letters' tops on screen; the scenario passed every corpus document regardless.

The scenario now records each paragraph's largest letters and exact line before
the restyle, and fails when a paragraph whose letters grew keeps an exact line
that did not grow with them and now stands below 1.15 of their size, or sits in
a row of exact height. It is judged by the change, not by an absolute share:
the page sets many exact lines tighter than 1.1 of their letters before any
edit, and that is its leading.

A scenario a document has nothing to edit for is recorded N/A with what the
document lacks instead of disappearing from the JSON, N/A does not fail the
run, and a run of one scenario writes each document's results as a list.
…ne share

The restyle scenario read only the main story, so a header or footer line
set at the body size on an exact line, or held in a frame of exact height,
and a text box its text just fills, could be cut by the restyle while the
scenario passed - hidden today only because every corpus document fails in
its body.

It now reads every story the restyle reaches: the main text, each section's
own headers and footers, and the text drawings hold, keyed by story and place
so the reopened document matches. A grown paragraph fails on exact lines
shorter than 1.1 of its letters - the share add-a-page already holds typed
text to, replacing a second, stricter 1.15 - or in a row or frame of exact
height, and a drawing whose text newly overflows fails too; the detail counts
each and names the first of each.

An edit reads as having nothing to edit only when it returns $false, not 0;
drawings-follow-text is N/A when no drawing stands beside text; the N/A
reasons count characters, as Find-BodyParagraph does.
@DemchaAV DemchaAV changed the title test(docx): fail Word's restyle scenario when text is left on lines too short for it test(docx): fail Word's restyle scenario when text is left without room for it Oct 5, 2026
@DemchaAV
DemchaAV merged commit f7b71f3 into 2.5-dev Oct 5, 2026
11 checks passed
@DemchaAV
DemchaAV deleted the test/docx-edit-protocol-restyle-clipping branch October 5, 2026 19:28
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