docx_reader/documents/elements/
doc_grid.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
use serde::{Deserialize, Serialize};

use crate::types::*;

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DocGrid {
	grid_type: DocGridType,
	line_pitch: Option<usize>,
	char_space: Option<isize>,
}

impl DocGrid {
	pub fn new() -> Self {
		Self::default()
	}

	pub fn with_empty() -> Self {
		Self {
			grid_type: DocGridType::Default,
			line_pitch: None,
			char_space: None,
		}
	}

	pub fn grid_type(mut self, t: DocGridType) -> Self {
		self.grid_type = t;
		self
	}

	pub fn line_pitch(mut self, line_pitch: usize) -> Self {
		self.line_pitch = Some(line_pitch);
		self
	}

	pub fn char_space(mut self, char_space: isize) -> Self {
		self.char_space = Some(char_space);
		self
	}
}

impl Default for DocGrid {
	fn default() -> Self {
		Self {
			grid_type: DocGridType::Lines,
			line_pitch: Some(360),
			char_space: None,
		}
	}
}