docx_reader/documents/elements/
doc_grid.rs1use serde::{Deserialize, Serialize};
2
3use crate::types::*;
4
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
6#[serde(rename_all = "camelCase")]
7pub struct DocGrid {
8 grid_type: DocGridType,
9 line_pitch: Option<usize>,
10 char_space: Option<isize>,
11}
12
13impl DocGrid {
14 pub fn new() -> Self {
15 Self::default()
16 }
17
18 pub fn with_empty() -> Self {
19 Self {
20 grid_type: DocGridType::Default,
21 line_pitch: None,
22 char_space: None,
23 }
24 }
25
26 pub fn grid_type(mut self, t: DocGridType) -> Self {
27 self.grid_type = t;
28 self
29 }
30
31 pub fn line_pitch(mut self, line_pitch: usize) -> Self {
32 self.line_pitch = Some(line_pitch);
33 self
34 }
35
36 pub fn char_space(mut self, char_space: isize) -> Self {
37 self.char_space = Some(char_space);
38 self
39 }
40}
41
42impl Default for DocGrid {
43 fn default() -> Self {
44 Self {
45 grid_type: DocGridType::Lines,
46 line_pitch: Some(360),
47 char_space: None,
48 }
49 }
50}