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.
This commit is contained in:
kiwi4boy committed 2026-11-20 02:15:56 -05:00
1 parent f580d6ae27
commit 8f195d860b
2 files changed
+18 -4

No files matched your search

+6 -4
View File
@@ -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<TextBody> {
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)
+12
View File
@@ -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.