2020-02-12 08:44:53 +02:00
|
|
|
use std::str::FromStr;
|
|
|
|
|
|
|
|
use xml::attribute::OwnedAttribute;
|
|
|
|
|
|
|
|
use crate::types::*;
|
|
|
|
|
|
|
|
use super::super::errors::*;
|
|
|
|
|
|
|
|
pub fn read_indent(
|
|
|
|
attrs: &[OwnedAttribute],
|
2020-02-28 12:52:41 +02:00
|
|
|
) -> Result<(i32, Option<i32>, Option<SpecialIndentType>), ReaderError> {
|
2020-02-12 08:44:53 +02:00
|
|
|
let mut start = 0;
|
2020-02-28 12:52:41 +02:00
|
|
|
let mut end: Option<i32> = None;
|
2020-02-12 08:44:53 +02:00
|
|
|
let mut special: Option<SpecialIndentType> = None;
|
|
|
|
|
|
|
|
for a in attrs {
|
|
|
|
let local_name = &a.name.local_name;
|
|
|
|
if local_name == "left" || local_name == "start" {
|
2020-02-28 12:52:41 +02:00
|
|
|
start = i32::from_str(&a.value)?;
|
2020-02-12 08:44:53 +02:00
|
|
|
} else if local_name == "end" || local_name == "right" {
|
2020-02-28 12:52:41 +02:00
|
|
|
end = Some(i32::from_str(&a.value)?);
|
2020-02-12 08:44:53 +02:00
|
|
|
} else if local_name == "hanging" {
|
2020-02-28 12:52:41 +02:00
|
|
|
special = Some(SpecialIndentType::Hanging(i32::from_str(&a.value)?))
|
2020-02-12 08:44:53 +02:00
|
|
|
} else if local_name == "firstLine" {
|
2020-02-28 12:52:41 +02:00
|
|
|
special = Some(SpecialIndentType::FirstLine(i32::from_str(&a.value)?))
|
2020-02-12 08:44:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok((start, end, special))
|
|
|
|
}
|