Skip to content

fix(docx): resolve basedOn style chains - #1455

Merged
developer0hye merged 1 commit into
mainfrom
fix/issue-1453-docx-based-on-style-cascade
Aug 31, 2026
Merged

fix(docx): resolve basedOn style chains#1455
developer0hye merged 1 commit into
mainfrom
fix/issue-1453-docx-based-on-style-cascade

Conversation

@developer0hye

Copy link
Copy Markdown
Owner

Summary

  • Resolve DOCX paragraph and character style w:basedOn chains transitively within the same style type.
  • Preserve document-default, parent, child, and direct-formatting precedence while handling missing parents, cross-type parents, cycles, and declaration order deterministically.
  • Restore the inherited centered alignment of the Place your event title here.docx #1219 fixture's ALL, AGES, WELCOME, and gate text, with fresh two-page visual evidence.

Related issue

Fixes #1453

Testing

  • TDD red: CARGO_TARGET_DIR=/Users/yhkwon/Documents/office2pdf/target cargo test -p office2pdf --lib test_based_on_chain_inherits_parent_paragraph_and_run_properties -- --nocapture failed before the implementation because inherited center alignment was None.
  • CARGO_TARGET_DIR=/Users/yhkwon/Documents/office2pdf/target cargo test -p office2pdf --lib parser::docx::tests::style_tests -- --nocapture (51 passed)
  • CARGO_TARGET_DIR=/Users/yhkwon/Documents/office2pdf/target cargo test --workspace (all workspace, fixture, integration, and doc tests passed)
  • CARGO_TARGET_DIR=/Users/yhkwon/Documents/office2pdf/target cargo clippy --workspace --all-targets -- -D warnings
  • CARGO_TARGET_DIR=/Users/yhkwon/Documents/office2pdf/target cargo check --target wasm32-unknown-unknown -p office2pdf
  • CARGO_TARGET_DIR=/Users/yhkwon/Documents/office2pdf/target cargo check --target wasm32-unknown-unknown -p office2pdf --features wasm
  • CARGO_TARGET_DIR=/Users/yhkwon/Documents/office2pdf/target cargo check --target wasm32-unknown-unknown -p office2pdf --features wasm-cjk-font
  • python3 -m unittest discover -s scripts/tests -p 'test_*.py' (275 passed)
  • cargo fmt --all -- --check
  • git diff --check
  • python3 scripts/compare_layout.py gt.pdf after.pdf --json --audit (expected nonzero; all remaining findings dispositioned to DOCX missing-font selection changes table wrapping and placement across hosts #1409 and DOCX table cells do not break overlong Latin tokens at character boundaries #1454, with zero painted-visibility mismatches)
  • python3 scripts/compare_text_layer.py gt.pdf after.pdf --json (census identical; normalized content differs only because GT breaks WELCOME as WELC / OME, tracked in DOCX table cells do not break overlong Latin tokens at character boundaries #1454)
  • python3 scripts/compare_render.py --page 1 --dpi 300 --audit --lines --artifacts-dir ... gt.pdf after.pdf and page 2 equivalent (expected nonzero; all remaining clusters dispositioned to DOCX missing-font selection changes table wrapping and placement across hosts #1409 and DOCX table cells do not break overlong Latin tokens at character boundaries #1454)
  • Documentation freshness audit: PASS

Visual impact

  • No rendered PDF change
  • Rendered PDF change or visual evidence added
  • Reason: inherited center alignment moves the page-1 right-cell heading and gate runs horizontally to the reference anchors.

Visual audit

Visual comparison

GT Before After
GT Before After

Required inspection

  • Rendered all evidence at 150 DPI or higher
  • Stored progressive JPEG quality 86 assets with metadata stripped
  • Used Codex/Claude vision to inspect the full GT/output pages, diff, and matched crops
  • Inspected matched region crops at full resolution
  • Ran compare_layout.py --audit and dispositioned every large text-instance shift and painted-visibility mismatch
  • Ran the 5% fuzz pixel-difference sweep
  • Inventoried hairlines and border dash styles
  • Inventoried font weight, italic, and underline emphasis

Deviation audit

Check Result
Page count/order Matches GT: two pages in the same order, with the RSVP page second
Element presence Remaining: #1454 tracks GT's WELC / OME lines versus the output's single WELCOME line; all source elements remain present
Position/size Remaining: #1454 tracks the page-1 vertical stack caused by the missing line; #1409 tracks subtitle and RSVP metric shifts; #1453 fixes the right-cell horizontal anchors
Rotation/flip Matches GT: the rotated photo and transformed decorations keep their orientation
Fill Matches GT: the blue/pink panels and solid decorations retain their colors and coverage
Stroke/border Matches GT: the white circle, three outlined triangles, diagonal separators, yellow diamond, and three vertical rules retain their high-DPI hairline strokes; there are no dashed borders
Shape outline geometry Matches GT: crops show the diamond, circle, triangles, polygon boundaries, dot fields, photo bounds, and vertical bars unchanged
Text content Remaining: #1454 tracks the hard line break in GT's WELC / OME; the codepoint-class census otherwise matches and both footer instances remain extractable
Font family/weight/style Remaining: #1409 tracks host-dependent title/body/RSVP font family, weight, and width metrics; bold emphasis remains present, with no italic or underlined runs
Text color Matches GT: all text remains black on both pages
Alignment Remaining: #1454 tracks centering of the two resulting WELCOME lines after wrapping; #1453 fixes the inherited center alignment for every current right-cell line
Line/paragraph spacing Remaining: #1454 tracks the missing WELCOME line and resulting vertical cell distribution; #1409 tracks subtitle and RSVP font-metric offsets
Clipping/overflow Remaining: #1454 tracks the single overflowing WELCOME line; the page-1 footer is correctly clipped/occluded and now reports zero visibility mismatches

Checklist

  • Commits include a Signed-off-by line
  • PR scope contains one root cause
  • Remaining visual deviations each reference an open issue

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
@developer0hye
developer0hye merged commit f497d24 into main Aug 31, 2026
18 checks passed
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.

DOCX basedOn style chains are ignored, dropping inherited alignment and formatting

1 participant