diff --git a/crates/pptx/src/read/dml.rs b/crates/pptx/src/read/dml.rs index 5076c3761..11949be56 100644 --- a/crates/pptx/src/read/dml.rs +++ b/crates/pptx/src/read/dml.rs @@ -23,6 +23,10 @@ pub fn pct(e: &El, name: &str) -> Option { e.f64(name).map(|v| v / 100_000.0) } +fn bullet_size_points(value: Option<&str>) -> Option { + value.and_then(|v| v.trim().parse::().ok()).filter(|v| (100..=400_000).contains(v)).map(|v| v as f64 / 100.0) +} + /// 1/60 000 degree → degrees. pub fn ang(e: &El, name: &str) -> Option { e.f64(name).map(|v| v / 60_000.0) @@ -438,8 +442,7 @@ pub fn ppr(imp: &mut Imp, part: &Part, p: &El) -> (Option, ParaProps, Option } "buSzPts" => { pp.bullet_size = None; - pp.bullet_size_points = - e.attr("val").and_then(|v| v.parse::().ok()).filter(|v| (100..=400_000).contains(v)).map(|v| v as f64 / 100.0); + pp.bullet_size_points = bullet_size_points(e.attr("val")); } "tabLst" => { pp.tabs = Some( @@ -676,6 +679,13 @@ mod tests { assert_eq!(color(&d.root).unwrap().base, ColorBase::Rgb { rgb: Rgba::rgb(255, 0, 0) }); } + #[test] + fn bullet_point_size_trims_schema_whitespace() { + let d = parse(br#""#).unwrap(); + assert_eq!(bullet_size_points(d.root.attr("val")), Some(14.0)); + assert_eq!(bullet_size_points(Some("1400")), Some(14.0)); + } + #[test] fn body_props() { let d = parse(br#""#).unwrap();