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
69
70
71
72
73
74
75
76
77
78
79
80
81
use crate::FormatColor;

pub struct FormatBorder<'a> {
    pub(crate) left: FormatBorderElement<'a>,
    pub(crate) right: FormatBorderElement<'a>,
    pub(crate) top: FormatBorderElement<'a>,
    pub(crate) bottom: FormatBorderElement<'a>,
    pub(crate) diagonal: FormatBorderElement<'a>,
}

#[derive(Copy, Clone)]
pub struct FormatBorderElement<'a> {
    pub(crate) border_type: FormatBorderType,
    pub(crate) color: FormatColor<'a>,
}

impl Default for FormatBorderElement<'_> {
    fn default() -> Self {
        Self {
            border_type: Default::default(),
            color: Default::default(),
        }
    }
}

impl Default for FormatBorder<'_> {
    fn default() -> Self {
        Self {
            left: Default::default(),
            right: Default::default(),
            top: Default::default(),
            bottom: Default::default(),
            diagonal: Default::default(),
        }
    }
}

#[derive(Copy, Clone)]
pub enum FormatBorderType {
    None,
    Thin,
    Medium,
    Dashed,
    Dotted,
    Thick,
    Double,
    Hair,
    MediumDashed,
    DashDot,
    MediumDashDot,
    DashDotDot,
    MediumDashDotDot,
    SlantDashDot,
}

impl Default for FormatBorderType {
    fn default() -> Self {
        Self::None
    }
}

impl FormatBorderType {
    pub(crate) fn to_str(&self) -> &str {
        match self {
            FormatBorderType::None => "none",
            FormatBorderType::Thin => "thin",
            FormatBorderType::Medium => "medium",
            FormatBorderType::Dashed => "dashed",
            FormatBorderType::Dotted => "dotted",
            FormatBorderType::Thick => "thick",
            FormatBorderType::Double => "double",
            FormatBorderType::Hair => "hair",
            FormatBorderType::MediumDashed => "mediumDashed",
            FormatBorderType::DashDot => "dashDot",
            FormatBorderType::MediumDashDot => "mediumDashDot",
            FormatBorderType::DashDotDot => "dashDotDot",
            FormatBorderType::MediumDashDotDot => "mediumDashDotDot",
            FormatBorderType::SlantDashDot => "slantDashDot",
        }
    }
}