From 8f195d860b04fca074fa9725a7eeecc8babfa614 Mon Sep 17 00:00:00 2001 From: kiwi4boy Date: Fri, 20 Nov 2026 02:15:56 -0500 Subject: [PATCH] ppt95: a notes page's notes placeholder wins over other notes text The notes came from the first object that was either the notes placeholder or text of the notes type, so a notes-type shape before the placeholder gave its text instead. The placeholder is now looked for first, and other notes text only without one. --- crates/ppt-binary/src/ppt95.rs | 10 ++++++---- crates/ppt-binary/src/ppt95/tests.rs | 12 ++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/crates/ppt-binary/src/ppt95.rs b/crates/ppt-binary/src/ppt95.rs index 71140e044a..88ecd68f3c 100644 --- a/crates/ppt-binary/src/ppt95.rs +++ b/crates/ppt-binary/src/ppt95.rs @@ -741,13 +741,15 @@ fn convert_within(document: &Rec, app: &dyn Defaults, budget: usize) -> Presenta /// Document itself, isn't read: the PowerPoint 97 path doesn't import notes masters either. fn notes(page: &Rec, env: &Env, slide_scheme: &Scheme) -> Option { let scheme = page.child(rt::SCHEME).and_then(|s| s.child(rt::COLOR_SCHEME)).map_or(*slide_scheme, |s| scheme_of(&s)); - let is_notes = |r: &Rec| { - let kind = r.child(rt::PLACEHOLDER_ATOM).filter(|_| r.kind == rt::PLACEHOLDER).and_then(|a| a.u8(0)); + let kind = |r: &Rec| r.child(rt::PLACEHOLDER_ATOM).filter(|_| r.kind == rt::PLACEHOLDER).and_then(|a| a.u8(0)); + let notes_text = |r: &Rec| { let text_type = r.child(rt::TEXT).and_then(|t| t.child(rt::TEXT_BODY)).and_then(|b| b.child(rt::TEXT_ATOM)).and_then(|a| a.u32(0)); - kind == Some(NOTES_PLACEHOLDER) || (kind.is_none() && text_type == Some(NOTES_TEXT)) + kind(r).is_none() && text_type == Some(NOTES_TEXT) }; let objects = page.child(rt::OBJECTS)?; - let found = objects.children().take(MAX_OBJECTS).filter(|r| matches!(r.kind, rt::SHAPE | rt::PLACEHOLDER)).find(|r| is_notes(r))?; + let candidates = || objects.children().take(MAX_OBJECTS).filter(|r| matches!(r.kind, rt::SHAPE | rt::PLACEHOLDER)); + // The notes placeholder wherever it is, before any other text of the notes type. + let found = candidates().find(|r| kind(r) == Some(NOTES_PLACEHOLDER)).or_else(|| candidates().find(|r| notes_text(r)))?; let mut body = text::text_body(&found.child(rt::TEXT)?, env, &scheme, None, false)?; body.body = BodyProps::default(); Some(body) diff --git a/crates/ppt-binary/src/ppt95/tests.rs b/crates/ppt-binary/src/ppt95/tests.rs index 5e0fc61191..c5e5789e23 100644 --- a/crates/ppt-binary/src/ppt95/tests.rs +++ b/crates/ppt-binary/src/ppt95/tests.rs @@ -2137,6 +2137,18 @@ fn notes_land_on_their_slide() { assert_eq!(p.slides[0].notes.paragraphs[0].runs[0].props.size, Some(24.0)); assert_eq!(texts(&p), ["On the slide"]); assert!(p.slides[1..].iter().all(|s| s.shapes.is_empty())); + + // Text of the notes type before the notes placeholder: the placeholder's text is the notes. + let mut spec = SlideSpec::new(0x100, 16); + spec.notes = Some(notes_with( + 0x100, + vec![ + shape_95(bx, Some(text_typed(simple_text(b"Typed first", bx, BODY), 2))), + placeholder_95(0x0E, 0, 1, bx, Some(simple_text(b"From the placeholder", bx, BODY))), + ], + )); + let p = import(&stream_of(document_atom(5760, 4320, 1), &[slide(&spec)], &[master(MASTER, DEFAULT, [0; 4])])).unwrap(); + assert_eq!(p.slides[0].notes.text(), "From the placeholder"); } /// Notes paragraphs keep their spacing and justified alignment, as a slide's do.