Skip to content

Fix four bugs causing PowerPoint repair dialog & missing bullets (#1432, #1440, #1441, #1442)#1457

Open
rupivbluegreen wants to merge 1 commit into
gitbrent:masterfrom
rupivbluegreen:fix/ooxml-and-bullet-bugs
Open

Fix four bugs causing PowerPoint repair dialog & missing bullets (#1432, #1440, #1441, #1442)#1457
rupivbluegreen wants to merge 1 commit into
gitbrent:masterfrom
rupivbluegreen:fix/ooxml-and-bullet-bugs

Conversation

@rupivbluegreen

Copy link
Copy Markdown

Change Summary

Fixes four small bugs in src/gen-xml.ts, all of which are reported with reproductions and root-cause analysis in the linked issues. Three produce OOXML schema violations that trigger the PowerPoint repair dialog; one silently drops a bullet style.

Change Type

  • Bug fix
  • New feature
  • Documentation update

Related Issues

Motivation and Context

Three of these (#1440, #1441, #1442) produce OOXML schema violations that cause PowerPoint to show the "PowerPoint found a problem with content" repair dialog when opening a generated file. The fourth (#1432) makes bullet: { type: 'bullet' } — a documented and TypeScript-typed value (type?: 'bullet' | 'number', default 'bullet') — silently produce no bullet. The fixes are minimal and isolated; all four root causes were already debugged by the original reporters.

Change Description

gen-xml.ts:93 — Issue #1442
Solid color background now includes <a:effectLst/>, matching the image-background branch one line above.

-strSlideXml += `<p:bg><p:bgPr>${genXmlColorSelection(slide.background)}</p:bgPr></p:bg>`
+strSlideXml += `<p:bg><p:bgPr>${genXmlColorSelection(slide.background)}<a:effectLst/></p:bgPr></p:bg>`

gen-xml.ts:320 — Issue #1440
Adds two defensive guards after the existing number-to-array conversion:

  • if cellMargin is still not an array (i.e. user passed an object or string), fall back to DEF_CELL_MARGIN_IN
  • map any non-finite entries to 0 so inch2Emu(undefined) can no longer yield marL=\"NaN\" etc.

gen-xml.ts:890 — Issue #1432
Merges the outer if (bullet.type) and inner if (type === 'number') checks into a single condition so non-number types fall through to the characterCode / code / default branches and produce a normal bullet character.

gen-xml.ts:1158 — Issue #1441
genXmlTextBody() no longer returns an empty string when a non-tablecell object has no text; it returns a minimal valid <p:txBody> (<a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"...\"/></a:p>) so the enclosing <p:sp> satisfies the OOXML schema. The lang defaults to opts.lang || 'en-US', consistent with other endParaRPr emissions in this file.

Verification

Built locally with npm run build and ran a small Node script that exercises each scenario and inspects the resulting XML in the generated .pptx:

```
PASS #1442 solid bg includes <a:effectLst/>
PASS #1441 empty-text shape has <p:txBody>
PASS #1440 bogus table margin produces no NaN attributes
PASS #1432 bullet:{type:"bullet"} renders <a:buChar>
```

Confirmed that the same script fails on `master` (without the fix), and `npx eslint src/gen-xml.ts src/gen-objects.ts` passes clean.

Checklist

  • My code follows the style guidelines of this project (tabs, single quotes, no semicolons)
  • My changes generate no new eslint warnings (lint clean on modified files)
  • I have performed a self-review of my code
  • I have commented the non-obvious lines (OOXML reasoning, NaN guard rationale)
  • I have included verification that the fixes are effective (see above)
  • Only src/*.ts modified — no dist or src/bld changes

…t#1440, gitbrent#1441, gitbrent#1442)

* gitbrent#1432 - bullet:{type:'bullet'} now produces a bullet character
  Merged the outer 'if (bullet.type)' and inner 'if type === number'
  conditions so non-number types fall through to the default bullet
  rendering branch instead of being silently dropped.

* gitbrent#1440 - guard table cell margin against non-number/non-array values
  Falls back to DEF_CELL_MARGIN_IN and maps any non-finite entries to
  0, preventing marL/marR/marT/marB='NaN' attributes that trigger the
  PowerPoint repair dialog.

* gitbrent#1441 - shapes without text now emit a minimal valid <p:txBody>
  genXmlTextBody() previously returned an empty string for non-tablecell
  objects with no text, leaving <p:sp> elements without their required
  <p:txBody> child (OOXML schema violation, triggers repair dialog).

* gitbrent#1442 - solid color slide backgrounds include <a:effectLst/>
  Brings the solid color background branch in line with the image
  background branch, avoiding the PowerPoint repair dialog.
MBuelowius added a commit to NeomaVerwaltung/PptxGenJS that referenced this pull request Jun 23, 2026
…rent#1432, gitbrent#1440, gitbrent#1441, gitbrent#1442)

Adopts upstream PR gitbrent#1457. Four independent fixes in gen-xml.ts:

- Solid-color slide background: emit <a:effectLst/> in <p:bgPr> (gitbrent#1442)
- Table cell margin: guard non-number/non-array values that produced NaN
  XML attributes (gitbrent#1440)
- bullet:{type:"bullet"}: only the "number" type takes the auto-num branch;
  all other types now fall through to the default bullet (gitbrent#1432)
- Shapes without text: emit a minimal valid <p:txBody> instead of nothing,
  as required by the OOXML schema (gitbrent#1441)

Original work by @rupivbluegreen in gitbrent#1457 (MIT).

Co-Authored-By: rupivbluegreen <rupivbluegreen@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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

1 participant