docx_reader/documents/elements/
run_property.rs

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
use serde::Serialize;

use super::*;
use crate::types::*;

#[derive(Debug, Clone, Serialize, PartialEq, Default)]
#[serde(rename_all = "camelCase")]
pub struct RunProperty {
	#[serde(skip_serializing_if = "Option::is_none")]
	pub style: Option<RunStyle>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub sz: Option<Sz>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub sz_cs: Option<SzCs>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub color: Option<Color>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub highlight: Option<Highlight>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub vert_align: Option<VertAlign>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub underline: Option<Underline>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub bold: Option<Bold>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub bold_cs: Option<BoldCs>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub caps: Option<Caps>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub italic: Option<Italic>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub italic_cs: Option<ItalicCs>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub vanish: Option<Vanish>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub spec_vanish: Option<SpecVanish>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub character_spacing: Option<CharacterSpacing>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub fonts: Option<RunFonts>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub text_border: Option<TextBorder>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub del: Option<Delete>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub ins: Option<Insert>,
	#[serde(skip_serializing_if = "Option::is_none")]
	pub strike: Option<Strike>,
}

impl RunProperty {
	pub fn new() -> RunProperty {
		Default::default()
	}

	pub fn style(mut self, style_id: &str) -> Self {
		self.style = Some(RunStyle::new(style_id));
		self
	}

	pub fn size(mut self, size: usize) -> RunProperty {
		self.sz = Some(Sz::new(size));
		self.sz_cs = Some(SzCs::new(size));
		self
	}

	pub fn spacing(mut self, spacing: i32) -> RunProperty {
		self.character_spacing = Some(CharacterSpacing::new(spacing));
		self
	}

	pub fn color(mut self, color: impl Into<String>) -> RunProperty {
		self.color = Some(Color::new(color));
		self
	}

	pub fn highlight(mut self, color: impl Into<String>) -> RunProperty {
		self.highlight = Some(Highlight::new(color));
		self
	}

	pub fn vert_align(mut self, a: VertAlignType) -> Self {
		self.vert_align = Some(VertAlign::new(a));
		self
	}

	pub fn bold(mut self) -> RunProperty {
		self.bold = Some(Bold::new());
		self.bold_cs = Some(BoldCs::new());
		self
	}

	pub fn disable_bold(mut self) -> RunProperty {
		self.bold = Some(Bold::new().disable());
		self.bold_cs = Some(BoldCs::new().disable());
		self
	}

	pub fn caps(mut self) -> RunProperty {
		self.caps = Some(Caps::new());
		self
	}

	pub fn italic(mut self) -> RunProperty {
		self.italic = Some(Italic::new());
		self.italic_cs = Some(ItalicCs::new());
		self
	}

	pub fn strike(mut self) -> RunProperty {
		self.strike = Some(Strike::new());
		self
	}

	pub fn disable_italic(mut self) -> RunProperty {
		self.italic = Some(Italic::new().disable());
		self.italic_cs = Some(ItalicCs::new().disable());
		self
	}

	pub fn underline(mut self, line_type: impl Into<String>) -> RunProperty {
		self.underline = Some(Underline::new(line_type));
		self
	}

	pub fn vanish(mut self) -> RunProperty {
		self.vanish = Some(Vanish::new());
		self
	}

	pub fn spec_vanish(mut self) -> RunProperty {
		self.spec_vanish = Some(SpecVanish::new());
		self
	}

	pub fn fonts(mut self, font: RunFonts) -> RunProperty {
		self.fonts = Some(font);
		self
	}

	pub fn text_border(mut self, b: TextBorder) -> Self {
		self.text_border = Some(b);
		self
	}

	pub fn delete(mut self, d: Delete) -> Self {
		self.del = Some(d);
		self
	}

	pub fn insert(mut self, i: Insert) -> Self {
		self.ins = Some(i);
		self
	}
}