Skip to content

PPTX: open and save macro-enabled .pptm/.potm/.ppsm decks - #523

Open
NikitkaRa wants to merge 1 commit into
storytold:mainfrom
NikitkaRa:pptm-macro-decks
Open

NikitkaRa wants to merge 1 commit into
storytold:mainfrom
NikitkaRa:pptm-macro-decks

Conversation

@NikitkaRa

Copy link
Copy Markdown
Contributor

Summary

  • .pptm/.potm/.ppsm open from the file dialogs, drag and drop and the web picker (they were rejected before).
  • The VBA project (ppt/vbaProject.bin) is read into Presentation.vba_project as opaque media and kept byte for byte. It is never run. It also survives a .deckcraft save.
  • Saving as .pptm/.potm/.ppsm (new deckcraft_pptx::export_macro_enabled) writes it back with the macro-enabled main content type, the vbaProject relationship and the application/vnd.ms-office.vbaProject override.
  • Saving a macro deck as .pptx/.potx/.ppsx leaves the macros out and warns (warning in the file.save/file.saveAs result plus a UI message), as PowerPoint does.
  • docs/gaps.md: the macro half of "Template, slide-show and macro variants" is removed.
  • Note: open PRs PPTX: .potx and .ppsx declare a template and slide show main part (#210) #212/Save .potx and .ppsx with their own main content type (#210) #217 change how CT_PRES is picked for potx/ppsx. This API is separate from theirs, but a small conflict in write/mod.rs is possible. Backstage's Change File Type list isn't changed; typing a .pptm name in Save As works.

Test plan

  • pptm_keeps_its_vba_project (pptx roundtrip tests): it builds a PowerPoint-layout .pptm and imports it. The VBA bytes match. A re-export to pptm/potm/ppsm gives the right part, content types and rel, and the file reopens with its macros. A plain export has no VBA part and no macroEnabled type. Engine file.open then saveAs .pptx warns, and saveAs .pptm keeps the bytes.
  • cargo xtask ci
  • Manual check in PowerPoint (the box has no display, so the UI and PowerPoint weren't checked by screenshot)

anishguduru pushed a commit to anishguduru/deckcraft that referenced this pull request Oct 16, 2026
`write_full` can't know the output size in advance, so its buffer grows by
doubling and the result kept up to as much again unused: 28 % for a 100 MB
save, 99 % for a 5 MB one. The result is often kept for as long as a document
is open. It becomes the working bytes after edits that need a full rewrite
(repaired files, security changes, redaction) through `write_incremental`, and
it backs Save As ▸ optimized and every new document from Create, Combine,
Extract and Split.

`shrink_to_fit` at the end drops the unused capacity. The bytes are the same.
On macOS the shrink happens in place (2 µs for 100 MB, the buffer doesn't
move), and full-save times are unchanged.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
anishguduru pushed a commit to anishguduru/deckcraft that referenced this pull request Oct 16, 2026
…g copied (storytold#552)

* M1: stream data read from a file points into the file instead of being copied

Every stream COS loaded was copied out of the document's bytes
(`data[start..end].to_vec()`) and kept in the object cache until the document
closed. Anything that reads every object therefore left a second copy of all
stream data behind. That includes a full save, which edits needing a rewrite
(repaired files, security changes, redaction) run on every change. A full save
of a 208 MB document left 208 MB cached on it.

`Stream::raw` is now `Bytes`: owned bytes, or a range of a larger shared
buffer. Streams parsed from a document's own bytes are ranges of that buffer,
which the document keeps anyway. Decrypted and newly built streams own their
bytes as before. A stream added to a document from another document's file gets
its own copy of just its bytes (`Document::set`/`add`), so it never keeps
another whole file alive.

Results, measured with an exact heap counter:
- A full save of a 208 MB document leaves 0.2 MB cached instead of 208.2 MB.
- The first full save of a freshly opened document is about twice as fast:
  10 → 5 ms at 40 MB, 38 → 21 ms at 200 MB.

Output is identical: 68 incremental and full saves of five originals,
encrypted ones included, hash the same before and after.

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

* M1: the full-save capacity test (storytold#523) builds its stream from Bytes

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Macro-enabled decks are recognised everywhere a deck is opened (file
dialogs, drag and drop, web picker). The VBA project is kept byte for
byte as an opaque part and never run; saving as .pptm/.potm/.ppsm writes
it back with the macro-enabled content type and vbaProject relationship.
Saving such a deck as .pptx leaves the macros out and warns, as
PowerPoint does.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Harrison-Booth

Copy link
Copy Markdown
Contributor

This now conflicts with main after the module split in #1433 (the files moved into modules; see docs/ path map PR 1468). If you would rather not, I can open a PR that credits you, keeps your commits and shows a git range-diff against this one, so you'll still get credit and have visible work.

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ReviewerA — source-read COMMENT (not an approval)

I read the head of the diff: macro-enabled .pptm, .potm and .ppsm decks open and save. The extension lists gain the three types in the web build and in the desktop dialogs. The macros (a vbaProject.bin part) must never be run, and the PR must say that they are kept as opaque data and written back unchanged, never interpreted or executed; opening a macro-enabled file silently, with no warning, is also something users of PowerPoint expect to be told about. Saving a .pptm that lost its macro part would be a data-loss bug, and saving one with a macro part to a .pptx must drop it with a notice. The content types (application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml) must be correct for PowerPoint to open the result. The format code is in hunks I did not read. I have not run it, and no exact-head CI result exists for this head. Nothing was run.

I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.

Status: waiting_author.

@aiongg aiongg added the missing feature The reference application has it and we do not, or only part of it label Nov 4, 2026

@aiongg aiongg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI-generated review (Opus). Not a maintainer decision.

Small fixes needed (not certain):

Macro-enabled decks now open, keep their VBA project unchanged without running it, and save back as .pptm/.potm/.ppsm with the right content types and relationship. Saving one as .pptx drops the macros and warns.

  • crates/pptx/src/read/mod.rs:484-487 keeps ppt/vbaProject.bin as raw media and nothing interprets it; crates/format/src/lib.rs:74-82 carries it through a .deckcraft save.
  • crates/pptx/src/write/mod.rs:728-733 writes the part, the vbaProject relationship and the application/vnd.ms-office.vbaProject override only for the macro-enabled main content types, so plain .pptx output has no VBA part.
  • crates/ui-egui/src/lib.rs:1275-1281: the download fallback of Save As (web) saves a macro deck as .pptx without the warning that file.save gives; call macros_dropped there and show its text in the status bar.
  • crates/engine/src/cmd/file.rs:557-560: file.export to pptx/potx/ppsx also drops the macros without a warning.
  • The web Save As only offers .pptx or .deckcraft (crates/ui-egui/src/lib.rs:1262), so the browser build has no way to keep the macros on save.
  • docs/file-format-parity.md:22 and docs/parity-checklist.md:60 still say .pptm is not supported; update them along with docs/gaps.md.
  • packaging/windows/deckcraft.wxs:65-70 and packaging/macos/Info.plist.in:89 don't register the macro-enabled extensions for Open With.

Claims checked:

  • verified: .pptm/.potm/.ppsm open from the file dialogs, drag and drop and the web picker (apps/deckcraft/src/main.rs:106-108 add the extensions to the open filters; crates/ui-egui/src/lib.rs:150-152 accept them in is_presentation_name; apps/deckcraft-web/src/web.rs:7 lists them; crates/engine/src/cmd/file.rs…
  • verified: The VBA project is read into Presentation.vba_project as opaque media, kept byte for byte, never run, and survives a .deckcraft save (crates/pptx/src/read/mod.rs:484-487 resolves the vbaProject relationship through media_for (read/mod.rs:47-58), which copies the raw bytes; crates/model/src/lib.rs:9…
  • verified: Saving as .pptm/.potm/.ppsm writes the macro-enabled main content type, the vbaProject relationship and the vbaProject override (crates/pptx/src/write/mod.rs:536-543 picks the main content type per extension; write/mod.rs:728-733 adds RT_VBA and the part through xml_part_binary (crates/pptx/src/opc…
  • contradicted: Saving a macro deck as .pptx/.potx/.ppsx leaves the macros out and warns, in the file.save/file.saveAs result and as a UI message (crates/engine/src/cmd/file.rs:420-424 warns for file.save/saveAs, and crates/pptx/src/write/mod.rs:728 leaves the part out for the plain types. The Save As download fal…
  • verified: docs: the macro half of the template, slide-show and macro variants gap is removed (docs/gaps.md:110-116 now covers only .potx/.ppsx; docs/file-format-parity.md:22 and docs/parity-checklist.md:60 still describe .pptm as unsupported)
  • verified: Typing a .pptm name in Save As saves a macro-enabled file (crates/engine/src/cmd/file.rs:371-376 maps .pptm/.potm/.ppsm to their formats, and save uses format_for_path at file.rs:416)

Recommendation: merge after the fixes above; they may be pushed to this branch.

Reviewed at 1fb6074.

@aiongg aiongg assigned aiongg and unassigned aiongg Nov 5, 2026
@aiongg

aiongg commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Automated message. Not a maintainer decision.

This branch conflicts with main. Could you merge or rebase main into it? The conflict needs a person to resolve.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing feature The reference application has it and we do not, or only part of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants