Compare commits

...
Author SHA1 Message Date
Dylan M. Taylor 9b50c0703d docs: prefer shared Craft libraries for reusable features 2026-11-16 06:29:14 -05:00
FredApps 3b6f9e7cb8 Merge pull request #2176 from storytold/onee/792-pptx-shared-cfb
#792: read password-protected decks with craft-cfb and drop the local PNG encoder
2026-11-16 11:03:41 +01:00
FredApps 5f58c3c208 #792: read password-protected decks with craft-cfb and drop the local PNG encoder
DeckCraft's pptx crate carried a copy of GridCraft's CFB directory walk to tell an
encrypted package from other compound files. It now asks the shared craft-cfb
(has_entry_named, same UTF-16 fallback for damaged directories, directory entries
capped at 4096 as before). The placeholder for missing picture media keeps its
exact bytes, written as a constant instead of through a hand-rolled CRC/Adler/PNG
encoder.

Part of storytold/craft-libs#778 and storytold/craft-libs#792.
2026-11-16 10:52:29 +01:00
Zinadin Zidan 596ec54b59 Slide show: play a slide's animations again when the show advances to it (#2090) (#2126)
ShowState remembers what was played on each visited slide, so a slide
reached again by a link or by Back looks as it was left. Going forward
used the same path: next() entered a visited slide at the step it was
left at, so after Back and forward again its entrance effects did not
play and the shapes were already in place.

