diff --git a/crates/ppt-binary/src/ppt95.rs b/crates/ppt-binary/src/ppt95.rs index 38e4c7333d..a1584bbfa4 100644 --- a/crates/ppt-binary/src/ppt95.rs +++ b/crates/ppt-binary/src/ppt95.rs @@ -37,9 +37,10 @@ //! cap. //! //! PowerPoint 95 numbers placeholders its own way: on the master 1 title, 2 body, 6 date, 7 slide -//! number and 8 footer; on slides 0x0C title, 0x0D body, 0x0F centred title and 0x10 subtitle. A -//! placeholder of any other type keeps its text as a text box. The master's placeholders place the -//! caller's default master's, and the footer row places every layout's, as the PowerPoint 97 path +//! number and 8 footer; on slides 0x0C title, 0x0D body, 0x0F centred title and 0x10 subtitle. On a +//! slide, a placeholder of any other type keeps its text as a text box; on the master it is left +//! out. The master's placeholders place the caller's default master's, and the footer row places +//! every layout's, as the PowerPoint 97 path //! does. //! //! A picture is a shape naming one of the document's pictures, which are Windows metafiles; its diff --git a/crates/ppt-binary/src/ppt95/tests.rs b/crates/ppt-binary/src/ppt95/tests.rs index 1bd81dd20a..61f91721ee 100644 --- a/crates/ppt-binary/src/ppt95/tests.rs +++ b/crates/ppt-binary/src/ppt95/tests.rs @@ -2808,11 +2808,13 @@ fn the_wmf_reader_stays_in_each_record() { } /// For a sample with a rendering beside it (`.wmf`), each shape on its first slide with a -/// straight outline matches a polygon PowerPoint 95 drew. The number of shapes checked. +/// straight outline matches a polygon PowerPoint 95 drew, each a polygon of its own: two shapes +/// moved onto one place don't both match it. The number of shapes checked. fn check_outlines(name: &str, p: &Presentation, wmf: &[u8]) -> usize { let polygons = wmf_polygons(wmf, p.slide_size); let Some(slide) = p.slides.first() else { return 0 }; let mut checked = 0; + let mut used = vec![false; polygons.len()]; for s in &slide.shapes { let Some(corners) = outline_corners(s) else { continue }; // A dashed line is drawn dash by dash. @@ -2821,7 +2823,9 @@ fn check_outlines(name: &str, p: &Presentation, wmf: &[u8]) -> usize { } let width = s.line.as_ref().and_then(|l| l.width).unwrap_or(1.0); let near = polygons.iter().min_by_key(|poly| poly.len().abs_diff(corners.len())); - assert!(polygons.iter().any(|poly| outline_matches(&corners, poly, width)), "{name}: {corners:?} is not drawn; nearest {near:?}"); + let hit = (0..polygons.len()).find(|&i| !used[i] && outline_matches(&corners, &polygons[i], width)); + let Some(i) = hit else { panic!("{name}: {corners:?} is not drawn, or only where another shape is; nearest {near:?}") }; + used[i] = true; checked += 1; } checked