Skip to content

Commit cc8685d

Browse files
author
Your Name
committed
pptx: treat a start list as a click wait only when every condition does
An automatic group lists delay=indefinite together with evt=onBegin; reading only the first condition imported a Cameo nested in it as click-waiting, which cleared its autoplay flag.
1 parent 69e2c9d commit cc8685d

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎crates/pptx/src/read/timing.rs‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ fn behaviour_auto_reverses(c: &El) -> bool {
204204
!behaviours.is_empty() && behaviours.iter().all(|b| b.child("cTn").and_then(|t| t.bool("autoRev")).unwrap_or(false))
205205
}
206206

207-
/// Does this time node wait for a click? Its start condition is `indefinite` or names the click.
207+
/// Does this time node wait for a click? Every condition in its start list must: a list that also
208+
/// names `onBegin` (or a delay) starts on its own, as automatic groups do.
208209
fn starts_on_click(e: &El) -> bool {
209-
e.child("stCondLst")
210-
.and_then(|s| s.child("cond"))
211-
.is_some_and(|c| c.attr("delay").is_some_and(|d| d.trim() == "indefinite") || c.attr("evt") == Some("onClick"))
210+
let conds: Vec<&El> = e.child("stCondLst").map(|s| s.elements().filter(|c| c.is("cond")).collect()).unwrap_or_default();
211+
!conds.is_empty() && conds.iter().all(|c| c.attr("delay").is_some_and(|d| d.trim() == "indefinite") || c.attr("evt") == Some("onClick"))
212212
}
213213

214214
/// The `p:video`/`p:audio` nodes, each with whether an enclosing time node waits for a click.
@@ -432,5 +432,10 @@ mod tests {
432432
assert!(!autoplay_of(&click_step), "an enclosing click step keeps delay 0 on the inner node");
433433
let waiting = ENTRY.replace(r#"<p:cond delay="0"/>"#, r#"<p:cond delay="indefinite"/>"#);
434434
assert!(!autoplay_of(&waiting), "an indefinite delay waits for a click");
435+
// A group that also starts `onBegin` runs by itself, so it is not a click step.
436+
let automatic = ENTRY
437+
.replace("<p:video>", r#"<p:par><p:cTn id="9"><p:stCondLst><p:cond delay="indefinite"/><p:cond evt="onBegin" delay="0"><p:tn val="2"/></p:cond></p:stCondLst><p:childTnLst><p:video>"#)
438+
.replace("</p:video>", "</p:video></p:childTnLst></p:cTn></p:par>");
439+
assert!(autoplay_of(&automatic), "an automatic group is not a click wait");
435440
}
436441
}

0 commit comments

Comments
 (0)