From 2958d98e8a5d6145f69aaa950e2cd1e8b83c2088 Mon Sep 17 00:00:00 2001 From: kiwi4boy Date: Thu, 19 Nov 2026 23:53:57 -0500 Subject: [PATCH] ppt-binary: check the PowerPoint 95 crop's right and bottom values A sample cropped on the right and at the bottom shows the crop record's last two values in that order, as the reader takes them; the samples check now covers it. --- crates/ppt-binary/src/ppt95/picture.rs | 4 ++-- crates/ppt-binary/src/ppt95/tests.rs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/ppt-binary/src/ppt95/picture.rs b/crates/ppt-binary/src/ppt95/picture.rs index 016a91ffeb..e81a4466d0 100644 --- a/crates/ppt-binary/src/ppt95/picture.rs +++ b/crates/ppt-binary/src/ppt95/picture.rs @@ -9,8 +9,8 @@ //! A picture on a page is a shape (3008, a rectangle drawn with its format as any shape is) holding //! a 4014 container: 4015, the crop (left, top, right and bottom as i32s, in ten-thousandths of the //! picture), and 4053 → 4036, the picture's slot number. The shape's box is the cropped picture's. -//! (On a notes page, 4014 → 4054 → 4032 names the slide its slide image shows instead.) Only the -//! left and top crops were seen set; the right and bottom are taken to follow in that order. +//! (On a notes page, 4014 → 4054 → 4032 names the slide its slide image shows instead.) Each of the +//! four crops was seen set: left and top in one file, right and bottom in another. //! //! The metafile is kept as it is, as `image/x-wmf` media, as the PowerPoint 97 path keeps the //! metafiles of its blip store. Each slot is read once, the first time a shape names it, and all of diff --git a/crates/ppt-binary/src/ppt95/tests.rs b/crates/ppt-binary/src/ppt95/tests.rs index 4b6e27a1dc..53d31298cf 100644 --- a/crates/ppt-binary/src/ppt95/tests.rs +++ b/crates/ppt-binary/src/ppt95/tests.rs @@ -1809,7 +1809,7 @@ fn check_sample(name: &str, p: &Presentation) { // The automation reported 1295, 1367.5, 4610 × 720 twips. assert_eq!(boxed(s), (64.75, 68.375, 230.5, 36.0)); } - "picture" | "jpeg" | "png" | "picwmf" | "piccrop" | "twopics" | "picshare" | "notes" | "notes2" => check_media_sample(name, p), + "picture" | "jpeg" | "png" | "picwmf" | "piccrop" | "piccrop2" | "twopics" | "picshare" | "notes" | "notes2" => check_media_sample(name, p), _ => check_shape_sample(name, p), } } @@ -1845,6 +1845,11 @@ fn check_media_sample(name: &str, p: &Presentation) { let pics = pictures(0); assert_eq!((pics.len(), pics[0].0, pics[0].2), (1, (90.0, 81.0, 54.0, 63.0), [0.25, 0.125, 0.0, 0.0])); } + "piccrop2" => { + // CropRight 0.3 and CropBottom 0.05: the crop's last two values, in that order. + let pics = pictures(0); + assert_eq!((pics.len(), pics[0].0, pics[0].2), (1, (72.0, 72.0, 50.375, 68.375), [0.0, 0.0, 0.3, 0.05])); + } "twopics" => { let pics = pictures(0); assert_eq!(pics.iter().map(|x| (x.0, x.3)).collect::>(), [(inch, 128), ((216.0, 72.0, 144.0, 72.0), 220)]);