1#![allow(unused_must_use)]
2
3use std::borrow::Cow;
4
5use derive_more::From;
6use hard_xml::{XmlRead, XmlWrite};
7
8use crate::{__define_enum, __string_enum};
9
10#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
11#[cfg_attr(test, derive(PartialEq))]
12#[xml(tag = "w:drawing")]
13pub struct Drawing<'a> {
14 #[xml(child = "wp:anchor")]
16 pub anchor: Option<Anchor<'a>>,
17 #[xml(child = "wp:inline")]
18 pub inline: Option<Inline<'a>>,
19}
20
21#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
22#[cfg_attr(test, derive(PartialEq))]
23#[xml(tag = "wp:anchor")]
24pub struct Anchor<'a> {
25 #[xml(attr = "distT", with = "crate::rounded_float")]
26 pub dist_t: Option<isize>,
27 #[xml(attr = "distB", with = "crate::rounded_float")]
28 pub dist_b: Option<isize>,
29 #[xml(attr = "distL", with = "crate::rounded_float")]
30 pub dist_l: Option<isize>,
31 #[xml(attr = "distR", with = "crate::rounded_float")]
32 pub dist_r: Option<isize>,
33 #[xml(attr = "simplePos", with = "crate::rounded_float")]
34 pub simple_pos_attr: Option<isize>,
35 #[xml(attr = "relativeHeight", with = "crate::rounded_float")]
36 pub relative_height: Option<isize>,
37 #[xml(attr = "behindDoc")]
38 pub behind_doc: Option<bool>,
39 #[xml(attr = "locked")]
40 pub locked: Option<bool>,
41 #[xml(attr = "layoutInCell")]
42 pub layout_in_cell: Option<bool>,
43 #[xml(attr = "allowOverlap")]
44 pub allow_overlap: Option<bool>,
45
46 #[xml(child = "wp:simplePos")]
47 pub simple_pos: Option<SimplePos>,
48 #[xml(child = "wp:positionH")]
49 pub position_horizontal: Option<PositionHorizontal>,
50 #[xml(child = "wp:positionV")]
51 pub position_vertical: Option<PositionVertical>,
52 #[xml(child = "wp:extent")]
53 pub extent: Option<Extent>,
54 #[xml(
55 child = "wp:wrapNone",
56 child = "wp:wrapSquare",
57 child = "wp:wrapTight",
58 child = "wp:wrapThrough",
59 child = "wp:wrapTopAndBottom"
60 )]
61 pub wrap: Option<Wrap>,
62 #[xml(child = "wp:docPr")]
63 pub doc_property: DocPr<'a>,
64 #[xml(child = "a:graphic")]
65 pub graphic: Option<Graphic<'a>>,
66}
67
68#[derive(Debug, From, XmlRead, XmlWrite, Clone)]
69#[cfg_attr(test, derive(PartialEq))]
70pub enum Wrap {
71 #[xml(tag = "wp:wrapNone")]
72 None(WrapNone),
73 #[xml(tag = "wp:wrapSquare")]
74 Square(WrapSquare),
75 #[xml(tag = "wp:wrapTight")]
76 Tight(WrapTight),
77 #[xml(tag = "wp:wrapThrough")]
78 Through(WrapThrough),
79 #[xml(tag = "wp:wrapTopAndBottom")]
80 TopAndBottom(WrapTopAndBottom),
81}
82
83#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
84#[cfg_attr(test, derive(PartialEq))]
85#[xml(tag = "wp:wrapNone")]
86pub struct WrapNone {}
87
88#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
89#[cfg_attr(test, derive(PartialEq))]
90#[xml(tag = "wp:wrapSquare")]
91pub struct WrapSquare {}
92
93#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
94#[cfg_attr(test, derive(PartialEq))]
95#[xml(tag = "wp:wrapTight")]
96pub struct WrapTight {
97 #[xml(attr = "wrapText")]
98 pub wrap_text: WrapTextType,
99 #[xml(child = "wp:wrapPolygon")]
100 pub wrap_polygon: WrapPolygon,
101}
102
103#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
104#[cfg_attr(test, derive(PartialEq))]
105#[xml(tag = "wp:wrapPolygon")]
106pub struct WrapPolygon {
107 #[xml(attr = "edited")]
108 pub edited: Option<bool>,
109 #[xml(child = "wp:start")]
110 pub start: WrapPolygonStart,
111 #[xml(child = "wp:lineTo")]
112 pub lineto: Vec<WrapPolygonLineTo>,
113}
114
115#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
116#[cfg_attr(test, derive(PartialEq))]
117#[xml(tag = "wp:start")]
118pub struct WrapPolygonStart {
119 #[xml(attr = "x", with = "crate::rounded_float")]
120 pub x: Option<isize>,
121 #[xml(attr = "y", with = "crate::rounded_float")]
122 pub y: Option<isize>,
123}
124
125#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
126#[cfg_attr(test, derive(PartialEq))]
127#[xml(tag = "wp:lineTo")]
128pub struct WrapPolygonLineTo {
129 #[xml(attr = "x", with = "crate::rounded_float")]
130 pub x: Option<isize>,
131 #[xml(attr = "y", with = "crate::rounded_float")]
132 pub y: Option<isize>,
133}
134
135#[derive(Debug, Clone, Default)]
136#[cfg_attr(test, derive(PartialEq))]
137pub enum WrapTextType {
138 #[default]
139 Both,
140}
141
142__string_enum! {
143 WrapTextType {
144 Both = "bothSides",
145}}
146
147#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
148#[cfg_attr(test, derive(PartialEq))]
149#[xml(tag = "wp:wrapThrough")]
150pub struct WrapThrough {}
151
152#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
153#[cfg_attr(test, derive(PartialEq))]
154#[xml(tag = "wp:wrapTopAndBottom")]
155pub struct WrapTopAndBottom {}
156
157#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
158#[cfg_attr(test, derive(PartialEq))]
159#[xml(tag = "wp:positionH")]
160pub struct PositionHorizontal {
161 #[xml(attr = "relativeFrom")]
162 pub relative_from: Option<RelativeFromH>,
163 #[xml(flatten_text = "wp:posOffset", with = "crate::rounded_float")]
164 pub pos_offset: Option<isize>,
165}
166
167#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
168#[cfg_attr(test, derive(PartialEq))]
169#[xml(tag = "wp:positionV")]
170pub struct PositionVertical {
171 #[xml(attr = "relativeFrom")]
172 pub relative_from: Option<RelativeFromV>,
173 #[xml(flatten_text = "wp:posOffset", with = "crate::rounded_float")]
174 pub pos_offset: Option<isize>,
175}
176
177__define_enum! {
178 RelativeFromH {
179 Margin= "margin", Page = "page",Column= "column",Character= "character",LeftMargin= "leftMargin",RightMargin= "rightMargin",InsideMargin= "insideMargin",OUtsideMargin= "outsideMargin",}
188}
189
190__define_enum! {
191 RelativeFromV {
192 Margin= "margin", Page = "page",Paragraph= "paragraph",Line= "line",TopMargin= "topMargin",BottomMargin= "bottomMargin",InsideMargin= "insideMargin",OUtsideMargin= "outsideMargin",}
201}
202
203#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
204#[cfg_attr(test, derive(PartialEq))]
205#[xml(tag = "wp:inline")]
206pub struct Inline<'a> {
207 #[xml(attr = "distT", with = "crate::rounded_float")]
208 pub dist_t: Option<isize>,
209 #[xml(attr = "distB", with = "crate::rounded_float")]
210 pub dist_b: Option<isize>,
211 #[xml(attr = "distL", with = "crate::rounded_float")]
212 pub dist_l: Option<isize>,
213 #[xml(attr = "distR", with = "crate::rounded_float")]
214 pub dist_r: Option<isize>,
215 #[xml(attr = "simplePossimplePos", with = "crate::rounded_float")]
216 pub simple_pos_attr: Option<isize>,
217 #[xml(attr = "relativeHeight", with = "crate::rounded_float")]
218 pub relative_height: Option<isize>,
219 #[xml(attr = "behindDoc")]
220 pub behind_doc: Option<bool>,
221 #[xml(attr = "locked")]
222 pub locked: Option<bool>,
223 #[xml(attr = "layoutInCell")]
224 pub layout_in_cell: Option<bool>,
225 #[xml(attr = "allowOverlap")]
226 pub allow_overlap: Option<bool>,
227 #[xml(attr = "wp14:anchorId")]
228 pub anchor_id: Option<Cow<'a, str>>,
229 #[xml(attr = "wp14:editId")]
230 pub edit_id: Option<Cow<'a, str>>,
231
232 #[xml(child = "wp:simplePos")]
233 pub simple_pos: Option<SimplePos>,
234 #[xml(child = "wp:positionH")]
235 pub position_horizontal: Option<PositionHorizontal>,
236 #[xml(child = "wp:positionV")]
237 pub position_vertical: Option<PositionVertical>,
238 #[xml(child = "wp:extent")]
239 pub extent: Option<Extent>,
240 #[xml(child = "wp:docPr")]
241 pub doc_property: DocPr<'a>,
242 #[xml(child = "a:graphic")]
243 pub graphic: Option<Graphic<'a>>,
244}
245
246#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
247#[cfg_attr(test, derive(PartialEq))]
248#[xml(tag = "wp:docPr")]
249pub struct DocPr<'a> {
250 #[xml(attr = "id", with = "crate::rounded_float")]
251 pub id: Option<isize>,
252 #[xml(attr = "name")]
253 pub name: Option<Cow<'a, str>>,
254 #[xml(attr = "descr")]
255 pub descr: Option<Cow<'a, str>>,
256}
257
258#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
259#[cfg_attr(test, derive(PartialEq))]
260#[xml(tag = "a:graphic")]
261pub struct Graphic<'a> {
262 #[xml(default, attr = "xmlns:a")]
263 pub a: Cow<'a, str>,
264 #[xml(default, child = "a:graphicData")]
265 pub data: GraphicData<'a>,
266}
267
268#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
269#[cfg_attr(test, derive(PartialEq))]
270#[xml(tag = "a:graphicData")]
271pub struct GraphicData<'a> {
272 #[xml(default, attr = "uri")]
273 pub uri: Cow<'a, str>,
274 #[xml(child = "pic:pic")]
276 pub children: Vec<Picture<'a>>,
277}
278
279#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
280#[cfg_attr(test, derive(PartialEq))]
281#[xml(tag = "pic:pic")]
282pub struct Picture<'a> {
283 #[xml(default, attr = "xmlns:pic")]
284 pub a: Cow<'a, str>,
285 #[xml(child = "pic:nvPicPr")]
286 pub nv_pic_pr: NvPicPr<'a>,
287 #[xml(child = "pic:blipFill")]
288 pub fill: BlipFill<'a>,
289 #[xml(child = "pic:spPr")]
290 pub sp_pr: SpPr<'a>,
291}
292
293#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
294#[cfg_attr(test, derive(PartialEq))]
295#[xml(tag = "pic:spPr")]
296pub struct SpPr<'a> {
297 #[xml(child = "a:xfrm")]
298 pub xfrm: Option<Xfrm>,
299 #[xml(child = "a:prstGeom")]
300 pub prst_geom: Option<PrstGeom<'a>>,
301}
302
303#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
304#[cfg_attr(test, derive(PartialEq))]
305#[xml(tag = "a:prstGeom")]
306pub struct PrstGeom<'a> {
307 #[xml(attr = "prst")]
308 pub prst: Option<Cow<'a, str>>,
309 #[xml(child = "a:avLst")]
310 pub av_lst: Option<AvList>,
311}
312
313#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
314#[cfg_attr(test, derive(PartialEq))]
315#[xml(tag = "a:avLst")]
316pub struct AvList {}
317
318#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
319#[cfg_attr(test, derive(PartialEq))]
320#[xml(tag = "a:xfrm")]
321pub struct Xfrm {
322 #[xml(child = "a:off")]
323 pub offset: Option<Offset>,
324 #[xml(child = "a:ext")]
325 pub ext: Option<Ext>,
326}
327
328#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
329#[cfg_attr(test, derive(PartialEq))]
330#[xml(tag = "a:ext")]
331pub struct Ext {
332 #[xml(attr = "cx", with = "crate::rounded_float")]
333 pub cx: Option<isize>,
334 #[xml(attr = "cy", with = "crate::rounded_float")]
335 pub cy: Option<isize>,
336}
337
338#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
339#[cfg_attr(test, derive(PartialEq))]
340#[xml(tag = "a:off")]
341pub struct Offset {
342 #[xml(attr = "x", with = "crate::rounded_float")]
343 pub x: Option<isize>,
344 #[xml(attr = "y", with = "crate::rounded_float")]
345 pub y: Option<isize>,
346}
347
348#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
349#[cfg_attr(test, derive(PartialEq))]
350#[xml(tag = "wp:simplePos")]
351pub struct SimplePos {
352 #[xml(attr = "x", with = "crate::rounded_float")]
353 pub x: Option<isize>,
354 #[xml(attr = "y", with = "crate::rounded_float")]
355 pub y: Option<isize>,
356}
357
358#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
359#[cfg_attr(test, derive(PartialEq))]
360#[xml(tag = "pic:nvPicPr")]
361pub struct NvPicPr<'a> {
362 #[xml(child = "pic:cNvPr")]
363 pub c_nv_pr: Option<CNvPr<'a>>,
364 #[xml(child = "pic:cNvPicPr")]
365 pub c_nv_pic_pr: Option<CNvPicPr>,
366}
367
368#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
369#[cfg_attr(test, derive(PartialEq))]
370#[xml(tag = "pic:cNvPr")]
371pub struct CNvPr<'a> {
372 #[xml(attr = "id", with = "crate::rounded_float")]
373 pub id: Option<isize>,
374 #[xml(attr = "name")]
375 pub name: Option<Cow<'a, str>>,
376 #[xml(attr = "descr")]
377 pub descr: Option<Cow<'a, str>>,
378}
379
380#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
381#[cfg_attr(test, derive(PartialEq))]
382#[xml(tag = "pic:cNvPicPr")]
383pub struct CNvPicPr {}
384
385#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
386#[cfg_attr(test, derive(PartialEq))]
387#[xml(tag = "pic:blipFill")]
388pub struct BlipFill<'a> {
389 #[xml(default, child = "a:blip")]
390 pub blip: Blip<'a>,
391 #[xml(child = "a:stretch")]
392 pub stretch: Option<Stretch>,
393}
394
395#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
396#[cfg_attr(test, derive(PartialEq))]
397#[xml(tag = "a:blip")]
398pub struct Blip<'a> {
399 #[xml(default, attr = "r:embed")]
400 pub embed: Cow<'a, str>,
401 #[xml(default, attr = "cstate")]
402 pub cstate: Option<Cow<'a, str>>,
403}
404
405#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
406#[cfg_attr(test, derive(PartialEq))]
407#[xml(tag = "a:stretch")]
408pub struct Stretch {
409 #[xml(child = "a:fillRect")]
410 pub fill_rect: Option<FillRect>,
411}
412
413#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
414#[cfg_attr(test, derive(PartialEq))]
415#[xml(tag = "a:fillRect")]
416pub struct FillRect {}
417
418#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
419#[cfg_attr(test, derive(PartialEq))]
420#[xml(tag = "wp:extent")]
421pub struct Extent {
422 #[xml(default, attr = "cx", with = "crate::rounded_float")]
423 pub cx: isize,
424
425 #[xml(default, attr = "cy", with = "crate::rounded_float")]
426 pub cy: isize,
427}