docx_rs/reader/attributes/
val.rs

1use std::str::FromStr;
2
3use xml::attribute::OwnedAttribute;
4
5use super::super::errors::*;
6
7pub fn read_val(attrs: &[OwnedAttribute]) -> Option<String> {
8    for a in attrs {
9        let local_name = &a.name.local_name;
10        if local_name == "val" {
11            return Some(a.value.to_owned());
12        }
13    }
14    None
15}
16
17pub fn value_to_dax(v: &str) -> Result<i32, ReaderError> {
18    if v.ends_with("pt") {
19        let v = f64::from_str(&v.replace("pt", ""))? as i32;
20        Ok(v * 20)
21    } else {
22        Ok(f64::from_str(v)? as i32)
23    }
24}