From e4b1a609f2d19ef8e1330407ed74c233260e6927 Mon Sep 17 00:00:00 2001 From: Naseq Date: Wed, 11 Nov 2026 11:46:30 +0430 Subject: [PATCH] PPTX: preserve empty notes slides on save and reopen (#2025) When a slide has an associated notes slide with no text, PPTX export previously omitted both the notes slide part and its relationship, treating notes slides without text runs as removable. Track whether a slide has an associated notes slide (`has_notes_slide`). Import marks it when reading a notes slide relationship, and export keeps the notes slide part, its slide relationship, and notes master linkage even when its text body is empty. Native serialization preserves the presence flag, and setting notes via `slide.notes` also enables it. Regression test in `crates/pptx/tests/it/notes.rs` verifies that a slide with an empty notes slide retains its notes part and relationship across multiple import and export roundtrips. --- ROADMAP.md | 4 ++- crates/engine/src/cmd/slide.rs | 6 ++++- crates/model/src/lib.rs | 4 +++ crates/pptx/src/read.rs | 1 + crates/pptx/src/write.rs | 6 ++--- crates/pptx/tests/it/notes.rs | 48 ++++++++++++++++++++++++++++++++++ docs/file-format-parity.md | 5 ++-- 7 files changed, 67 insertions(+), 7 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index edd316276..95fcf89b5 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -2,7 +2,7 @@ **Stage: alpha** · next: beta, ~20 points and ~120–210 h away -> **Last reviewed:** 2026-11-04 · **Last updated:** 2026-11-04 · **Change:** trivial (Ogg Opus recovery includes trailing packets without granules in its reported duration; parity scores unchanged) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365) +> **Last reviewed:** 2026-11-04 · **Last updated:** 2026-11-11 · **Change:** minor (empty notes slides are preserved through PPTX and native saves rather than dropped, #2025; 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-11 | PPTX: a slide whose notes slide has empty text retains its notesSlide part and relationship on save and reopen (#2025); empty notes slides survive native round trips | | 2026-11-04 | Ogg Opus recovery keeps trailing packets without granules in the total duration, matching their recovered positions; valid end trimming stays covered | | 2026-11-03 | Web: the `?host=parent` bridge (as in GridCraft, WordCraft and PdfCraft) lets a same-origin page that frames DeckCraft send a presentation and store its saves; Save writes an opened .pptx back as .pptx under its own name, as on the desktop | | 2026-11-02 | Slide show on Linux and the BSDs: Presenter View stays off when winit lists exactly one display, as in PowerPoint; if it lists none, the setting is kept. On one display the presenter window covered the show, and the hidden window stalled every frame: slide changes took up to ~1.7 s under Hyprland (#1156) | @@ -340,6 +341,7 @@ app's JSON control channel (`deckcraft --control PORT`). | Date | Change | Summary | |---|---|---| +| 2026-11-11 | minor | Progress log: empty notes slides preserved on PPTX/native save (#2025); 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 | | 2026-11-03 | trivial | Reuse Slides brings referenced custom table styles along; scores unchanged | diff --git a/crates/engine/src/cmd/slide.rs b/crates/engine/src/cmd/slide.rs index f15cf32fa..5f3fbc8f6 100644 --- a/crates/engine/src/cmd/slide.rs +++ b/crates/engine/src/cmd/slide.rs @@ -602,11 +602,15 @@ fn notes(s: &mut Session, p: &Value) -> Result { let text = str_param(p, "text").unwrap_or("").to_string(); s.edit(|doc, _| { if let Some(sl) = doc.slides.get_mut(i) { - let notes = &mut Arc::make_mut(sl).notes; + let sl = Arc::make_mut(sl); + let notes = &mut sl.notes; match body { Some(b) => *notes = b, None => deckcraft_model::edit::replace_text(notes, &text), } + if !notes.is_empty() { + sl.has_notes_slide = true; + } } Ok(()) })?; diff --git a/crates/model/src/lib.rs b/crates/model/src/lib.rs index 8547bc60c..5f6f996c1 100644 --- a/crates/model/src/lib.rs +++ b/crates/model/src/lib.rs @@ -626,6 +626,9 @@ pub struct Slide { pub animations: Vec, /// Speaker notes. pub notes: TextBody, + /// Whether the slide has an associated notes slide even if its text is empty. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub has_notes_slide: bool, pub comments: Vec, /// `clrMapOvr`: a colour map replacing the layout's or master's (`bg1`→`dk1`…); None follows /// the layout. @@ -652,6 +655,7 @@ impl Default for Slide { transition: None, animations: vec![], notes: TextBody::default(), + has_notes_slide: false, comments: vec![], color_map: None, tags: vec![], diff --git a/crates/pptx/src/read.rs b/crates/pptx/src/read.rs index 47f6229c3..4e5869a51 100644 --- a/crates/pptx/src/read.rs +++ b/crates/pptx/src/read.rs @@ -678,6 +678,7 @@ fn read_slides( let mut slide = read_slide(imp, &part, doc, *id, layout); if let Some(notes) = slide_notes(imp, &part, &mut owned_parts) { slide.notes = notes; + slide.has_notes_slide = true; } read_slide_comments(pkg, pres_part, &part, &mut slide, &mut owned_parts); file_slide_ids.insert(*file_id, *id); diff --git a/crates/pptx/src/write.rs b/crates/pptx/src/write.rs index e4c0858c9..28e65ba32 100644 --- a/crates/pptx/src/write.rs +++ b/crates/pptx/src/write.rs @@ -427,7 +427,7 @@ struct NotesMasterWrite { fn notes_master_write(p: &Presentation) -> Option { let nm = p.notes_master.as_deref(); let kept = nm.filter(|m| !m.shapes.is_empty()); - let has_notes = p.slides.iter().any(|s| !s.notes.is_empty()); + let has_notes = p.slides.iter().any(|s| !s.notes.is_empty() || s.has_notes_slide); if !has_notes && nm.is_none() { return None; } @@ -666,7 +666,7 @@ pub fn export(p: &Presentation, main_ct: &str) -> Result, PptxError> { if let Some(lp) = layout_parts.get(&s.layout) { so.rels.add("slideLayout", &opc::relative(&sname, lp), false); } - if !s.notes.is_empty() { + if !s.notes.is_empty() || s.has_notes_slide { let nname = format!("ppt/notesSlides/notesSlide{}.xml", i + 1); so.rels.add("notesSlide", &opc::relative(&sname, &nname), false); let mut no = Out::new(&nname); @@ -1301,7 +1301,7 @@ fn app_xml(p: &Presentation) -> Vec { ); w.elt("Application", "DeckCraft"); w.elt("Slides", &p.slides.len().to_string()); - w.elt("Notes", &p.slides.iter().filter(|s| !s.notes.is_empty()).count().to_string()); + w.elt("Notes", &p.slides.iter().filter(|s| !s.notes.is_empty() || s.has_notes_slide).count().to_string()); w.elt("HiddenSlides", &p.slides.iter().filter(|s| s.hidden).count().to_string()); if !p.props.company.is_empty() { w.elt("Company", &p.props.company); diff --git a/crates/pptx/tests/it/notes.rs b/crates/pptx/tests/it/notes.rs index b5863d510..1ae98bac2 100644 --- a/crates/pptx/tests/it/notes.rs +++ b/crates/pptx/tests/it/notes.rs @@ -14,6 +14,31 @@ const NOTES: &str = "ppt/notesSlides/notesSlide1.xml"; /// label and plain text), a level-2 paragraph with buNone, and a closing plain line. const NOTES_XML: &str = r#" Metodický prehľadŽiaci pracujú vo dvojiciach.Cieľ: vysvetliť cyklusReflexiaBez odrážkyPomôcky: počítač"#; +const EMPTY_NOTES_XML: &str = r#" +"#; + +fn empty_notes_deck() -> Vec { + let mut p = defaults::new_presentation(None); + Arc::make_mut(&mut p.slides[0]).notes = TextBody::from_text("placeholder"); + let bytes = deckcraft_pptx::export(&p).expect("export"); + let mut src = zip::ZipArchive::new(Cursor::new(bytes)).expect("zip"); + let mut out = zip::ZipWriter::new(Cursor::new(Vec::new())); + let mut found = false; + for i in 0..src.len() { + let mut f = src.by_index(i).expect("entry"); + let name = f.name().to_string(); + let mut data = vec![]; + f.read_to_end(&mut data).expect("read"); + if name == NOTES { + data = EMPTY_NOTES_XML.as_bytes().to_vec(); + found = true; + } + out.start_file(name, zip::write::SimpleFileOptions::default()).expect("start"); + out.write_all(&data).expect("write"); + } + assert!(found, "the export has no {NOTES}"); + out.finish().expect("finish").into_inner() +} /// A deck with one notes slide, its notes replaced by [`NOTES_XML`]. fn deck() -> Vec { @@ -80,3 +105,26 @@ fn notes_formatting_survives_a_round_trip() { assert!(xml.contains(r#"lvl="1""#) && xml.contains(r#"marL="285750""#) && xml.contains(r#"indent="-285750""#), "{xml}"); assert!(xml.contains(r#""), "{xml}"); } + +#[test] +fn empty_notes_slide_is_preserved_on_save_and_reopen() { + let raw = empty_notes_deck(); + let p = deckcraft_pptx::import(&raw).expect("import"); + assert!(p.slides[0].notes.is_empty(), "imported notes text is empty"); + assert!(p.slides[0].has_notes_slide, "slide notes presence is captured"); + + let saved = deckcraft_pptx::export(&p).expect("export"); + let mut z = zip::ZipArchive::new(Cursor::new(&saved)).expect("zip"); + assert!(z.by_name(NOTES).is_ok(), "empty notes slide part is kept in saved package"); + let mut rels_xml = String::new(); + z.by_name("ppt/slides/_rels/slide1.xml.rels").expect("slide rels").read_to_string(&mut rels_xml).expect("read slide rels"); + assert!(rels_xml.contains("notesSlide"), "slide points to notes slide: {rels_xml}"); + + let again = deckcraft_pptx::import(&saved).expect("reimport"); + assert!(again.slides[0].notes.is_empty()); + assert!(again.slides[0].has_notes_slide, "notes slide presence survives roundtrip"); + + let saved_again = deckcraft_pptx::export(&again).expect("export again"); + let mut z2 = zip::ZipArchive::new(Cursor::new(saved_again)).expect("zip"); + assert!(z2.by_name(NOTES).is_ok(), "empty notes slide part is kept on subsequent export"); +} diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 70b74f7e1..a9fa6a569 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File-format parity with PowerPoint -> **Last reviewed:** 2026-11-02 · **Last updated:** 2026-11-03 · **Change:** minor (cell anchorCtr, vertOverflow/horzOverflow, compatLnSpc, normalizeH, thaiDist, table rtl, run altLang and reflection transforms round-trip; Reuse Slides brings referenced custom table styles; previous: minor (native chart payloads stored in bounded ZIP members; previous: major, community PR wave 2026-10-14: seven owned PPTX corpus files, embedded fonts, EMF/WMF clip regions, threaded comments (#70), chart trendlines and workbooks (#335), SmartArt written as a diagram, tags and custom XML kept, picture export DPI; duplicated rows and headers folded; previous: trivial, lines in scaled groups, #233)) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365) +> **Last reviewed:** 2026-11-02 · **Last updated:** 2026-11-11 · **Change:** minor (empty notes slides are preserved on save and reopen, #2025; previous: cell anchorCtr, vertOverflow/horzOverflow, compatLnSpc, normalizeH, thaiDist, table rtl, run altLang and reflection transforms round-trip; Reuse Slides brings referenced custom table styles; previous: minor (native chart payloads stored in bounded ZIP members; previous: major, community PR wave 2026-10-14: seven owned PPTX corpus files, embedded fonts, EMF/WMF clip regions, threaded comments (#70), chart trendlines and workbooks (#335), SmartArt written as a diagram, tags and custom XML kept, picture export DPI; duplicated rows and headers folded; previous: trivial, lines in scaled groups, #233)) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365) Every format PowerPoint reads or writes, DeckCraft's support, fidelity and how it is tested. Gaps are itemized in [gaps.md](gaps.md#file-formats). Dimension score: **~58% ready** @@ -77,7 +77,7 @@ the round trip even though DeckCraft doesn't model it. | Presentation, slide size, sections (p14), custom shows | yes | yes | | | Slide masters, layouts, placeholders and inheritance | yes | yes | | | Themes: colour, font (Latin/EA/CS), effect schemes, background styles | yes | yes | Unknown theme parts kept | -| Notes slides and notes master | yes | yes | Header, footer, date and slide-number text on the notes master is kept. Edited in View ▸ Notes Master. Notes keep their run and paragraph formatting (bold, italic, underline, size, levels, indents, bullets), shown and kept when edited in the notes pane and Notes Page (`crates/pptx/tests/it/notes.rs`). PDF notes pages print them as plain text; levels and bullets inherited from a custom notes master aren't shown | +| Notes slides and notes master | yes | yes | Header, footer, date and slide-number text on the notes master is kept. Edited in View ▸ Notes Master. Notes keep their run and paragraph formatting (bold, italic, underline, size, levels, indents, bullets), shown and kept when edited in the notes pane and Notes Page (`crates/pptx/tests/it/notes.rs`). Empty notes slides are preserved on save and reopen (#2025). PDF notes pages print them as plain text; levels and bullets inherited from a custom notes master aren't shown | | Handout master | yes | yes | Header, footer, date and slide-number text is kept. Edited in View ▸ Handout Master | | Shapes: preset geometry (~180 presets), custom geometry, groups, connectors | yes | yes | Presets re-derived in `crates/geom/src/preset.rs` (and `preset/extra.rs`). Outlines, dashes, arrowheads and ink inside a group, and text, keep their size in points whatever the group's child-coordinate scale (#233). | | Fills: solid, gradient, picture (stretch/tile/crop), pattern, group | yes | yes | | @@ -121,6 +121,7 @@ the round trip even though DeckCraft doesn't model it. |---|---|---| | 2026-11-02 | minor | Optional table RTL direction is read and written as `a:tblPr/@rtl`; native and two PPTX saves preserve true, false and absent values with distinguishable column text | | 2026-11-02 | minor | Text runs preserve alternate-language metadata in native and PPTX round trips | +| 2026-11-11 | minor | Empty notes slides retain their notesSlide part and relationship on save and reopen (#2025) | | 2026-11-03 | trivial | Reuse Slides transfers referenced custom table styles from native and PPTX sources; grouped tables, undo, native save/reopen and style-id conflicts are covered | | 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-11-02 | trivial | Reflection start position, affine scale/skew, direction and fade, alignment and rotation attributes survive native and PPTX saves; rendering remains partial |