diff --git a/crates/pptx/src/read.rs b/crates/pptx/src/read.rs index 47f6229c3..fa71f07e4 100644 --- a/crates/pptx/src/read.rs +++ b/crates/pptx/src/read.rs @@ -34,7 +34,7 @@ pub struct Imp<'a> { pub custom_show_names: HashMap, /// GUIDs (upper case) of the table styles the file defines. pub table_style_ids: Vec, - /// Per legacy VML drawing part: shape id → preview picture part (see `shapes::vml_preview`). + /// Per legacy VML drawing part: shape id or o:spid → preview picture part (see `shapes::vml_preview`). pub vml_previews: HashMap>, /// Aggregate byte count of retained chart sidecars across the presentation. pub kept_sidecar_bytes: usize, diff --git a/crates/pptx/src/read/shapes.rs b/crates/pptx/src/read/shapes.rs index 467d889da..84af20600 100644 --- a/crates/pptx/src/read/shapes.rs +++ b/crates/pptx/src/read/shapes.rs @@ -510,8 +510,7 @@ fn vml_preview(imp: &mut Imp, part: &Part, spid: &str) -> Option`, ``, ``) removed, so shapes wrapped in them are parsed. fn strip_vml_conditionals(bytes: &[u8]) -> std::borrow::Cow<'_, [u8]> { let mut out = Vec::with_capacity(bytes.len()); let mut at = 0; @@ -541,12 +540,20 @@ fn strip_vml_conditionals(bytes: &[u8]) -> std::borrow::Cow<'_, [u8]> { if changed { std::borrow::Cow::Owned(out) } else { std::borrow::Cow::Borrowed(bytes) } } +/// Every shape id and o:spid in a VML drawing with a picture, mapped to that picture's part: parsed once per +/// drawing however many objects look it up. fn vml_index(pkg: &crate::opc::Package, vml: &str) -> std::collections::HashMap { let mut out = std::collections::HashMap::new(); let Some(bytes) = pkg.xml_bytes(vml) else { return out }; let decoded = crate::xml::decode_xml_bytes(bytes); let bytes = strip_vml_conditionals(&decoded); - let Ok(doc) = crate::xml::parse(&bytes) else { return out }; + let doc = match crate::xml::parse(&bytes) { + Ok(d) => d, + Err(e) => { + log::warn!("pptx: {vml}: {e}"); + return out; + } + }; let rels = pkg.rels(vml); let mut shapes = vec![]; doc.root.find_all("shape", &mut shapes);