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
use crate::core::units::Twip;
use super::document::BlockElement;
/// Section properties (`w:sectPr`).
#[derive(Debug, Clone, Default)]
pub struct SectionProperties {
/// Page size and orientation.
pub page_size: Option<PageSize>,
/// Page margin settings.
pub margins: Option<PageMargins>,
/// References to header parts.
pub header_refs: Vec<HeaderFooterRef>,
/// References to footer parts.
pub footer_refs: Vec<HeaderFooterRef>,
/// Number of text columns (if multi-column layout).
pub columns: Option<u32>,
}
/// Page dimensions.
#[derive(Debug, Clone)]
pub struct PageSize {
/// Page width in twips.
pub width: Twip,
/// Page height in twips.
pub height: Twip,
/// Page orientation (portrait or landscape).
pub orient: Option<PageOrientation>,
}
/// Page orientation.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PageOrientation {
/// Portrait orientation (height > width).
Portrait,
/// Landscape orientation (width > height).
Landscape,
}
/// Page margins.
#[derive(Debug, Clone)]
pub struct PageMargins {
/// Top margin in twips.
pub top: Twip,
/// Bottom margin in twips.
pub bottom: Twip,
/// Left margin in twips.
pub left: Twip,
/// Right margin in twips.
pub right: Twip,
/// Header distance from top edge in twips.
pub header: Option<Twip>,
/// Footer distance from bottom edge in twips.
pub footer: Option<Twip>,
/// Gutter width in twips.
pub gutter: Option<Twip>,
}
/// Reference to a header or footer part.
#[derive(Debug, Clone)]
pub struct HeaderFooterRef {
/// Which pages this header/footer applies to.
pub hf_type: HeaderFooterType,
/// Relationship ID referencing the header/footer part.
pub relationship_id: String,
}
/// Type of header/footer.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum HeaderFooterType {
/// Default header/footer (odd pages or all pages).
Default,
/// First-page header/footer.
First,
/// Even-page header/footer.
Even,
}
/// A parsed header or footer.
#[derive(Debug, Clone)]
pub struct HeaderFooter {
/// Which pages this applies to.
pub hf_type: HeaderFooterType,
/// Block content within the header or footer.
pub content: Vec<BlockElement>,
/// `true` if this came from a `<w:headerReference>`, `false` if
/// from a `<w:footerReference>`. Lets downstream consumers (e.g.
/// the markdown renderer) sort entries into headers vs footers
/// without trying to back-derive from cumulative ref counts.
pub is_header: bool,
}