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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use quick_xml::events::BytesStart;
use quick_xml::Reader;
use quick_xml::Writer;
use reader::driver::*;
use std::io::Cursor;
use writer::driver::*;
#[derive(Clone, Default, Debug)]
pub struct SourceRectangle {
t: Option<String>,
l: Option<String>,
r: Option<String>,
b: Option<String>,
}
impl SourceRectangle {
pub fn set_t<S: Into<String>>(&mut self, value: S) {
self.t = Some(value.into());
}
pub fn get_t(&self) -> &Option<String> {
&self.t
}
pub fn set_l<S: Into<String>>(&mut self, value: S) {
self.l = Some(value.into());
}
pub fn get_l(&self) -> &Option<String> {
&self.l
}
pub fn set_r<S: Into<String>>(&mut self, value: S) {
self.r = Some(value.into());
}
pub fn get_r(&self) -> &Option<String> {
&self.r
}
pub fn set_b<S: Into<String>>(&mut self, value: S) {
self.b = Some(value.into());
}
pub fn get_b(&self) -> &Option<String> {
&self.b
}
pub(crate) fn set_attributes<R: std::io::BufRead>(
&mut self,
_reader: &mut Reader<R>,
e: &BytesStart,
) {
for a in e.attributes().with_checks(false) {
match a {
Ok(ref attr) if attr.key == b"t" => {
self.set_t(get_attribute_value(attr).unwrap());
}
Ok(ref attr) if attr.key == b"l" => {
self.set_l(get_attribute_value(attr).unwrap());
}
Ok(ref attr) if attr.key == b"r" => {
self.set_r(get_attribute_value(attr).unwrap());
}
Ok(ref attr) if attr.key == b"b" => {
self.set_b(get_attribute_value(attr).unwrap());
}
Ok(_) => {}
Err(_) => {}
}
}
}
pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
let mut attributes: Vec<(&str, &str)> = Vec::new();
match &self.t {
Some(v) => attributes.push(("t", v)),
None => {}
}
match &self.l {
Some(v) => attributes.push(("l", v)),
None => {}
}
match &self.r {
Some(v) => attributes.push(("r", v)),
None => {}
}
match &self.b {
Some(v) => attributes.push(("b", v)),
None => {}
}
write_start_tag(writer, "a:srcRect", attributes, true);
}
}