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
use std::io::Read;
use std::str::FromStr;
use super::*;
impl FromXML for CustomProps {
fn from_xml<R: Read>(reader: R) -> Result<Self, ReaderError> {
let mut r = EventReader::new(reader);
// TODO: Fow now, support only string.
let mut props = CustomProps::new();
loop {
let e = r.next();
match e {
Ok(XmlEvent::StartElement {
name, attributes, ..
}) => {
if let Ok(XMLElement::Property) = XMLElement::from_str(&name.local_name) {
if let Some(key) = read_name(&attributes) {
loop {
let e = r.next();
match e {
Ok(XmlEvent::StartElement { name, .. }) => {
// TODO: Fow now, support only string.
if let Ok(VtXMLElement::Lpwstr) =
VtXMLElement::from_str(&name.local_name)
{
let e = r.next();
if let Ok(XmlEvent::Characters(c)) = e {
props = props.add_custom_property(&key, c)
}
}
}
Ok(XmlEvent::EndElement { name, .. }) => {
if let Ok(XMLElement::Property) =
XMLElement::from_str(&name.local_name)
{
break;
}
}
_ => {}
}
}
}
}
}
Ok(XmlEvent::EndDocument { .. }) => {
return Ok(props);
}
Err(_) => return Err(ReaderError::XMLReadError),
_ => {}
}
}
}
}