fix(pptx): background rendering - gradient inheritance and page fill reset#188
Open
nikith-18161 wants to merge 8 commits into
Open
fix(pptx): background rendering - gradient inheritance and page fill reset#188nikith-18161 wants to merge 8 commits into
nikith-18161 wants to merge 8 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()walkedslide → layout → masterfor 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 pagewithout afillparameter inherits the previous page's fill. Slides with no explicit background would show the prior slide's color or gradient. Fixed by explicitly settingfill: whitewhen neitherbackground_colornorbackground_gradientis present.3.
bgRefbackground 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. AddedbgRefsupport so the placeholder color is resolved as the background color.Testing
cargo test -p office2pdf --lib— 1076 passed, 0 failedcargo test -p office2pdf --test pptx_fixtures— 93 passed, 0 failedcargo fmt --all -- --check— clean