docx_rust/formatting/
indent.rs

1#![allow(dead_code)]
2
3use hard_xml::{XmlRead, XmlWrite};
4
5use crate::__xml_test_suites;
6
7/// indent
8/// percent to one character.
9///
10/// ```rust
11/// use docx_rust::formatting::*;
12///
13/// let sz = Size::from(42isize);
14/// ```
15#[derive(Debug, XmlRead, XmlWrite, Clone, Default)]
16#[cfg_attr(test, derive(PartialEq))]
17#[xml(tag = "w:ind")]
18pub struct Indent {
19    #[xml(attr = "w:leftChars")]
20    pub left_chars: Option<isize>,
21    #[xml(attr = "w:left")]
22    pub left: Option<isize>,
23    #[xml(attr = "w:rightChars")]
24    pub right_chars: Option<isize>,
25    #[xml(attr = "w:right")]
26    pub right: Option<isize>,
27    #[xml(attr = "w:firstLineChars")]
28    pub first_line_chars: Option<isize>,
29    #[xml(attr = "w:firstLine")]
30    pub first_line: Option<isize>,
31    #[xml(attr = "w:hanging")]
32    pub hanging: Option<isize>,
33}
34
35impl Indent {
36    pub fn left<T>(mut self, val: T) -> Self
37    where
38        isize: From<T>,
39    {
40        self.left_chars = Some(val.into());
41        self.left = self.left_chars;
42        self
43    }
44
45    pub fn right<T>(mut self, val: T) -> Self
46    where
47        isize: From<T>,
48    {
49        self.right_chars = Some(val.into());
50        self.right = self.right_chars;
51        self
52    }
53
54    pub fn first_line<T>(mut self, val: T) -> Self
55    where
56        isize: From<T>,
57    {
58        self.first_line = Some(val.into());
59        self.first_line_chars = self.first_line;
60        self
61    }
62}
63
64__xml_test_suites!(
65    Indent,
66    Indent::default().first_line(200isize),
67    r#"<w:ind w:firstLineChars="200" w:firstLine="200"/>"#,
68);