* #239: open PowerPoint 97-2003 .ppt/.pot/.pps files
New crate deckcraft-ppt (L3), written from the public [MS-CFB], [MS-PPT]
and [MS-ODRAW] Open Specifications: a compound-file reader (ported from
FilmCraft's clean-room reader), the edit chain and persist directory, and
the OfficeArt drawings. Main masters become masters (colours, fonts, text
styles, background, decorations), title masters become layouts; slides
keep their shapes (presets, freeforms, groups, rotation, flips), fills,
lines, shadows, pictures (PNG, JPEG, DIB, TIFF, EMF, WMF), text with the
master styles resolved into it, fields, notes and hidden flags.
Import only: an opened .ppt has no save path, so Save asks for a new
name. A .pps from the system starts the slide show. File dialogs, drag
and drop, the web shell and the macOS, Windows and Linux file
associations offer the three extensions. Tests build .ppt files from
records and sweep hostile input.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* #239: address review: budget picture decoding, read each persist directory once, macOS .pot/.pps types
- Pictures decode lazily, when a shape first uses them, each at most once and all
within a shared 4 GiB budget: many store entries pointing at one deflated blob
can no longer ask for unbounded memory.
- A persist directory named by many edits is read once.
- Info.plist declares com.microsoft.powerpoint.pot and .pps alongside .ppt.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* #239: address review: check the picture budget before copying bitmap data
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* #239: build against current main
- convert.rs: set `flip: None` on imported gradients. `Gradient` gained the field in
ad97533a; None is what an unflipped gradient was before.
- tests.rs: split `imports_a_presentation` into one check per section (title, picture,
group, text box, master) for the workspace `cognitive_complexity` lint (6ddd2fb8).
The assertions are unchanged.
- Cargo.lock: deckcraft-ppt takes the workspace version, 0.15.0.
* #239: keep the picture budget on 32-bit targets
`MAX_TOTAL` was `4 << 30` as a `usize`. On wasm32 that is 2^32, which wraps to 0
without any error, so the web build's picture budget was zero and every .ppt
picture was dropped. Use the address space as the limit there. A compile-time
assertion that the budget holds at least one picture keeps it from happening
again on any target: the CI wasm step (`cargo check`) now fails if it does.
* #239: read past the character fields PowerPoint 2002 and later add
A TextCFException can end with pp10runid (mask bit 20), newEAFontRef (24),
csFontRef (25) and pp11ext (26), after `position`. read_cf stopped at
`position`, so in a StyleTextPropAtom the next run's count and mask were read
from the leftover bytes, and every later run got garbage formatting or the
walk ended. Master text styles go through the same reader. The fields are
read past and not used. The test has a run carrying all four followed by a
bold 18 pt run, which now reads as written.
* #239: convert each listed object once and index notes pages
Nothing stopped a slide list from naming one persist object many times, and
each listing converted its whole drawing again: a 100k-shape slide listed
180k times fits in about 10 MB and makes 1.8e10 shapes. An object is now
listed once across the slide, master and notes lists (PowerPoint never lists
one twice), and a repeat is logged and skipped. Notes pages are looked up
through a map built once, instead of a scan per slide (slides x notes). The
first matching page still wins.
* #239: find formatting runs by binary search
paragraphs() found the run at a position (rposition) and the next run start
(find) by scanning the run starts for every run, break and field, so text
cost grew with chars x runs. The starts are a running sum and never
decrease, so both lookups are now partition_point. Measured in a debug
build, 640k one-character runs (about 6 MB of file): 75 s before, about 2 s
after. The test uses a 20 s bound, like render's pathgrad budget test.
* #239: cap decoded pictures at the .pptx package total
The picture budget was 4 GiB, so a few MB of small deflated metafiles, each
inflating to 64 MiB, could make the import hold 4 GiB. A .pptx package may
inflate to 2 GiB in total (deckcraft-pptx opc MAX_TOTAL), and pictures are
the only part of a .ppt this crate inflates, so use the same 2 GiB. That also
fits a 32-bit usize, which replaces the wasm32 special case. This is a limit
change, so there is no new test: the budget test
(the_store_decodes_lazily_within_a_budget) and the compile-time check that
the budget holds a picture still cover it.
* #239: fall back to the first main master the same way every time
A slide naming a master that doesn't exist fell back to the lowest index in
the masters HashMap. A title master is stored with its main master's index,
so the two tied and the HashMap's random order picked one: the same file got
the "Title Master" layout on some opens and the main master's on others. The
fallback now considers main masters only. The test opens such a deck 30
times; before the fix it took the title master's layout within those opens.
* #239: try the edit scan before calling a file too old
Any Current User token other than the plain or encrypted one, including none
at all from a truncated record, returned TooOld at once. A PowerPoint 97 file
with a damaged Current User stream was reported as "made by PowerPoint 95 or
earlier", and the UserEditAtom scan meant for a missing stream never ran.
[MS-PPT] allows only those two tokens, so an unknown one can't tell a damaged
file from an older format. The scan now runs, and TooOld is returned only when
it finds no edit record behind an unknown token.
* #239: read persist directories within one stream's worth of words
dirs_seen only skips a directory named at the same offset again. Directories
nested inside one another, each named by its own UserEditAtom, were each read
to the end of the stream: MAX_EDITS x the stream. In a debug build, 4095 such
edits over a 64 MiB stream took about 48 s. All directories now share a budget
of stream.len() / 4 words. Real directories are separate records inside the
stream, so they always fit. The hostile case stops in milliseconds and is
reported as damaged.
* #239: check two additions on input-derived sizes
- cfb.rs: the mini sector end `at + MINI_SECTOR_SIZE` was unchecked. On a
32-bit target (wasm32), a sector number near 0x03FF_FFFF puts `at` at the
top of usize, so the add panics in a debug build and wraps in release.
- text.rs: the style-run total `chars.len() as u32 + 1` truncated and could
overflow past u32::MAX characters. It now saturates.
Neither case can be reached in a native test (one needs a 32-bit target, the
other more than 4 GiB of text), so there is no new test. The `+ 1`s in
convert.rs paragraphs() that the review also named are bounded by the text
length and can't overflow, so they are unchanged.
* #239: gaps: name every loss in the .ppt Impact line
The Impact line said old decks "open and read correctly" and named only
motion and links, while the Evidence above it also lists sounds and video,
degraded tables, OLE objects, charts and WordArt, and missing PICT pictures.
(CodeRabbit's open note on docs/gaps.md.)
* #239: ppt: a sector chain that revisits a sector is an error
read_chain stopped at the stream's size, so a FAT loop shorter than the stream returned the
looped sectors again as the stream's bytes. It now tracks visited sectors and fails on a revisit,
and reserves the stream's size (capped at the file length) up front.
a_looping_chain_stops expected the repeated bytes; it now expects the error (eliets2's review).
* #239: ppt: slide shapes inherit from their own master's shapes
Master shape properties were remembered by shape id alone, so a later master (a title master,
or a second main master) that reused a shape id replaced the first master's entry, and slides
inherited fill and line from the wrong master. They are now keyed by master slide id and shape id,
and a shape's hspMaster is looked up in its slide's master, then a title master's main master.
Notes pages have no imported master, so they inherit nothing.
PowerPoint gives shapes file-unique ids, so this takes a damaged or generated file (eliets2's
review).
* #239: ppt: drop the unused fBackground field
RawShape.background was set from the FSP flag but never read: the background shape is the
drawing container's own shape (OfficeArtDgContainer.shape, [MS-ODRAW] 2.2.13), which drawing()
already takes. The comment there now says so (eliets2's review).
* #239: ppt: shadowed text keeps its shadow
TextCFException's shadow bit was read and merged but never reached the run. A shadowed run now
gets a shadow in the colour scheme's shadow colour, at the distance and direction of the app's own
Text Shadow command, with no blur (the record has none). Emboss has no counterpart in the model,
so its field is gone and the loss is listed in the docs (eliets2's review).
* #239: the .pps show-on-open test opens a real 97-2003 file
a_ppsx_from_the_system_starts_the_show saved a .pptx under the name "Old talk.pps", so it went
through the PPTX path and never reached the legacy importer. crates/ppt/tests/fixtures/old-talk.pps
is a one-slide .pps built from records by the ppt tests (rebuilt with DECKCRAFT_WRITE_PPT_FIXTURE=1,
checked on every run), attributed CC0 like the other generated fixtures, and the UI test opens it
(eliets2's review).
* #239: docs: one date, the full list of losses, .pot in the README
From eliets2's review:
- README names .ppt/.pot/.pps and says the import has no writer (Save asks for a new name).
- The parity-checklist row lists the same losses as docs/gaps.md, now with text emboss, and the
checklist gets a status line for the change.
- The ROADMAP progress row, the architecture and file-format change rows and every header carry
one date (2026-11-09), so the progress row sits at the top in order; the ROADMAP gets its
status line.
- docs/gaps.md says why there is no real-deck corpus in the repo (no PowerPoint-made files) and
where one would live.
* #239: ppt: test mini streams, 4096-byte sectors and the DIFAT chain
The compound-file test builder only made version-3 files with 512-byte sectors, no mini stream
and every FAT sector in the header, so read_mini_chain, 4096-byte sectors and the DIFAT chain never
ran. build_with takes the sector shift and the mini stream cutoff, and lists FAT sectors past the
header's 109 in DIFAT sectors; build is build_with(streams, 9, 0), so existing tests see the same
layout. Three tests read streams back through each path (eliets2's review).
* #239: ppt: test every picture kind, two-UID blips and blips inside the FBSE
The blip tests covered PNG, deflated WMF and DIB only. New tests decode JPEG (RGB and CMYK), TIFF
and PNG with one and two UIDs, an uncompressed EMF with each UID count, a metafile over the budget
(compressed or not), and a blip held inside its FBSE rather than in the Pictures stream. All
passed as written (eliets2's review).
* #239: ppt: placeholder text held only in the slide list is imported
A shape's client text box may hold just an OutlineTextRefAtom, with no TextHeaderAtom ([MS-PPT]
OfficeArtClientTextbox): the text lives in the slide list, and that is the usual form for slide
placeholders. read_block returned None without a header, so text_block never reached its
outline fallback and the placeholder came in empty. A block with a reference and no header is
now returned for the caller to follow.
placeholder_text_can_come_from_the_slide_list covers the reference alone (it failed before this
change) and a header with a reference; the test document builder can put outline blocks in the
slide list (streams_with_outline). Found writing the test eliets2's review asked for.
* #239: ppt: test newer edits and the two other encryption signs
doc::read had tests for one edit and the Current User token only. a_later_edit_replaces_a_slide
adds an edit whose persist directory gives the slide a new object; the newer slide is imported and
the master from the older directory is kept. encryption_is_found_in_the_edit_and_the_persist_directory
covers an edit record long enough for encryptSessionPersistIdRef and a CryptSession object named
by a later edit. Both passed as written (eliets2's review).
* #239: ppt: test title masters and slides that follow nothing
No test made a slide of a title master or a slide with the follow-master flags off. The new test
checks that a title master becomes a "Title Master" layout with its own background and shapes
and without the master's shapes, that its slide uses that layout and follows its background, and
that a slide with all three flags off keeps its own background and colour scheme and hides the
master's shapes. It passed as written (eliets2's review).
* #239: ppt: merge boolean properties flag by flag
A boolean property word holds sixteen flags, each with its own fUse bit.
Props::inherit and add_table kept the whole word from the most specific
set, so a placeholder or text box that set only fNoFillHitTest lost the
inherited "not filled" and "no line" and was drawn with a fill and an
outline. Merge those words per flag instead (#1137 review, issue 1).
* #239: ppt: recover a broken edit chain and report lost slides
An edit whose previous-edit offset points back at itself (or anywhere
that isn't an edit) cut the older edits off, and with them the persist
directories holding the slides: such a file opened as an empty deck
with no warning. When the chain doesn't end at offset 0, read every
edit's persist directory in the stream, newest first, filling only what
the chain left unset.
Slides the slide list names but whose objects are still missing are now
returned by deckcraft_ppt::import_checked and reported like a damaged
.pptx: lostSlides, a "(Repaired)" copy and the CLI warning
(#1137 review, issue 3).
* #239: ppt: picture frames, inline picture fills, gradients, footers, numbering
The remaining differences from LibreOffice in the #1137 stress test:
- Picture frames (and OLE frames) that say nothing about fill or line
start with neither, as placeholders and text boxes do, instead of the
drawing defaults' fill.
- A pib or fillBlip held in the property's own complex bytes (fBid) is
decoded within the picture budget: table cells with a picture fill
showed a plain colour.
- Shaded fills put the back colour at fillFocus ([MS-ODRAW]), and the
linear angle follows how LibreOffice writes and reads it (0 degrees
from the top): the linear gradient was reversed, the radial inside out.
- HeadersFooters (the slide's, else the document's) add the date,
footer and slide number placeholders; the master's footer placement,
alignment, size and colour reach every layout.
- Numbering from the document's ___PPT9 tag (OutlineTextProps9, pp9rt
in the runs' fontStyle) turns bulleted paragraphs into numbered ones.
- Wingdings diamonds draw as a diamond, not a dot.
* #239: ppt: read CString records up to their first NUL
Header/footer text and the ___PPT9 tag name were decoded from the whole
CString body. A writer that ends the string with a NUL would put the NUL
into the footer text and make the tag name fail to match, losing the
numbering. Stop at the first NUL, as the font names already do.
---------
Co-authored-by: kiwi4boy <kiwi4boy@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: keithcsqueensu <92232107+keithcsqueensu@users.noreply.github.com>
Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
10 KiB
DeckCraft architecture
Last reviewed: 2026-10-14 · Last updated: 2026-11-11 · Change: trivial (containers and the Opus decoder come from craft-libs; previous: minor,
pptcrate for PowerPoint 97–2003 import; previous: minor, native chart payloads stored in bounded ZIP members; previous: minor, community PR wave 2026-10-14: 320 engine commands, 41 dialogs, themetafilecrate, 1,641 tests; duplicated L2/L5/L6 rows and headers folded; previous: minor, transition frames) · Target: Microsoft PowerPoint for Mac 16.113 (Microsoft 365)
How DeckCraft is built today. The binding rules (layering, everything is a command, thin UI, never
break wasm, never crash) are in AGENTS.md §3–§5; this document describes what
exists. 202k lines of Rust in 24 crates, 3 apps and xtask; 1,641 #[test] functions
(cargo xtask stats counts them per crate).
Layers
cargo xtask layers enforces that a crate depends only on lower layers (the table in
xtask/src/layers.rs, which is authoritative; AGENTS.md §4 gives the simplified picture), and that
nothing below L6 uses egui, eframe, winit or rfd.
| Layer | Crates | What they do |
|---|---|---|
| L0 | geom, color |
EMU/pt units, transforms, ~180 preset shape generators re-derived from ECMA-376, adjust handles, hit testing; RGB/HSL and DrawingML colour transforms |
| L1 | model, fonts |
Presentation, masters, layouts, slides, shapes, text, themes, tables, charts, transitions, animations, placeholder inheritance (resolve); font database (craft-fonts + system) with metric-compatible substitutes for Office fonts (Carlito for Calibri, Caladea for Cambria, Liberation for Arial/Times) |
| L2 | text, anim, format, media |
Shaping (HarfRust), UAX #9 bidi, UAX #14 line breaking, autofit, caret hit testing; per-shape animation state over time, the show state machine, transition frame layouts, Morph matching; .deckcraft (zip + JSON + media) and outline text; media probing, decoding, mixer and clock (MP4/MOV, MKV/WebM and Ogg demuxers from craft-media and the Opus decoder from craft-audio, the H.264, HEVC, VP9 and AV1 decoders from craft-video, all in craft-libs) |
| L3 | render, pptx, ppt |
vello_cpu raster of slides, masters and layouts (fills, outlines, effects, pictures, tables, charts, Morph frames); PPTX import/export from ECMA-376; PowerPoint 97–2003 import from [MS-PPT], [MS-ODRAW] and [MS-CFB] |
| L4 | pdf |
App-owned export layout and rendering through the shared craft-pdf writer |
| L5 | engine |
Sessions, documents, selection, undo history on shared slide snapshots, the command registry (320 commands in cmd/*), pointer tools, keys, AutoRecover, the panic guard (guard.rs) |
| L6 | ui-egui, mcp |
The PowerPoint-style interface (ribbon with 10 tabs + contextual tabs, canvas, thumbnails, panes, 41 dialogs, show and presenter windows, the JSON control channel); the MCP server (JSON-RPC 2.0 over stdio), headless or connected to a running app |
| apps | deckcraft (desktop: eframe/wgpu, cpal audio, logging), deckcraft-cli (run, render, convert, mcp, app), deckcraft-web (trunk; WebGPU with WebGL2 fallback), xtask |
Exempt from layering |
The media codecs and containers are clean-room pure Rust, 59k lines, shared in spirit with FilmCraft.
Data model
A Presentation holds a theme set, slide masters with their layouts, slides, sections, custom
shows, comments, media and document properties. Shapes are a tree (ShapeKind: preset or custom
geometry, picture, table, chart, group, connector, ink, media, SmartArt-as-group, and Opaque for
anything read from PPTX that DeckCraft doesn't model: its XML is kept and written back). Text
bodies hold paragraphs of runs with DrawingML properties; formatting resolves slide → layout →
master → theme at render time. Transitions live on slides; animations are the flat ordered list the
Animation Pane shows, rebuilt into PowerPoint's timing tree on save.
Commands and frontends
Every user-visible action is a CommandSpec (id, label, ribbon/menu place, shortcut, params doc,
enabled, run) in crates/engine/src/cmd/*. The UI, deckcraft-cli run, the JSON control
channel (deckcraft --control PORT, control-protocol.md) and MCP
(mcp.md) all dispatch through Session::execute, so they behave identically.
Programmatic calls never open dialogs. Pointer gestures go through Session::pointer, keys through
Session::key.
Rendering and the show
The renderer draws a slide to an RGBA pixmap on the CPU; the UI uploads it as an egui texture.
Transitions are layers of textured quads over the old and new slide images, or over their
backgrounds and contents rendered apart (Dynamic Content), from anim::transition_frame: 3-D
effects project cards through a perspective camera and anim::layer_mesh subdivides them so
textures stay straight; soft edges are per-corner opacities. The show renders the slides once per
transition and only composites cached textures each frame; render::composite_transition is the
CPU twin used by deckcraft-cli render-transition and the tests. The show window and the presenter view are egui viewports; animation state per shape
comes from anim::timeline each frame. Animations ▸ Preview plays that same state on the editor
canvas for the current slide, then draws the slide at rest. PDF export renders each slide at print resolution and
overlays an invisible real-text layer with embedded font subsets.
File I/O
- PPTX (
crates/pptx): lenient reader (unknown parts skipped, malformed parts logged and ignored, sizes and depths bounded, zip bombs capped), writer that PowerPoint opens without repair. Unknown elements round-trip throughOpaqueandraw_extfields. - PowerPoint 97–2003 (
crates/ppt, import only): a compound-file reader (ported from FilmCraft), the persist directory and edit chain, and the OfficeArt drawings. Each main master becomes a master with the standard layouts, a title master a layout of it; text carries its formatting with the master's text styles resolved into it, and group children are placed in slide points. Every read is checked and every walk bounded. A.pptopens without a save path. - Native (
crates/format): zip withmimetype,presentation.json,media/<id>andchart-parts/<index>. Chart relationships and payload references stay in the manifest; binary chart parts use bounded ZIP reads and share the media byte/item budgets. Earlier inline chart bytes still load and migrate on save;.slidecraftfiles from before the rename still open. - Formats and their gaps: file-format-parity.md.
Quality gates
cargo xtask ci: rustfmt check, clippy -D warnings, tests, layering, asset attribution
(cargo xtask assets), wasm32 check. CI runs it on Ubuntu for every PR and push to main;
macOS is built and tested by the release workflow only. Releases (pushes to release) build signed
macOS, Windows, Linux, FreeBSD and web artifacts.
Revision history
| Date | Change | Summary |
|---|---|---|
| 2026-11-12 | trivial | The metafile crate is gone: render reads EMF/WMF with craft-metafile from craft-libs |
| 2026-11-12 | trivial | The bitstream, h264, hevc, vp9 and av1 crates are gone: media decodes video with craft-video from craft-libs |
| 2026-11-11 | trivial | The opus, ogg, isobmff and matroska crates are gone: media uses craft-audio and craft-media from craft-libs |
| 2026-11-09 | minor | ppt crate (L3): PowerPoint 97–2003 .ppt/.pot/.pps import |
| 2026-10-18 | minor | Native chart payloads use referenced ZIP members and share media byte/item limits; old inline sidecars remain readable. Synthetic tests cover multi-megabyte layout, all shape owners, shared budgets, missing/corrupt members and invalid references. Scores and milestone scope unchanged |
| 2026-10-14 | minor | Community PR wave folded: one L2/L5/L6 row each; command registry 320 (cmd! registrations in cmd/*), 41 dialogs (titled in dialogs.rs), 202k lines, 24 crates (metafile added at L0), 1,641 tests. The per-PR rows below give the counts each PR saw on its own branch |
| 2026-10-14 | minor | Size and Position dialog (shape.sizePosition): position, size, rotation, scale and lock aspect in one undo step. 227 commands, 28 dialogs |
| 2026-10-14 | trivial | Command registry: 228 (comment.next, comment.prev) |
| 2026-10-14 | trivial | Photo Album dialog and insert.photoAlbum (227 commands, 28 dialogs) |
| 2026-10-14 | trivial | Edit Photo Album (insert.photoAlbumEdit) reopens the Photo Album dialog and re-flows those slides (228 commands, 28 dialogs) |
| 2026-10-14 | minor | Create New Theme Colors (design.colors with no params); command count stays 226 |
| 2026-10-14 | minor | Create New Theme Fonts (design.fonts with no params); command count stays 226 |
| 2026-10-14 | minor | Insert › Date and Time dialog (insert.dateTime with no keys). 28 dialogs; command count stays 226 |
| 2026-10-14 | minor | Command registry is 227 (design.effects). Dialogs stay 27. The test-count line stays 504 |
| 2026-10-14 | minor | Command registry counted at 236, including master.preserve and master.placeholders. Dialogs stay 27. The test-count line stays 504. The menu measurement and the d556ff9 snapshot still count 226 |
| 2026-10-13 | trivial | Animation preview draws the current slide's timeline on the editor canvas |
| 2026-10-14 | minor | Paragraph and Tabs dialogs; command registry 229; 29 dialogs |
| 2026-10-14 | minor | Font dialog; command registry 227; 28 dialogs |
| 2026-10-13 | minor | Transitions: perspective meshes, background/content parts, CPU compositor |
| 2026-10-10 | major | Created from the code on main (d556ff9) and AGENTS.md §4 |
The PDF writer dependency enables only write. Krilla handles serialization and simple-text
shaping for notes and footers; slide layout, rasterization, font selection, text mapping,
links and outlines remain app-owned. PDF embedding and all Hayro production dependencies
are disabled. Native builds enable parallel compression on the same pinned Krilla backend;
WASM keeps it disabled. Generated-PDF assertions use a std-only parser as a development dependency.