Skip to content

PPTX: a picture in a picture placeholder takes its layout's shape - #1384

Merged
h-a-n-a-s-h-i merged 2 commits into
storytold:mainfrom
leobasilio:fix/picture-placeholder-geometry
Oct 30, 2026
Merged

h-a-n-a-s-h-i merged 2 commits into
storytold:mainfrom
leobasilio:fix/picture-placeholder-geometry

Conversation

@leobasilio

@leobasilio leobasilio commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

A photo in a picture placeholder whose layout draws it as a circle (or any shape other than a rectangle) was drawn as a plain rectangle, but still with the layout's border. PowerPoint cuts the photo into the layout's shape.

Seen in a real deck: a portrait on a slide whose layout has a round picture placeholder with a white border (<a:prstGeom prst="ellipse"/> and <a:ln w="95250"> in the layout) got a white-bordered rectangle in DeckCraft and a white-bordered circle in PowerPoint. The slide's p:pic names no geometry of its own, only its frame.

Cause: #301 made a placeholder with no prstGeom or custGeom take its layout's geometry, but mark_inherited_geometry was only called for p:sp, not p:pic, so the picture kept the default rectangle. Its line and fill already came from the layout, which is why the border was right and the shape was wrong. pic now calls it too. The renderer already clips a picture to its shape's outline, so nothing changes there. A picture outside a placeholder, or with its own geometry, is unchanged.

Before After
before after

