1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use std::io::Read;
use std::str::FromStr;

use xml::attribute::OwnedAttribute;
use xml::reader::EventReader;

use super::*;

impl ElementReader for TablePositionProperty {
    fn read<R: Read>(
        _r: &mut EventReader<R>,
        attrs: &[OwnedAttribute],
    ) -> Result<Self, ReaderError> {
        let mut property = TablePositionProperty::new();
        for a in attrs {
            let local_name = &a.name.local_name;
            match local_name.as_str() {
                "leftFromText" => {
                    if let Ok(v) = i32::from_str(&a.value) {
                        property = property.left_from_text(v);
                    }
                }
                "rightFromText" => {
                    if let Ok(v) = i32::from_str(&a.value) {
                        property = property.right_from_text(v);
                    }
                }
                "vertAnchor" => {
                    property = property.vertical_anchor(a.value.clone());
                }
                "horzAnchor" => {
                    property = property.horizontal_anchor(a.value.clone());
                }
                "tblpXSpec" => {
                    property = property.position_x_alignment(a.value.clone());
                }
                "tblpYSpec" => {
                    property = property.position_y_alignment(a.value.clone());
                }
                "tblpX" => {
                    if let Ok(v) = i32::from_str(&a.value) {
                        property = property.position_x(v);
                    }
                }
                "tblpY" => {
                    if let Ok(v) = i32::from_str(&a.value) {
                        property = property.position_y(v);
                    }
                }
                _ => {}
            }
        }
        Ok(property)
    }
}