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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#![allow(unused_must_use)]
#![allow(unused_imports)]
use std::borrow::Cow;
use std::io::Write;
use strong_xml::{XmlRead, XmlResult, XmlWrite, XmlWriter};
use crate::schema::{SCHEMA_DRAWINGML, SCHEMA_MAIN, SCHEMA_WORDML_14};
use crate::{__xml_test_suites, write_attr};
#[derive(Debug, Default, XmlRead, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:theme")]
pub struct Theme<'a> {
#[xml(attr = "name")]
pub name: Option<Cow<'a, str>>,
#[xml(child = "a:themeElements")]
pub elements: ThemeElements<'a>,
#[xml(child = "a:objectDefaults")]
pub defaults: ObjectDefaults,
#[xml(child = "a:extraClrSchemeLst")]
pub extra_clr_scheme_lst: ExtraClrSchemeLst,
#[xml(child = "a:extLst")]
pub ext_lst: ExtLst,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:themeElements")]
pub struct ThemeElements<'a> {
#[xml(child = "a:clrScheme")]
pub clr_scheme: Option<ClrScheme<'a>>,
#[xml(child = "a:fontScheme")]
pub font_scheme: Option<FontScheme<'a>>,
#[xml(child = "a:fmtScheme")]
pub fmt_scheme: Option<FmtScheme<'a>>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:clrScheme")]
pub struct ClrScheme<'a> {
#[xml(attr = "name")]
pub name: Option<Cow<'a, str>>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:fontScheme")]
pub struct FontScheme<'a> {
#[xml(attr = "name")]
pub name: Option<Cow<'a, str>>,
#[xml(child = "a:majorFont")]
pub major_font: MajorFont<'a>,
#[xml(child = "a:minorFont")]
pub minor_font: MinorFont<'a>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:majorFont")]
pub struct MajorFont<'a> {
#[xml(child = "a:latin")]
pub latin: Option<Latin<'a>>,
#[xml(child = "a:ea")]
pub ea: Option<EA<'a>>,
#[xml(child = "a:cs")]
pub cs: Option<CS<'a>>,
#[xml(child = "a:font")]
pub fonts: Vec<Font<'a>>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:minorFont")]
pub struct MinorFont<'a> {
#[xml(child = "a:latin")]
pub latin: Option<Latin<'a>>,
#[xml(child = "a:ea")]
pub ea: Option<EA<'a>>,
#[xml(child = "a:cs")]
pub cs: Option<CS<'a>>,
#[xml(child = "a:font")]
pub fonts: Vec<Font<'a>>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:ea")]
pub struct EA<'a> {
#[xml(attr = "typeface")]
pub typeface: Option<Cow<'a, str>>,
#[xml(attr = "panose")]
pub panose: Option<Cow<'a, str>>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:cs")]
pub struct CS<'a> {
#[xml(attr = "typeface")]
pub typeface: Option<Cow<'a, str>>,
#[xml(attr = "panose")]
pub panose: Option<Cow<'a, str>>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:latin")]
pub struct Latin<'a> {
#[xml(attr = "typeface")]
pub typeface: Option<Cow<'a, str>>,
#[xml(attr = "panose")]
pub panose: Option<Cow<'a, str>>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:font")]
pub struct Font<'a> {
#[xml(attr = "script")]
pub script: Option<Cow<'a, str>>,
#[xml(attr = "typeface")]
pub typeface: Option<Cow<'a, str>>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:fmtScheme")]
pub struct FmtScheme<'a> {
#[xml(attr = "name")]
pub name: Option<Cow<'a, str>>,
#[xml(child ="a:fillStyleLst")]
pub fill_style_lst: FillStyleLst,
#[xml(child ="a:lnStyleLst")]
pub in_style_lst: InStyleLst,
#[xml(child ="a:effectStyleLst")]
pub effect_style_lst: EffectStyleLst,
#[xml(child ="a:bgFillStyleLst")]
pub bg_fill_style_lst: BgFillStyleLst,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:fillStyleLst")]
pub struct FillStyleLst {}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:lnStyleLst")]
pub struct InStyleLst {}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:effectStyleLst")]
pub struct EffectStyleLst {}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:bgFillStyleLst")]
pub struct BgFillStyleLst {}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:objectDefaults")]
pub struct ObjectDefaults {}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:extraClrSchemeLst")]
pub struct ExtraClrSchemeLst {}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "a:extLst")]
pub struct ExtLst {}
impl<'a> XmlWrite for Theme<'a> {
fn to_writer<W: Write>(&self, writer: &mut XmlWriter<W>) -> XmlResult<()> {
let Theme {
name,
elements,
defaults,
extra_clr_scheme_lst,
ext_lst,
} = self;
log::debug!("[Theme] Started writing.");
let _ = write!(writer.inner, "{}", crate::schema::SCHEMA_XML);
writer.write_element_start("a:theme")?;
writer.write_attribute("xmlns:a", SCHEMA_DRAWINGML)?;
if let Some(n) = name {
writer.write_attribute("name", n)?;
}
writer.write_element_end_open()?;
elements.to_writer(writer)?;
defaults.to_writer(writer)?;
extra_clr_scheme_lst.to_writer(writer)?;
ext_lst.to_writer(writer)?;
writer.write_element_end_close("a:theme")?;
log::debug!("[Theme] Finished writing.");
Ok(())
}
}
__xml_test_suites!(
Theme,
Theme::default(),
format!(
r#"{}<a:theme xmlns:a="{}"><a:themeElements/><a:objectDefaults/><a:extraClrSchemeLst/><a:extLst/></a:theme>"#,
crate::schema::SCHEMA_XML,
SCHEMA_DRAWINGML,
)
.as_str(),
);