Validation:

  • a_picture_placeholder_without_geometry_takes_its_layouts (new): fails on main (the geometry is rect), passes here. a_placeholder_without_geometry_takes_its_layouts (PPTX: a placeholder without geometry takes its layout's #301) still passes.
  • cargo fmt --check, cargo clippy -p deckcraft-pptx --all-targets -D warnings and cargo test -p deckcraft-pptx -p deckcraft-render pass. cargo xtask ci stops at ime_tests::korean_composes_in_the_notes_pane on my machine, which has no font with Korean glyphs; it fails the same way on main, so the doctest, assets, layers and wasm steps did not run.
  • The slide of the deck above, rendered with deckcraft-cli render: the photo is now in a white-bordered circle.
  • ROADMAP progress log updated.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Picture placeholders now inherit geometry from their layout when a presentation is reopened. This helps preserve the intended shape of pictures, including non-rectangular shapes such as ellipses. The fix applies when the picture itself does not include geometry, allowing it to retain the shape defined by its layout instead of appearing with a default shape.

A layout's round picture placeholder keeps a slide's photo in a circle in
PowerPoint. The reader marked only p:sp placeholders as inheriting their
geometry, so a p:pic placeholder with just a frame in its spPr came out as
a rectangle (with the layout's border). Mark p:pic placeholders too; the
renderer already clips pictures to their geometry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1705712 and b31a59a.

Files selected for processing: 1
  • ROADMAP.md
Files skipped from review as they are similar to previous changes: 1
  • ROADMAP.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

Picture parsing now marks geometry-less picture placeholders for geometry inheritance. An integration test checks that import uses the matching layout placeholder’s ellipse geometry when slide geometry is absent. The roadmap records the progress update.

Changes: Picture Placeholder Geometry

Layer / File(s) Summary
Mark and verify inherited picture geometry
crates/pptx/src/read/shapes.rs, crates/pptx/tests/it/placeholders.rs, ROADMAP.md
The picture reader marks placeholders without explicit geometry for inheritance. A test removes slide geometry and verifies that import uses the layout’s ellipse geometry. The roadmap records the 2026-10-25 progress update.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: dotcoocoo

Merge Risk: Minimal · up to b31a5

Pictures without their own geometry inherit the layout’s shape, including valid custom shapes. No merge-blocking issue was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: pictures in picture placeholders inherit the layout shape.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@hmmdev97

Copy link
Copy Markdown

Another deck with the same problem, from #1415. Here is a sample file for testing the fix: sample-rounded-placeholder.pptx. It is an anonymized customer deck with the master, layouts and geometry unchanged.

It differs from the ellipse case above in a few ways:

  • Custom geometry: the layout placeholders use <a:custGeom> (a rectangle with one rounded corner drawn with a cubicBezTo), not a preset.
  • Fill behind a transparent image: the layout placeholder has a solidFill, and the slide picture either overrides it with <a:noFill/> (slide 1) or sets its own fill (slide 2).
  • Two picture placeholders on one layout: slide 5 uses slideLayout7, which has pic idx=13 and pic idx=15. Each has a different rounded corner.
  • A picture with its own geometry: on slide 3 the picture sets <a:prstGeom prst="rect">, so it must stay square.
Slide Layout Placeholder Expected
1 slideLayout2 pic idx=14 rounded bottom-left
2 slideLayout5 pic idx=13 rounded bottom-right (the missing fill is #1416)
3 slideLayout2 pic idx=14, own prstGeom rect square
4 slideLayout5 pic idx=13 rounded bottom-right
5 slideLayout7 pic idx=13 / pic idx=15 rounded bottom-left / bottom-right

Left: ONLYOFFICE render. Right: deckcraft-cli 0.6.1 render.

Expected vs DeckCraft

@leobasilio

Copy link
Copy Markdown
Contributor Author

Checked this PR against the sample deck from #1415 (sample-rounded-placeholder.pptx). All five slides match the expected results.

I rendered the deck with deckcraft-cli built from this PR and from its parent. Base is on the left, this PR on the right:

image
Slide Layout / placeholder Without the fix With this PR Expected
1 layout 2, pic idx 14 square rounded bottom-left rounded bottom-left ✅
2 layout 5, pic idx 13 square rounded bottom-right rounded bottom-right ✅
3 layout 2, pic idx 14 with its own prstGeom rect square square stays square ✅
4 layout 5, pic idx 13 square rounded bottom-right rounded bottom-right ✅
5 layout 7, pic idx 13 and 15 both square top rounded bottom-left, bottom rounded bottom-right each with its own corner ✅

@hmmdev97 hmmdev97 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reported #1415. I tested this PR locally against the original customer deck that the shared sample was made from. That deck can't be shared, so this comment has no screenshots.

I rendered it with deckcraft-cli render --all, built from:

Build Picture placeholders (slides 1, 2, 4, 5) Slide 3 (own prstGeom rect) Fill behind the transparent icon (slide 2)
v0.11.1 (9ec3926) square ❌ square ✅ missing ❌
main (aaf6c1c) square ❌ square ✅ drawn ✅ (aece097)
this PR (b31a59a) rounded, each with its own corner ✅ square ✅ drawn ✅

With this PR, all five slides match what ONLYOFFICE/OpenOffice render. Without it, current main still draws the layout's rounded picture placeholders as plain rectangles, so the fix is still needed on top of main.

This approval is based on functional testing with the real deck, not on a code review. Thanks @leobasilio!

@Harrison-Booth

Copy link
Copy Markdown
Contributor

Review notes (comment only).

What I read: the diff (the reader now calls mark_inherited_geometry for p:pic, as it already did for p:sp) and the new a_picture_placeholder_without_geometry_takes_its_layouts test. CI on the head commit is green and the branch is clean against main.

Checked in real PowerPoint (Windows, COM, a new temporary presentation, closed without saving): I made a custom layout with a picture placeholder whose shape is an ellipse, added a slide on it and put a PNG into that placeholder with Shapes.AddPicture. The saved slide XML has a p:pic with <p:ph type="pic" idx="10"/> and an empty <p:spPr/>; the layout XML has the a:prstGeom prst="ellipse" on its placeholder. The slide exported by PowerPoint shows the picture cut into the ellipse. So the file shape this PR reads (a p:pic placeholder with no geometry of its own) is exactly what PowerPoint writes, and the layout's shape is what it draws.

Not run: I did not build or run the Rust tests here; I relied on the green CI. Nothing checked for a picture placeholder whose own spPr has an a:prstGeom (the test only covers the bare case).

@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit f08e5f8 into storytold:main Oct 30, 2026
7 checks passed
@echelon

echelon commented Oct 30, 2026

Copy link
Copy Markdown
Member

Landed on main, thank you @leobasilio for the contribution! If you haven't already, come join us on Discord: https://discord.gg/artcraft

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.

5 participants