next() now forgets the slide's run before entering it, when it moves
to the next slide and when a looping show comes round to the first
one. The slide starts over: its automatic first step plays, an On
Click build starts at its first step, and its triggered animations
start over. Back, links, Go to slide and Return to Zoom are unchanged.
2026-11-16 10:22:24 +01:00
scks1 9e975b0049 engine: arrange.align and arrange.distribute refuse values they do not name (#1974)
* engine: arrange.align and arrange.distribute refuse values they do not name

arrange.align took an `edge` it did not know as a no-op that still
reported its shapes as edited, aligned left when `edge` was left out
(the spec does not mark it optional), and read any `to` other than
exactly "slide" as the selection. arrange.distribute distributed
vertically for any `dir` starting with "v" and horizontally for any
other, and also read any `to` other than "slide" as the selection.

`edge` must now be left, center, right, top, middle or bottom, `to`
slide or selection, and `dir` horizontal or vertical. Anything else, or
a missing `edge`, is refused with the accepted values and nothing moves.
A missing `to` or `dir` keeps its default.

Test: align_and_distribute_refuse_values_they_do_not_name.

* engine: arrange.align and arrange.distribute refuse a dir or to that is not a string

`align_to` and `distribute` read `to` and `dir` through `str_param`, which
returns None for a value that is present but not a string, the same as for a
missing one. So `{"dir": 123}` distributed horizontally, and
`{"edge": "left", "to": false}` aligned to each command's default reference,
moving the selected shapes instead of failing.

Both now match on `p.get(..).map(Value::as_str)`: a missing field keeps its
default (horizontal for `dir`, each command's own rule for `to`), the named
strings work as before, and anything else, null included, is refused with the
accepted values.

The new test `align_and_distribute_refuse_dir_and_to_that_are_not_strings`
sends null, 123, false, {} and [] as `dir` to arrange.distribute and as `to`
to both commands, in a fresh three-shape session each time, and checks the
error, the revision and every shape's box.
2026-11-16 07:46:28 +00:00
FredApps 4c844f9332 Merge pull request #2165 from storytold/extract/shared-opc-names
Reuse shared OPC part-name primitives
2026-11-16 07:57:56 +01:00
14 changed files with 241 additions and 157 deletions
+4
View File
@@ -239,3 +239,7 @@ the `ROADMAP.md` progress log, and update each touched doc's status line and rev
- Workflows in `.github/workflows/` call the shared workflows in [`storytold/craft-common-actions`](https://github.com/storytold/craft-common-actions) at `@main`, with their inputs and secrets. No other jobs: if no shared workflow does what's needed, it doesn't go here.
- Don't add or change CI in a feature or fix PR. If the existing workflows can't build or test a change, link an existing craft-common-actions issue or PR, or open a new issue, or a PR only for a small fix that is safe for every app and does not increase CI time.
- Some workflow files here still run their own jobs. Don't add to them. Moving a job into craft-common-actions is its own task, never part of another PR, and the job stays here until a shared workflow runs it.
## Shared libraries
Before adding or changing file-format, codec, protocol, or reusable UI code, check `storytold/craft-libs` and its open PRs first; reuse or extend the shared library rather than duplicating it locally, keep app-specific policy and model mapping in the app, and preserve behavior, security/resource limits, attribution, and regression coverage during cutovers.
Generated
+6
View File
@@ -853,6 +853,11 @@ dependencies = [
"thiserror 2.0.21",
]
[[package]]
name = "craft-cfb"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ea24422ae9859dc5da398d0462bc87f8e02e0d10#ea24422ae9859dc5da398d0462bc87f8e02e0d10"
[[package]]
name = "craft-codepage"
version = "0.1.0"
@@ -1301,6 +1306,7 @@ dependencies = [
name = "deckcraft-pptx"
version = "0.19.0"
dependencies = [
"craft-cfb",
"craft-opc",
"craft-xml",
"deckcraft-color",
+2
View File
@@ -13,6 +13,8 @@ repository = "https://github.com/storytold/deckcraft"
[workspace.dependencies]
# OPC part-name primitives; relationship admission stays app-local.
craft-opc = { git = "https://github.com/storytold/craft-libs", rev = "ea24422ae9859dc5da398d0462bc87f8e02e0d10", version = "0.1.0" }
# Compound File Binary directory reads (password-protected deck detection).
craft-cfb = { git = "https://github.com/storytold/craft-libs", rev = "ea24422ae9859dc5da398d0462bc87f8e02e0d10", version = "0.1.0" }
# XML writer primitives; parser admission and OOXML policy stay app-local.
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "ea24422ae9859dc5da398d0462bc87f8e02e0d10", version = "0.1.0" }
# internal
+3 -1
View File
@@ -2,7 +2,7 @@
**Stage: alpha** · next: beta, ~20 points and ~120–210 h away
> **Last reviewed:** 2026-11-04 · **Last updated:** 2026-11-11 · **Change:** trivial (slide-list entries with missing relationships are reported as lost slides and open as repaired copies; the Opus decoder and the Ogg, MP4 and Matroska demuxers come from craft-libs; parity scores unchanged) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365)
> **Last reviewed:** 2026-11-04 · **Last updated:** 2026-11-14 · **Change:** trivial (a slide the show advances to again plays its animations again, #2090; slide-list entries with missing relationships are reported as lost slides and open as repaired copies; the Opus decoder and the Ogg, MP4 and Matroska demuxers come from craft-libs; parity scores unchanged) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365)
> **Last reviewed:** 2026-11-02 · **Last updated:** 2026-11-03 · **Change:** trivial (progress log: web `?host=parent` bridge opens and saves through a same-origin framing page; scores unchanged) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365)
> **Last reviewed:** 2026-11-02 · **Last updated:** 2026-11-03 · **Change:** trivial (community PR wave 10: PPTX and native saves keep table cell centred anchoring, text overflow, compatible line spacing, normalised character height, Thai distributed alignment, RTL table direction, alternate run language and reflection transforms; imported effects placed by parent time-node delays; Reuse Slides fits the destination size and brings custom table styles; deleted slides leave custom shows; merged shapes drop their animations; Compress Pictures measures grouped pictures at displayed size; parity scores unchanged) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365)
@@ -154,6 +154,7 @@ app's JSON control channel (`deckcraft --control PORT`).
| Date | What landed |
|---|---|
| 2026-11-14 | Slide show: a slide the show advances to again (click, →, Space, automatic advance or a loop) starts over, so its animations play again, as in PowerPoint. Back and links still show it as it was left (#2090) |
| 2026-11-11 | Media: the Opus decoder and the Ogg, MP4/MOV and Matroska demuxers are craft-audio and craft-media from craft-libs; DeckCraft's own copies and re-export crates are removed |
| 2026-11-07 | PPTX slide-list entries with missing relationships are reported in lostSlides instead of silently omitted. The engine opens the partial deck as a repaired copy with no original save path. Slide lists over 10,000 entries are explicitly refused before a partial load; exactly 10,000 remain supported. Synthetic 13-slide regression; does not establish the cause of #1910's field report. |
| 2026-11-04 | Ogg Opus recovery keeps trailing packets without granules in the total duration, matching their recovered positions; valid end trimming stays covered |
@@ -342,6 +343,7 @@ app's JSON control channel (`deckcraft --control PORT`).
| Date | Change | Summary |
|---|---|---|
| 2026-11-14 | trivial | Progress log: a slide the show advances to again plays its animations again (#2090); parity scores unchanged |
| 2026-11-11 | trivial | Opus and container code moved to craft-libs crates; parity scores unchanged |
| 2026-11-04 | trivial | Ogg Opus recovery duration includes its recovered tail; parity scores unchanged |
| 2026-11-02 | trivial | Progress log: run alternate-language metadata round-trips through native and PPTX formats; product parity scores unchanged |
+2 -1
View File
@@ -9,7 +9,8 @@
//! - a shape with a link and a triggered animation follows the link at once. The animation's clock
//! runs only while its slide is shown, so it goes on where it stopped when the show returns;
//! - with "advance on click" off a click never leaves the slide, but it still plays animation steps;
//! - a slide the show returns to (link or arrow keys) looks as it was left.
//! - a slide the show returns to by a link or by going back looks as it was left; going forward
//! to a slide starts it over (#2090).
use deckcraft_model::text::Action;
use deckcraft_model::{Presentation, ShapeId};
+12 -3
View File
@@ -47,7 +47,8 @@ pub enum LinkJump {
/// Where a slide show is. Besides the current position it remembers what was played on every slide
/// the show has visited (main steps, triggered sequences), so a slide reached again by a link or
/// the arrow keys looks the way it was left, as in PowerPoint.
/// by going back looks the way it was left, as in PowerPoint. Going forward to a slide starts it
/// over, so its animations play again (#2090).
#[derive(Clone, Debug, PartialEq, Default)]
pub struct ShowState {
/// Index into `presentation.slides`.
@@ -226,6 +227,14 @@ impl ShowState {
}
}
/// Advance to slide `i`: it starts over, as if the show had not been there, so its
/// animations play again (#2090). Links and Back keep a slide as it was left.
fn enter_forward(&mut self, pres: &Presentation, i: usize) {
self.leave(pres);
self.runs.remove(&i);
self.enter(pres, i);
}
fn next_index(&self, pres: &Presentation) -> Option<usize> {
let order = self.visit(pres);
match order.iter().position(|&i| i == self.slide) {
@@ -271,12 +280,12 @@ impl ShowState {
}
match self.next_index(pres) {
Some(i) => {
self.enter(pres, i);
self.enter_forward(pres, i);
ShowAction::Slide(i)
}
None if looping(pres) => match self.visit(pres).first() {
Some(&i) => {
self.enter(pres, i);
self.enter_forward(pres, i);
ShowAction::Slide(i)
}
None => {
+52
View File
@@ -876,6 +876,8 @@ fn show_back_leaves_a_slide_whose_first_step_is_automatic() {
// While the automatic step plays.
assert_eq!(s.prev(&p), ShowAction::Slide(0), "{start:?}");
assert_eq!(s.next(&p), ShowAction::Slide(1));
// Going forward again plays the automatic step again (#2090).
assert_eq!(s.step_done(&p), ShowAction::FinishStep(0), "{start:?}");
// Once it has played, the click step is undone first, then Back leaves the slide.
assert_eq!(s.next(&p), ShowAction::PlayStep(1));
assert_eq!(s.step_done(&p), ShowAction::FinishStep(1));
@@ -885,6 +887,56 @@ fn show_back_leaves_a_slide_whose_first_step_is_automatic() {
}
}
#[test]
fn a_slide_entered_going_forward_again_plays_its_animations_again() {
// #2090: the show remembered slide 2 as fully built, so its entrance effects did not play the
// second time the show advanced to it.
for start in [AnimStart::WithPrevious, AnimStart::AfterPrevious] {
let mut p = pres(3);
Arc::make_mut(&mut p.slides[1]).shapes = vec![shape(1, "A")];
Arc::make_mut(&mut p.slides[1]).animations = vec![anim(1, AnimClass::Entrance, "fade", start)];
let mut s = ShowState::new(&p);
assert_eq!(s.next(&p), ShowAction::Slide(1));
assert_eq!(s.step_done(&p), ShowAction::FinishStep(0));
assert_eq!(s.prev(&p), ShowAction::Slide(0), "{start:?}");
assert_eq!(s.next(&p), ShowAction::Slide(1));
assert_eq!((s.step, s.playing), (0, true), "{start:?}: the slide starts again");
let a = ShowState::timeline(&p, 1).state(ShapeId(1), None, s.step, 0.0);
assert!(!a.visible || a.opacity < 0.01, "{start:?}: the shape has not come in yet");
// Back from the next slide still shows it as it was left.
assert_eq!(s.step_done(&p), ShowAction::FinishStep(0));
assert_eq!(s.next(&p), ShowAction::Slide(2));
assert_eq!(s.prev(&p), ShowAction::Slide(1));
assert_eq!((s.step, s.playing), (1, false), "{start:?}");
}
// An On Click build left by a jump starts again when the show advances to the slide.
let mut p = pres(2);
Arc::make_mut(&mut p.slides[1]).shapes = vec![shape(1, "A")];
Arc::make_mut(&mut p.slides[1]).animations = vec![anim(1, AnimClass::Entrance, "fade", AnimStart::OnClick)];
let mut s = ShowState::new(&p);
assert_eq!(s.next(&p), ShowAction::Slide(1));
assert_eq!(s.next(&p), ShowAction::PlayStep(0));
assert_eq!(s.step_done(&p), ShowAction::FinishStep(0));
assert_eq!(s.goto(&p, 0), ShowAction::Slide(0));
assert_eq!(s.next(&p), ShowAction::Slide(1));
assert_eq!((s.step, s.playing), (0, false));
}
#[test]
fn a_looping_show_plays_the_first_slide_again() {
// #2090: a kiosk or loop-until-Esc show comes round to the first slide going forward.
let mut p = pres(2);
p.show.loop_until_esc = true;
Arc::make_mut(&mut p.slides[0]).shapes = vec![shape(1, "A")];
Arc::make_mut(&mut p.slides[0]).animations = vec![anim(1, AnimClass::Entrance, "fade", AnimStart::WithPrevious)];
let mut s = ShowState::new(&p);
assert!(s.playing);
assert_eq!(s.step_done(&p), ShowAction::FinishStep(0));
assert_eq!(s.next(&p), ShowAction::Slide(1));
assert_eq!(s.next(&p), ShowAction::Slide(0));
assert_eq!((s.step, s.playing), (0, true));
}
#[test]
fn show_auto_advance() {
let mut p = pres(2);
+17
View File
@@ -325,6 +325,23 @@ fn a_slide_comes_back_the_way_it_was_left() {
assert_eq!(s.step, ShowState::steps(&pres, 1));
}
#[test]
fn a_slide_entered_going_forward_again_starts_over() {
// #2090: the show advances to slide 2 a second time; its triggered animation is undone too.
let s1 = slide(1000, vec![], vec![], true);
let s2 = slide(1001, vec![shape(4)], vec![exit_on_click(4, 4, 0)], true);
let pres = Presentation { slides: vec![s1, s2], ..Default::default() };
let mut r = Run::new(pres, vec![vec![], vec![hit(4, None)]]);
assert_eq!(r.show.next(&r.pres), ShowAction::Slide(1));
assert_eq!(r.click(), Click::Animated);
assert!(!r.visible(ShapeId(4)));
assert_eq!(r.show.prev(&r.pres), ShowAction::Slide(0));
assert_eq!(r.show.prev(&r.pres), ShowAction::None);
assert_eq!(r.show.next(&r.pres), ShowAction::Slide(1));
assert!(r.visible(ShapeId(4)), "the shape is back");
assert!(r.show.trigger_plays().is_empty());
}
#[test]
fn a_playing_main_step_is_finished_when_the_show_leaves() {
let a = Animation { shape: ShapeId(1), class: AnimClass::Entrance, effect: "fade".into(), duration_ms: 500, ..Default::default() };
+24 -8
View File
@@ -417,17 +417,28 @@ fn regroup(s: &mut Session, _p: &Value) -> Result<Value> {
}
}
/// `to` of arrange.align and arrange.distribute: `Some(true)` for the slide, `Some(false)` for the
/// selection, `None` when it is left out. Any other value, a non-string included, is refused.
fn align_to(cmd: &str, p: &Value) -> Result<Option<bool>> {
match p.get("to").map(Value::as_str) {
None => Ok(None),
Some(Some("slide")) => Ok(Some(true)),
Some(Some("selection")) => Ok(Some(false)),
Some(_) => Err(bad(cmd, "`to` must be slide or selection")),
}
}
fn align(s: &mut Session, p: &Value) -> Result<Value> {
let edge = str_param(p, "edge").unwrap_or("left").to_string();
let edge = match str_param(p, "edge") {
Some(e @ ("left" | "center" | "right" | "top" | "middle" | "bottom")) => e.to_string(),
_ => return Err(bad("arrange.align", "`edge` must be left, center, right, top, middle or bottom")),
};
let to = align_to("arrange.align", p)?;
let ids = targets(s, p)?;
let st = s.doc()?;
let size = st.doc.slide_size;
let boxes: Vec<(ShapeId, Xfrm)> = ids.iter().filter_map(|id| st.shape(*id).map(|x| (*id, xfrm_of(&st.doc, &st.selection, x)))).collect();
let to_slide = match str_param(p, "to") {
Some("slide") => true,
Some(_) => false,
None => boxes.len() < 2,
};
let to_slide = to.unwrap_or(boxes.len() < 2);
let reference = if to_slide {
Rect::new(0.0, 0.0, size.width, size.height)
} else {
@@ -453,13 +464,18 @@ fn align(s: &mut Session, p: &Value) -> Result<Value> {
}
fn distribute(s: &mut Session, p: &Value) -> Result<Value> {
let horiz = !str_param(p, "dir").unwrap_or("horizontal").starts_with('v');
let horiz = match p.get("dir").map(Value::as_str) {
None | Some(Some("horizontal")) => true,
Some(Some("vertical")) => false,
Some(_) => return Err(bad("arrange.distribute", "`dir` must be horizontal or vertical")),
};
let to = align_to("arrange.distribute", p)?;
let ids = targets(s, p)?;
let st = s.doc()?;
let size = st.doc.slide_size;
let mut boxes: Vec<(ShapeId, Rect)> =
ids.iter().filter_map(|id| st.shape(*id).map(|x| (*id, xfrm_of(&st.doc, &st.selection, x).bounds()))).collect();
let to_slide = str_param(p, "to") == Some("slide") || boxes.len() < 3;
let to_slide = to == Some(true) || boxes.len() < 3;
if boxes.is_empty() {
return ok();
}
+76
View File
@@ -1184,6 +1184,82 @@ fn distribute_wide_middle_stays_in_selection_bounds() {
assert!(xs.iter().all(|x| (*x - [0.0, 10.0, 110.0][xs.iter().position(|y| y == x).unwrap()]).abs() < 1e-6), "{xs:?}");
}
/// An `edge`, `dir` or `to` that the commands do not name, or no `edge` at all, is refused with
/// the accepted values. Before, such a call reported its shapes as edited and moved nothing,
/// aligned to the selection, or fell back to the left edge or to horizontal.
#[test]
fn align_and_distribute_refuse_values_they_do_not_name() {
let mut s = session();
let mut ids = vec![];
for (x, y) in [(10.0, 10.0), (200.0, 50.0), (500.0, 200.0)] {
ids.push(s.execute("shape.insert", &json!({"preset": "rect", "rect": [x, y, 40, 40]})).unwrap()["id"].as_u64().unwrap());
}
s.execute("edit.select", &json!({"ids": ids})).unwrap();
let before = s.doc().unwrap().revision;
let edges = "`edge` must be left, center, right, top, middle or bottom";
let dirs = "`dir` must be horizontal or vertical";
let tos = "`to` must be slide or selection";
for (cmd, params, want) in [
("arrange.align", json!({"edge": "centre"}), edges),
("arrange.align", json!({"edge": "Left"}), edges),
("arrange.align", json!({"edge": "hcenter"}), edges),
("arrange.align", json!({}), edges),
("arrange.align", json!({"ids": [ids[0]], "edge": "left", "to": "Slide"}), tos),
("arrange.distribute", json!({"dir": "Vertical"}), dirs),
("arrange.distribute", json!({"dir": "columns"}), dirs),
("arrange.distribute", json!({"dir": "v"}), dirs),
("arrange.distribute", json!({"dir": "vertical", "to": "page"}), tos),
] {
let err = s.execute(cmd, &params).unwrap_err().to_string();
assert!(err.contains(want), "{cmd} {params}: {err}");
}
assert_eq!(s.doc().unwrap().revision, before, "a refused call leaves the slide as it was");
let pos = |s: &mut Session, id: u64, k: &str| s.execute("shape.inspect", &json!({"id": id})).unwrap()["box"][k].as_f64().unwrap();
s.execute("arrange.align", &json!({"ids": [ids[1]], "edge": "left", "to": "slide"})).unwrap();
assert!(pos(&mut s, ids[1], "x").abs() < 1e-6);
// Within the selection's span, 10..240: 120 pt of shapes leaves two 55 pt gaps.
s.execute("arrange.distribute", &json!({"ids": ids, "dir": "vertical", "to": "selection"})).unwrap();
assert!((pos(&mut s, ids[1], "y") - 105.0).abs() < 1e-6);
}
/// A `dir` or `to` that is present but is not a string (null, a number, a bool, an object or an
/// array) is refused with the accepted values, and the shapes and the revision stay as they were.
/// Before, such a value counted as left out: `dir` meant horizontal and `to` each command's
/// default, so the call moved the selected shapes.
#[test]
fn align_and_distribute_refuse_dir_and_to_that_are_not_strings() {
let dirs = "`dir` must be horizontal or vertical";
let tos = "`to` must be slide or selection";
let mut failures = vec![];
for v in [json!(null), json!(123), json!(false), json!({}), json!([])] {
for (cmd, params, want) in [
("arrange.distribute", json!({"dir": v.clone()}), dirs),
("arrange.distribute", json!({"dir": "horizontal", "to": v.clone()}), tos),
("arrange.align", json!({"edge": "left", "to": v.clone()}), tos),
] {
let mut s = session();
let mut ids = vec![];
for (x, y) in [(10.0, 10.0), (200.0, 50.0), (500.0, 200.0)] {
ids.push(s.execute("shape.insert", &json!({"preset": "rect", "rect": [x, y, 40, 40]})).unwrap()["id"].as_u64().unwrap());
}
s.execute("edit.select", &json!({"ids": ids})).unwrap();
let boxes = |s: &mut Session| -> Vec<Value> {
ids.iter().map(|id| s.execute("shape.inspect", &json!({"id": id})).unwrap()["box"].clone()).collect()
};
let (rev, before) = (s.doc().unwrap().revision, boxes(&mut s));
match s.execute(cmd, &params) {
Ok(_) => failures.push(format!("{cmd} {params}: accepted")),
Err(e) if !e.to_string().contains(want) => failures.push(format!("{cmd} {params}: {e}")),
Err(_) => {}
}
if s.doc().unwrap().revision != rev || boxes(&mut s) != before {
failures.push(format!("{cmd} {params}: moved the shapes"));
}
}
}
assert!(failures.is_empty(), "{failures:#?}");
}
#[test]
fn pointer_draw_move_resize() {
let mut s = session();
+1
View File
@@ -11,6 +11,7 @@ workspace = true
[dependencies]
craft-opc.workspace = true
craft-xml.workspace = true
craft-cfb.workspace = true
deckcraft-model = { workspace = true }
deckcraft-geom = { workspace = true }
deckcraft-color = { workspace = true }
+16 -94
View File
@@ -1,103 +1,24 @@
//! Just enough of the Compound File Binary (CFB/OLE2) container to tell a password-protected
//! presentation apart: PowerPoint wraps an encrypted `.pptx` in a CFB holding `EncryptionInfo`
//! and `EncryptedPackage` streams (ECMA-376 / [MS-OFFCRYPTO]) instead of a zip. Every read is
//! bounds-checked and every loop bounded. Copied from GridCraft's `crates/xlsx/src/cfb.rs`.
/// The CFB signature at the start of the file.
const SIGNATURE: [u8; 8] = [0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1];
const END_OF_CHAIN: u32 = 0xFFFF_FFFE;
/// Sector ids at or above this are markers (free, end of chain, FAT/DIFAT sector), not sectors.
const MAX_REG_SECT: u32 = 0xFFFF_FFFA;
/// Directory sectors followed at most (4096 entries with 512-byte sectors).
const MAX_DIR_SECTORS: usize = 1024;
/// DIFAT sectors followed at most.
const MAX_DIFAT_SECTORS: usize = 1024;
//! Password-protected presentations. PowerPoint wraps an encrypted `.pptx` in a Compound File
//! Binary (CFB/OLE2) container holding `EncryptionInfo` and `EncryptedPackage` streams
//! (ECMA-376 / [MS-OFFCRYPTO]) instead of a zip. The container's directory is read by the shared
//! `craft-cfb` crate, which bounds every chain and falls back to a UTF-16 name search when a
//! damaged file's directory cannot be followed.
/// Stream names that mark an encrypted (password-protected) OOXML package.
const ENCRYPTED_STREAMS: [&str; 2] = ["EncryptedPackage", "EncryptionInfo"];
fn u16_at(b: &[u8], at: usize) -> Option<u16> {
let s = b.get(at..at.checked_add(2)?)?;
Some(u16::from_le_bytes([*s.first()?, *s.get(1)?]))
/// Directory entries read at most: 1024 directory sectors of 512 bytes, as before the move to
/// `craft-cfb`, so a hostile directory chain stays cheap.
const MAX_DIR_ENTRIES: usize = 4096;
fn limits() -> craft_cfb::Limits {
craft_cfb::Limits { max_dir_entries: MAX_DIR_ENTRIES, ..craft_cfb::Limits::default() }
}
fn u32_at(b: &[u8], at: usize) -> Option<u32> {
let s = b.get(at..at.checked_add(4)?)?;
Some(u32::from_le_bytes([*s.first()?, *s.get(1)?, *s.get(2)?, *s.get(3)?]))
}
/// Whether `bytes` is a compound file holding an encryption stream. Walks the directory through
/// the FAT; when the structure can't be followed (truncated or malformed), falls back to scanning
/// the bytes for the UTF-16LE stream names.
/// Whether `bytes` is a compound file holding an encryption stream.
pub(crate) fn is_encrypted(bytes: &[u8]) -> bool {
if !bytes.starts_with(&SIGNATURE) {
return false;
}
match directory_names(bytes) {
Some(names) => names.iter().any(|n| ENCRYPTED_STREAMS.iter().any(|e| n.eq_ignore_ascii_case(e))),
None => ENCRYPTED_STREAMS.iter().any(|e| contains_utf16(bytes, e)),
}
}
fn contains_utf16(hay: &[u8], needle: &str) -> bool {
let n: Vec<u8> = needle.encode_utf16().flat_map(u16::to_le_bytes).collect();
!n.is_empty() && hay.windows(n.len()).any(|w| w == n.as_slice())
}
/// Names of every directory entry, or `None` when the directory can't be read.
fn directory_names(b: &[u8]) -> Option<Vec<String>> {
if !b.starts_with(&SIGNATURE) {
return None;
}
let shift = u16_at(b, 30)?;
if shift != 9 && shift != 12 {
return None;
}
let size = 1usize << shift;
let per = size / 4;
let sector = |id: u32| -> Option<&[u8]> {
let start = (id as usize).checked_add(1)?.checked_mul(size)?;
b.get(start..start.checked_add(size)?)
};
// The DIFAT: the FAT's sector ids, 109 in the header then chained DIFAT sectors.
let mut difat: Vec<u32> = (0..109).filter_map(|i| u32_at(b, 76 + i * 4)).filter(|&s| s < MAX_REG_SECT).collect();
let mut next = u32_at(b, 68)?;
for _ in 0..MAX_DIFAT_SECTORS {
if next >= MAX_REG_SECT {
break;
}
let s = sector(next)?;
difat.extend((0..per - 1).filter_map(|i| u32_at(s, i * 4)).filter(|&x| x < MAX_REG_SECT));
next = u32_at(s, (per - 1) * 4)?;
}
let fat_next = |id: u32| -> Option<u32> {
let idx = id as usize;
let fat_sector = *difat.get(idx / per)?;
u32_at(sector(fat_sector)?, (idx % per) * 4)
};
let mut names = Vec::new();
let mut id = u32_at(b, 48)?;
for _ in 0..MAX_DIR_SECTORS {
if id == END_OF_CHAIN {
return Some(names);
}
if id >= MAX_REG_SECT {
return None;
}
let s = sector(id)?;
for e in s.as_chunks::<128>().0 {
let len = usize::from(u16_at(e, 64)?);
if !(2..=64).contains(&len) {
continue;
}
let units: Vec<u16> = (0..(len - 2) / 2).filter_map(|i| u16_at(e, i * 2)).collect();
names.push(String::from_utf16_lossy(&units));
}
id = fat_next(id)?;
}
// A directory longer than the bound (or a cyclic chain): report what was read.
Some(names)
let limits = limits();
ENCRYPTED_STREAMS.iter().any(|name| craft_cfb::has_entry_named(bytes, name, &limits))
}
#[cfg(test)]
@@ -105,6 +26,7 @@ mod tests {
#![allow(clippy::unwrap_used)]
use super::*;
use craft_cfb::{ENDOFCHAIN as END_OF_CHAIN, SIGNATURE};
/// A minimal valid compound file (512-byte sectors: FAT at sector 0, directory at sector 1)
/// whose directory holds a root entry plus the given stream names.
@@ -146,7 +68,7 @@ mod tests {
#[test]
fn reads_directory_names() {
let b = build(&["EncryptionInfo", "EncryptedPackage"]);
assert_eq!(directory_names(&b), Some(vec!["Root Entry".into(), "EncryptionInfo".into(), "EncryptedPackage".into()]));
assert_eq!(craft_cfb::directory_names(&b, &limits()), Some(vec!["Root Entry".into(), "EncryptionInfo".into(), "EncryptedPackage".into()]));
assert!(is_encrypted(&b));
// A PowerPoint 97-2003 .ppt is a compound file too, without the encryption streams.
assert!(!is_encrypted(&build(&["PowerPoint Document", "Current User"])));
+22 -48
View File
@@ -1,59 +1,33 @@
//! A minimal PNG encoder for the placeholder image written when a picture's media is missing.
//! The placeholder image written when a picture's media is missing: a 1×1 fully transparent RGBA
//! PNG, kept as its fixed bytes (signature, IHDR, one stored-deflate IDAT scanline, IEND) so the
//! app carries no PNG encoder of its own.
fn crc32(data: &[u8]) -> u32 {
let mut c = 0xFFFF_FFFFu32;
for b in data {
c ^= *b as u32;
for _ in 0..8 {
c = if c & 1 != 0 { 0xEDB8_8320 ^ (c >> 1) } else { c >> 1 };
}
}
!c
}
fn adler32(data: &[u8]) -> u32 {
let (mut a, mut b) = (1u32, 0u32);
for x in data {
a = (a + *x as u32) % 65521;
b = (b + a) % 65521;
}
(b << 16) | a
}
fn chunk(out: &mut Vec<u8>, kind: &[u8; 4], data: &[u8]) {
out.extend_from_slice(&(data.len() as u32).to_be_bytes());
let mut c = Vec::with_capacity(data.len() + 4);
c.extend_from_slice(kind);
c.extend_from_slice(data);
out.extend_from_slice(&c);
out.extend_from_slice(&crc32(&c).to_be_bytes());
}
/// The PNG file, byte for byte what the former local encoder produced.
const TRANSPARENT_1X1: [u8; 73] = [
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4, 0x89, 0x00, 0x00, 0x00, 0x10, 0x49, 0x44, 0x41, 0x54, 0x78, 0x01, 0x01, 0x05, 0x00, 0xFA, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x01, 0x64, 0x78, 0x95, 0x38, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60,
0x82,
];
/// A 1×1 fully transparent RGBA PNG.
pub fn transparent_1x1() -> Vec<u8> {
let mut out = b"\x89PNG\r\n\x1a\n".to_vec();
let mut ihdr = vec![];
ihdr.extend_from_slice(&1u32.to_be_bytes());
ihdr.extend_from_slice(&1u32.to_be_bytes());
ihdr.extend_from_slice(&[8, 6, 0, 0, 0]);
chunk(&mut out, b"IHDR", &ihdr);
// One scanline: filter byte + RGBA, stored (uncompressed) deflate block.
let raw = [0u8, 0, 0, 0, 0];
let mut z = vec![0x78, 0x01, 0x01];
z.extend_from_slice(&(raw.len() as u16).to_le_bytes());
z.extend_from_slice(&(!(raw.len() as u16)).to_le_bytes());
z.extend_from_slice(&raw);
z.extend_from_slice(&adler32(&raw).to_be_bytes());
chunk(&mut out, b"IDAT", &z);
chunk(&mut out, b"IEND", &[]);
out
TRANSPARENT_1X1.to_vec()
}
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
#[test]
fn crc_known() {
assert_eq!(super::crc32(b"IEND"), 0xAE42_6082);
assert!(super::transparent_1x1().starts_with(b"\x89PNG"));
fn placeholder_is_a_transparent_1x1_png() {
let png = super::transparent_1x1();
assert!(png.starts_with(b"\x89PNG\r\n\x1a\n"));
// IHDR: 1×1, 8-bit RGBA, no interlace.
assert_eq!(&png[12..16], b"IHDR");
assert_eq!(&png[16..29], &[0, 0, 0, 1, 0, 0, 0, 1, 8, 6, 0, 0, 0]);
assert!(png.ends_with(b"IEND\xAE\x42\x60\x82"));
// The stored scanline: filter byte 0, then one pixel with zero alpha.
assert_eq!(&png[49..54], &[0, 0, 0, 0, 0]);
}
}
+4 -2
View File
@@ -1,6 +1,6 @@
# Slide show and presenter view: parity with PowerPoint
> **Last reviewed:** 2026-10-14 · **Last updated:** 2026-11-02 · **Change:** minor (deleting slides removes them from custom shows; previous: minor, Presenter View only with a second display on Linux and the BSDs, #1156; previous: minor, Set Up Slide Show ▸ Keep mouse cursor visible, #1445; previous: minor, Ctrl+wheel zooms the show around the pointer, #1286; previous: major, community PR wave 2026-10-14: interactive decks, laser pointer, See All Slides and zoom, go-to-slide number, custom show playback, presenter timer, clock, notes size and keyboard, Show Media Controls, swipe; breadth 68%; duplicated rows and headers folded; previous: major, created) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365)
> **Last reviewed:** 2026-10-14 · **Last updated:** 2026-11-14 · **Change:** minor (a slide the show advances to again plays its animations again, #2090; previous: minor, deleting slides removes them from custom shows; previous: minor, Presenter View only with a second display on Linux and the BSDs, #1156; previous: minor, Set Up Slide Show ▸ Keep mouse cursor visible, #1445; previous: minor, Ctrl+wheel zooms the show around the pointer, #1286; previous: major, community PR wave 2026-10-14: interactive decks, laser pointer, See All Slides and zoom, go-to-slide number, custom show playback, presenter timer, clock, notes size and keyboard, Show Media Controls, swipe; breadth 68%; duplicated rows and headers folded; previous: major, created) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365)
Presenting is the job PowerPoint is hired for. This doc covers the show window, presenter view,
rehearsal and recording. Transition and animation playback are in
@@ -23,7 +23,8 @@ ready** (estimated), **10–16 h** to parity.
| Hidden slides skipped | yes | yes | |
| Hyperlinks and action settings followed (slides, web, mail, End Show, Last Viewed) | yes | yes | Only `http(s)` and `mailto` open outside the show, by design (`safe_url`) |
| A shape with a triggered animation plays it when clicked; shapes an animation has hidden cannot be clicked; a shape without an action on top of one with an action blocks it; the pointer is a hand over what can be clicked | yes | yes | Click boxes are bounding boxes; "play sound" actions (`ppaction://media`) do nothing yet |
| A slide the show returns to (link, arrow keys) looks as it was left; a triggered animation goes on where it stopped | yes | yes | A main-sequence step still playing when the show leaves is finished |
| A slide the show returns to by a link or Back looks as it was left; a triggered animation goes on where it stopped | yes | yes | A main-sequence step still playing when the show leaves is finished |
| A slide the show advances to again (click, →, Space, automatic advance, loop) starts over and plays its animations again | yes | yes | Its triggered animations start over too (#2090) |
| "Advance on click" off: a click never leaves the slide (animation steps still play, keys still move on) | yes | yes | |
| Hyperlinks and action settings followed (slides, web, mail, End Show, Last Viewed, Custom Show) | yes | yes | Only `http(s)` and `mailto` open outside the show, by design (`safe_url`). A Custom Show action plays that show |
| Media playback with controls, play across slides, full-screen video, Play/Pause/Stop in the click sequence | yes | yes | WMA/WMV not decodable. Click sequence since #116. Slide Show ▸ Show Media Controls (on by default) hides the playback bar. Seeks and loops preserve new-generation video frames and end-of-stream; queue regression and repeated seeks across H.264/HEVC/VP9/AV1 in `crates/media` |
@@ -96,4 +97,5 @@ Reading View in a window with navigation: present (checklist row done).
| 2026-10-14 | minor | See All Slides (G) and click-to-zoom (Z) during the show. Presenter view opens that grid and sets black, white and zoom. Checklist breadth stays 66% |
| 2026-10-24 | minor | Ctrl+wheel (Cmd+wheel on a Mac) zooms the show in and out around the pointer, up to 4×; the plain wheel still turns the page (#1286) |
| 2026-10-23 | trivial | Presenter view draws the notes with their formatting (bullets, numbers, indents, bold/italic) instead of plain text (#1128) |
| 2026-11-14 | minor | A slide the show advances to again starts over, so its entrance effects play again; Back and links still show it as it was left (#2090) |
| 2026-10-10 | major | Created: show, presenter view, rehearse and record, compared with PowerPoint 16.113's Slide Show tab and menu |