From 6303166a1816693d7dfa7b04263cee61daf062fa Mon Sep 17 00:00:00 2001 From: Zach Berry <1112351+zberry@users.noreply.github.com> Date: Mon, 19 Oct 2026 02:58:27 -0500 Subject: [PATCH 1/2] [PP1] show.setup showMediaControls survives a pptx save and reopen PowerPoint stores Show media controls as the p14:showMediaCtrls extension inside p:showPr (uri {2FDB2607-...}); absent means shown. Write it when hidden, read it back. Co-Authored-By: Claude Sonnet 5.5 --- crates/pptx/src/read.rs | 1 + crates/pptx/src/write.rs | 8 ++++++++ crates/pptx/tests/it/roundtrip.rs | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/crates/pptx/src/read.rs b/crates/pptx/src/read.rs index 917aa9277..2df349cb7 100644 --- a/crates/pptx/src/read.rs +++ b/crates/pptx/src/read.rs @@ -1283,6 +1283,7 @@ fn read_show(sp: &El, shows: &HashMap) -> ShowSettings { without_narration: sp.bool("showNarration") == Some(false), without_animation: sp.bool("showAnimation") == Some(false), use_timings: sp.bool("useTimings").unwrap_or(true), + show_media_controls: sp.find("showMediaCtrls").and_then(|e| e.bool("val")).unwrap_or(true), ..Default::default() }; if sp.child("browse").is_some() { diff --git a/crates/pptx/src/write.rs b/crates/pptx/src/write.rs index 5d3e60e92..37cf5cd7d 100644 --- a/crates/pptx/src/write.rs +++ b/crates/pptx/src/write.rs @@ -1181,6 +1181,14 @@ fn pres_props_xml(p: &Presentation) -> Vec { w.open0("p:penClr"); w.val("a:srgbClr", s.pen_color.hex()); w.close("p:penClr"); + if !s.show_media_controls { + // "Show media controls" is PowerPoint's p14 extension; absent means shown. + w.open0("p:extLst"); + w.open("p:ext", A::new().a("uri", "{2FDB2607-1784-4EEB-B798-7EB5836EED8A}")); + w.empty("p14:showMediaCtrls", A::new().a("xmlns:p14", NS_P14).a("val", 0)); + w.close("p:ext"); + w.close("p:extLst"); + } w.close("p:showPr"); w.close("p:presentationPr"); w.finish() diff --git a/crates/pptx/tests/it/roundtrip.rs b/crates/pptx/tests/it/roundtrip.rs index 370cc9a9f..c61e6e433 100644 --- a/crates/pptx/tests/it/roundtrip.rs +++ b/crates/pptx/tests/it/roundtrip.rs @@ -1969,3 +1969,12 @@ fn default_durations_match_powerpoint() { assert_eq!(a.4, ms, "{effect}"); } } + +/// Show media controls is PowerPoint's `p14:showMediaCtrls` extension inside `p:showPr`. +#[test] +fn hidden_media_controls_survive_save_and_reopen() { + let mut p = Presentation::default(); + p.show.show_media_controls = false; + assert!(!round(&p).show.show_media_controls); + assert!(round(&Presentation::default()).show.show_media_controls); +} From b9eaaeb23b011b7a1e96568a4101f6d0d3cc13b9 Mon Sep 17 00:00:00 2001 From: Zach Berry <1112351+zberry@users.noreply.github.com> Date: Mon, 2 Nov 2026 17:03:02 -0600 Subject: [PATCH 2/2] Test: hidden media controls are written as PowerPoint's p14 extension The round trip now also checks the written presProps.xml: inside p:showPr, the extension uri and p14:showMediaCtrls with its namespace declared on the element; the default writes nothing. Co-Authored-By: Claude Opus 5.5 --- crates/pptx/tests/it/roundtrip.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/pptx/tests/it/roundtrip.rs b/crates/pptx/tests/it/roundtrip.rs index c61e6e433..521956a06 100644 --- a/crates/pptx/tests/it/roundtrip.rs +++ b/crates/pptx/tests/it/roundtrip.rs @@ -1970,11 +1970,30 @@ fn default_durations_match_powerpoint() { } } -/// Show media controls is PowerPoint's `p14:showMediaCtrls` extension inside `p:showPr`. +/// Show media controls is PowerPoint's `p14:showMediaCtrls` extension inside `p:showPr`: off is +/// written there, under its extension uri and with the p14 namespace declared on the element; +/// on (the default) writes nothing. #[test] fn hidden_media_controls_survive_save_and_reopen() { + let props = |p: &Presentation| { + let bytes = deckcraft_pptx::export(p).expect("export"); + let mut zip = zip::ZipArchive::new(std::io::Cursor::new(bytes)).expect("zip"); + let mut x = String::new(); + std::io::Read::read_to_string(&mut zip.by_name("ppt/presProps.xml").expect("presProps"), &mut x).expect("read"); + x + }; let mut p = Presentation::default(); p.show.show_media_controls = false; + let xml = props(&p); + let show = xml.split("").next()).expect("p:showPr"); + assert!( + show.contains( + "" + ), + "{xml}" + ); assert!(!round(&p).show.show_media_controls); - assert!(round(&Presentation::default()).show.show_media_controls); + let default = Presentation::default(); + assert!(!props(&default).contains("showMediaCtrls")); + assert!(round(&default).show.show_media_controls); }