use crate::excel::XmlReader;
use crate::raw::drawing::image::blip::XlsxBlip;
use std::io::Read;
use anyhow::bail;
use quick_xml::events::Event;
#[derive(Debug, Clone, PartialEq)]
pub struct XlsxPictureBullet {
pub blip: Option<XlsxBlip>,
}
impl XlsxPictureBullet {
pub(crate) fn load(reader: &mut XmlReader<impl Read>) -> anyhow::Result<Self> {
let mut bullet = Self { blip: None };
let mut buf = Vec::new();
loop {
buf.clear();
match reader.read_event_into(&mut buf) {
Ok(Event::Start(ref e)) if e.local_name().as_ref() == b"blip" => {
bullet.blip = Some(XlsxBlip::load(reader, e)?);
}
Ok(Event::End(ref e)) if e.local_name().as_ref() == b"blipFill" => break,
Ok(Event::Eof) => bail!("unexpected end of file."),
Err(e) => bail!(e.to_string()),
_ => (),
}
}
Ok(bullet)
}
}