docx_reader/documents/elements/
run_property.rs1use serde::Serialize;
2
3use super::*;
4use crate::types::*;
5
6#[derive(Debug, Clone, Serialize, PartialEq, Default)]
7#[serde(rename_all = "camelCase")]
8pub struct RunProperty {
9 #[serde(skip_serializing_if = "Option::is_none")]
10 pub style: Option<RunStyle>,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 pub sz: Option<Sz>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 pub sz_cs: Option<SzCs>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 pub color: Option<Color>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 pub highlight: Option<Highlight>,
19 #[serde(skip_serializing_if = "Option::is_none")]
20 pub vert_align: Option<VertAlign>,
21 #[serde(skip_serializing_if = "Option::is_none")]
22 pub underline: Option<Underline>,
23 #[serde(skip_serializing_if = "Option::is_none")]
24 pub bold: Option<Bold>,
25 #[serde(skip_serializing_if = "Option::is_none")]
26 pub bold_cs: Option<BoldCs>,
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub caps: Option<Caps>,
29 #[serde(skip_serializing_if = "Option::is_none")]
30 pub italic: Option<Italic>,
31 #[serde(skip_serializing_if = "Option::is_none")]
32 pub italic_cs: Option<ItalicCs>,
33 #[serde(skip_serializing_if = "Option::is_none")]
34 pub vanish: Option<Vanish>,
35 #[serde(skip_serializing_if = "Option::is_none")]
36 pub spec_vanish: Option<SpecVanish>,
37 #[serde(skip_serializing_if = "Option::is_none")]
38 pub character_spacing: Option<CharacterSpacing>,
39 #[serde(skip_serializing_if = "Option::is_none")]
40 pub fonts: Option<RunFonts>,
41 #[serde(skip_serializing_if = "Option::is_none")]
42 pub text_border: Option<TextBorder>,
43 #[serde(skip_serializing_if = "Option::is_none")]
44 pub del: Option<Delete>,
45 #[serde(skip_serializing_if = "Option::is_none")]
46 pub ins: Option<Insert>,
47 #[serde(skip_serializing_if = "Option::is_none")]
48 pub strike: Option<Strike>,
49}
50
51impl RunProperty {
52 pub fn new() -> RunProperty {
53 Default::default()
54 }
55
56 pub fn style(mut self, style_id: &str) -> Self {
57 self.style = Some(RunStyle::new(style_id));
58 self
59 }
60
61 pub fn size(mut self, size: usize) -> RunProperty {
62 self.sz = Some(Sz::new(size));
63 self.sz_cs = Some(SzCs::new(size));
64 self
65 }
66
67 pub fn spacing(mut self, spacing: i32) -> RunProperty {
68 self.character_spacing = Some(CharacterSpacing::new(spacing));
69 self
70 }
71
72 pub fn color(mut self, color: impl Into<String>) -> RunProperty {
73 self.color = Some(Color::new(color));
74 self
75 }
76
77 pub fn highlight(mut self, color: impl Into<String>) -> RunProperty {
78 self.highlight = Some(Highlight::new(color));
79 self
80 }
81
82 pub fn vert_align(mut self, a: VertAlignType) -> Self {
83 self.vert_align = Some(VertAlign::new(a));
84 self
85 }
86
87 pub fn bold(mut self) -> RunProperty {
88 self.bold = Some(Bold::new());
89 self.bold_cs = Some(BoldCs::new());
90 self
91 }
92
93 pub fn disable_bold(mut self) -> RunProperty {
94 self.bold = Some(Bold::new().disable());
95 self.bold_cs = Some(BoldCs::new().disable());
96 self
97 }
98
99 pub fn caps(mut self) -> RunProperty {
100 self.caps = Some(Caps::new());
101 self
102 }
103
104 pub fn italic(mut self) -> RunProperty {
105 self.italic = Some(Italic::new());
106 self.italic_cs = Some(ItalicCs::new());
107 self
108 }
109
110 pub fn strike(mut self) -> RunProperty {
111 self.strike = Some(Strike::new());
112 self
113 }
114
115 pub fn disable_italic(mut self) -> RunProperty {
116 self.italic = Some(Italic::new().disable());
117 self.italic_cs = Some(ItalicCs::new().disable());
118 self
119 }
120
121 pub fn underline(mut self, line_type: impl Into<String>) -> RunProperty {
122 self.underline = Some(Underline::new(line_type));
123 self
124 }
125
126 pub fn vanish(mut self) -> RunProperty {
127 self.vanish = Some(Vanish::new());
128 self
129 }
130
131 pub fn spec_vanish(mut self) -> RunProperty {
132 self.spec_vanish = Some(SpecVanish::new());
133 self
134 }
135
136 pub fn fonts(mut self, font: RunFonts) -> RunProperty {
137 self.fonts = Some(font);
138 self
139 }
140
141 pub fn text_border(mut self, b: TextBorder) -> Self {
142 self.text_border = Some(b);
143 self
144 }
145
146 pub fn delete(mut self, d: Delete) -> Self {
147 self.del = Some(d);
148 self
149 }
150
151 pub fn insert(mut self, i: Insert) -> Self {
152 self.ins = Some(i);
153 self
154 }
155}