use anyhow::bail;
use quick_xml::events::BytesStart;
use crate::raw::drawing::st_types::STAdjustCoordinate;
#[derive(Debug, Clone, PartialEq)]
pub struct XlsxPoint {
pub x: Option<STAdjustCoordinate>,
pub y: Option<STAdjustCoordinate>,
}
impl XlsxPoint {
pub(crate) fn load(e: &BytesStart) -> anyhow::Result<Self> {
let attributes = e.attributes();
let mut point = Self { x: None, y: None };
for a in attributes {
match a {
Ok(a) => {
let string_value = String::from_utf8(a.value.to_vec())?;
match a.key.local_name().as_ref() {
b"x" => point.x = Some(STAdjustCoordinate::from_string(&string_value)),
b"y" => point.y = Some(STAdjustCoordinate::from_string(&string_value)),
_ => {}
}
}
Err(error) => {
bail!(error.to_string())
}
}
}
Ok(point)
}
}