Skip to content

fix(pptx): background rendering - gradient inheritance and page fill reset#188

Open
nikith-18161 wants to merge 8 commits into
developer0hye:mainfrom
nikith-18161:fix/pptx-background-rendering
Open

fix(pptx): background rendering - gradient inheritance and page fill reset#188
nikith-18161 wants to merge 8 commits into
developer0hye:mainfrom
nikith-18161:fix/pptx-background-rendering

Conversation

@nikith-18161

Copy link
Copy Markdown

Summary

Fix three PPTX background rendering bugs affecting gradient inheritance, page fill reset, and theme background references.

Changes

1. Gradient background inheritance (pptx_slides.rs)

resolve_slide_background() walked slide → layout → master for solid colors but only checked the slide itself for gradients. Branded templates that define a gradient on the layout or master rendered with no background. Extended the gradient lookup to follow the same inheritance chain.

2. Page fill reset for slides without background (typst_gen.rs)

When no background is defined, Typst's #set page without a fill parameter inherits the previous page's fill. Slides with no explicit background would show the prior slide's color or gradient. Fixed by explicitly setting fill: white when neither background_color nor background_gradient is present.

3. bgRef background parsing (pptx_theme.rs)

parse_background_color() only handled <p:bgPr> (explicit fill) and silently ignored <p:bgRef> (theme background reference), which is the standard way PowerPoint templates define master backgrounds. Added bgRef support so the placeholder color is resolved as the background color.

Testing

  • cargo test -p office2pdf --lib — 1076 passed, 0 failed
  • cargo test -p office2pdf --test pptx_fixtures — 93 passed, 0 failed
  • cargo fmt --all -- --check — clean
  • Visually verified with test presentations covering all three cases

Signed-off-by: nikith-18161 <nikith.molaka@progentys.com>
…sheet

Signed-off-by: nikith-18161 <nikith.molaka@progentys.com>
Signed-off-by: nikith-18161 <nikith.molaka@progentys.com>
Signed-off-by: nikith-18161 <nikith.molaka@progentys.com>
- Fix failing test: update Double border style expectation to 'solid'
- Fix cargo fmt violations across xlsx.rs, xlsx_cells.rs, xlsx_style.rs,
  typst_gen.rs
- Fix incorrect paper size table: Statement (code 6) = 5.5x8.5in,
  Executive (code 7) = 7.25x10.5in, remove developer0hye#9 Envelope (code 19)
  from Letter grouping
- Add zero-margins fallback: when pageMargins element is absent umya
  returns 0.0 for all sides; fall back to Excel defaults (0.75in
  top/bottom, 0.7in left/right)
- Fix numeric right-align heuristic: use cell.get_value_number()
  instead of parsing the formatted string, avoiding false positives
  on text like '0050' and missing currency/percentage values
- Revert get_formatted_value fallback to get_value: the fallback
  cannot fix the inlineStr case without an upstream fix and risks
  un-hiding intentionally hidden cells
- Add TODO for vertical-align default inconsistency

Signed-off-by: nikith-18161 <nikith.molaka@progentys.com>
- Drop wrap_text field from TableCell IR — rendering not implementable
  in Typst without significant complexity; remove from ir/elements.rs,
  xlsx_cells.rs, xlsx_style.rs, docx_tables.rs, pptx_tables.rs and
  pptx_table_style_tests.rs
- Add Justify variant to CellHorizontalAlign; map Distributed to Justify
  in xlsx_style.rs; render as 'justify' in typst_gen_tables.rs
- Fix column width formula: (char_width * 7.0 + 5.0) * 0.75 per OOXML
  spec, accounting for 5px padding Excel adds before pixel-to-point
  conversion; update test range accordingly
- Add test_double_border_uses_2_5x_thickness covering format_border_side
  Double arm at 2.5x thickness as requested by reviewer

Signed-off-by: nikith-18161 <nikith.molaka@progentys.com>
Typst has no native justify alignment for table cells. Map
CellHorizontalAlign::Justify to 'left' as the closest approximation.

Signed-off-by: nikith-18161 <nikith.molaka@progentys.com>
…reset

Three PPTX background rendering bugs fixed:

1. resolve_slide_background: gradient background only checked the slide
   XML, never the layout or master. Solid color already walked the full
   slide -> layout -> master chain. Extended gradient lookup to follow
   the same inheritance chain so branded templates with gradients on
   the layout or master render correctly.

2. generate_fixed_page: when no background is defined, Typst's #set page
   without a fill inherits the previous page's fill. Slides with no
   background would show the prior slide's color/gradient. Fixed by
   explicitly setting fill: white when neither background_color nor
   background_gradient is present.

3. parse_background_color: only handled bgPr (explicit fill) and ignored
   bgRef (theme background reference), which is the standard way
   PowerPoint templates define master backgrounds. Added bgRef parsing
   so the placeholder color inside bgRef is resolved as the background
   color.

Signed-off-by: nikith-18161 <nikith.molaka@progentys.com>
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