docx_reader/documents/
settings.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
use super::*;

use crate::types::CharacterSpacingValues;

use serde::Serialize;

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Settings {
	default_tab_stop: DefaultTabStop,
	zoom: Zoom,
	doc_id: Option<DocId>,
	doc_vars: Vec<DocVar>,
	even_and_odd_headers: bool,
	adjust_line_height_in_table: bool,
	#[serde(skip_serializing_if = "Option::is_none")]
	character_spacing_control: Option<CharacterSpacingValues>,
}

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

	pub fn doc_id(mut self, id: impl Into<String>) -> Self {
		self.doc_id = Some(DocId::new(id.into()));
		self
	}

	pub fn default_tab_stop(mut self, tab_stop: usize) -> Self {
		self.default_tab_stop = DefaultTabStop::new(tab_stop);
		self
	}

	pub fn add_doc_var(mut self, name: impl Into<String>, val: impl Into<String>) -> Self {
		self.doc_vars.push(DocVar::new(name, val));
		self
	}

	pub fn even_and_odd_headers(mut self) -> Self {
		self.even_and_odd_headers = true;
		self
	}

	pub fn adjust_line_height_in_table(mut self) -> Self {
		self.adjust_line_height_in_table = true;
		self
	}

	pub fn character_spacing_control(mut self, val: CharacterSpacingValues) -> Self {
		self.character_spacing_control = Some(val);
		self
	}
}

impl Default for Settings {
	fn default() -> Self {
		Self {
			default_tab_stop: DefaultTabStop::new(840),
			zoom: Zoom::new(100),
			doc_id: None,
			doc_vars: vec![],
			even_and_odd_headers: false,
			adjust_line_height_in_table: false,
			character_spacing_control: None,
		}
	}
}