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
#![allow(dead_code)]
use std::borrow::Cow;
use strong_xml::{XmlRead, XmlWrite};
use crate::{
__string_enum,
document::HeaderFooterReference,
formatting::{PageCols, PageGrid, PageMargin, PageSize},
};
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:sectPr")]
pub struct SectionProperty<'a> {
#[xml(attr = "w:rsidR")]
pub rsid_r: Option<Cow<'a, str>>,
#[xml(attr = "w:rsidRDefault")]
pub rsid_r_default: Option<Cow<'a, str>>,
#[xml(child = "w:headerReference", child = "w:footerReference")]
pub header_footer_references: Vec<HeaderFooterReference<'a>>,
#[xml(child = "w:type")]
pub ty: Option<SectionTypeP>,
#[xml(child = "w:pgSz")]
pub page_size: Option<PageSize>,
#[xml(child = "w:pgMar")]
pub page_margin: Option<PageMargin>,
#[xml(child = "w:cols")]
pub cols: Option<PageCols>,
#[xml(child = "w:titlePg")]
pub title_page: Option<TitlePage>,
#[xml(child = "w:docGrid")]
pub grid: Option<PageGrid<'a>>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:type")]
pub struct SectionTypeP {
#[xml(attr = "w:val")]
pub ty: Option<SectionType>,
}
#[derive(Debug, Clone)]
#[cfg_attr(test, derive(PartialEq))]
pub enum SectionType {
NextPage,
NextColumn,
Continuous,
EvenPage,
OddPage,
}
__string_enum! {
SectionType {
NextPage = "nextPage",
NextColumn = "nextColumn",
Continuous = "continuous",
EvenPage = "evenPage",
OddPage = "oddPage",
}
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:titlePg")]
pub struct TitlePage {}
impl<'a> SectionProperty<'a> {
fn first_page_has_diffrent_header_and_footer(&mut self, val: bool) -> &mut Self {
if val {
self.title_page = Some(TitlePage::default());
} else {
self.title_page = None;
}
self
}
}