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
#![allow(dead_code)]

use strong_xml::{XmlRead, XmlWrite};

use crate::__xml_test_suites;

/// indent
/// percent to one character.
///
/// ```rust
/// use docx_rust::formatting::*;
///
/// let sz = Size::from(42isize);
/// ```
#[derive(Debug, XmlRead, XmlWrite, Clone, Default)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:ind")]
pub struct Indent {
    #[xml(attr = "w:leftChars")]
    pub left_chars: Option<isize>,
    #[xml(attr = "w:left")]
    pub left: Option<isize>,
    #[xml(attr = "w:rightChars")]
    pub right_chars: Option<isize>,
    #[xml(attr = "w:right")]
    pub right: Option<isize>,
    #[xml(attr = "w:firstLineChars")]
    pub first_line_chars: Option<isize>,
    #[xml(attr = "w:firstLine")]
    pub first_line: Option<isize>,
}

impl Indent {
    fn left<T>(mut self, val: T) -> Self
    where
        isize: From<T>,
    {
        self.left_chars = Some(val.into());
        self.left = self.left_chars;
        self
    }

    fn right<T>(mut self, val: T) -> Self
    where
        isize: From<T>,
    {
        self.right_chars = Some(val.into());
        self.right = self.right_chars;
        self
    }

    fn first_line<T>(mut self, val: T) -> Self
    where
        isize: From<T>,
    {
        self.first_line = Some(val.into());
        self.first_line_chars = self.first_line;
        self
    }
}

__xml_test_suites!(
    Indent,
    Indent::default().first_line(200isize),
    r#"<w:ind w:firstLineChars="200" w:firstLine="200"/>"#,
);