Skip to content

fix(pptx): skip inherited content placeholders in html preview#80

Closed
kuishou68 wants to merge 1 commit intoiOfficeAI:mainfrom
kuishou68:fix/pptx-inherited-placeholders
Closed

fix(pptx): skip inherited content placeholders in html preview#80
kuishou68 wants to merge 1 commit intoiOfficeAI:mainfrom
kuishou68:fix/pptx-inherited-placeholders

Conversation

@kuishou68
Copy link
Copy Markdown
Contributor

@kuishou68 kuishou68 commented Apr 28, 2026

Summary

  • Skip inherited PPT layout/master content placeholders in HTML preview.
  • Keep visible inherited metadata placeholders: date/time, footer, header, and slide number.
  • Prevent placeholder edit-prompt text from rendering over real slide content.

Fixes #79

Validation

  • dotnet build src/officecli/officecli.csproj
  • On the affected PPTX sample, inherited prompt text count changed from 29 to 0 in generated HTML.

Note: build still reports the existing OpenMcdf NU1902 advisory warning.

Image Clipboard_Screenshot_1777344160

@goworm
Copy link
Copy Markdown
Contributor

goworm commented Apr 28, 2026

Closing in favor of #81, which addresses the same root cause (ECMA-376 §19.3.1.36 default type=obj when the attribute is absent — Open XML SDK reports HasValue==false, masking the original denylist) and additionally preserves layout placeholder chrome (fill/outline) instead of dropping the entire shape. PR #81 credits @kuishou68 as Co-Authored-By since the diagnosis and reproducer in this PR are what made the fix reachable. Thanks for the original report and screenshots — they made the bug very clear.

@goworm goworm closed this Apr 28, 2026
goworm added a commit that referenced this pull request Apr 28, 2026
…view (#81)

Layout and master content placeholders carry editor prompt boilerplate
("Click to add title", "单击此处添加正文") in their <p:txBody>. Real
Office never renders that text; it shows up only in edit mode. Open XML
SDK exposes the layout's <p:txBody> directly, and the previous renderer
forwarded it onto the slide whenever the placeholder slipped past the
type denylist.

Two issues with the old denylist approach:

1. ECMA-376 §19.3.1.36 says a <p:ph> with no `type` attribute defaults
   to `obj`. Open XML SDK reports `Type.HasValue == false` for the
   absent attribute, so the entire denylist branch was skipped — and a
   layout body placeholder authored without an explicit type leaked its
   prompt text onto the slide. This is the shape behind issue #79.

2. Picture/Chart/Table/Media placeholders weren't on the denylist
   either, so their prompt text ("Click icon to add picture") leaked
   the same way.

Fix: model the rule the way Apache POI does
(SlideShowExtractor.java:179-183, XSLFShape.java:369-370). Layout and
master placeholders never contribute text to the rendered slide — only
the four metadata slots (date/footer/header/slide number) carry
genuine layout-supplied content. Everything else is suppressed at the
text level but still renders chrome (fill / outline / geometry), so a
layout's themed placeholder background survives.

The ECMA default is now applied explicitly (`Type.HasValue == false`
=> Object) instead of relying on a side effect of the SDK's missing
HasValue.

Validated with a local functional test that injects a layout
placeholder with no `type` attribute and asserts the prompt text does
not appear in ViewAsHtml() while the layout-supplied footer text and
themed fill do.

Fixes #79
Supersedes #80

Co-authored-by: pojian <lijianlin6868@gmail.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.

PPTX HTML preview renders inherited placeholder prompt text

2 participants