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
82
use anyhow::bail;
use quick_xml::events::BytesStart;
use std::io::Read;
use crate::excel::XmlReader;
use crate::helper::string_to_unsignedint;
use crate::raw::drawing::color::XlsxColorEnum;
/// innerShdw (Inner Shadow Effect
///
/// specifies an inner shadow effect.
/// A shadow is applied within the edges of the object according to the parameters given by the attributes
///
/// Example:
/// ```
/// <a:innerShdw blurRad="10" dir"90" dist="10">
/// <a:schemeClr val="phClr">
/// <a:lumMod val="99000" />
/// <a:satMod val="120000" />
/// a:shade val="78000" />
/// </a:schemeClr>
/// </a:innerShdw>
/// ```
///
/// https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.drawing.innershadow?view=openxml-3.0.1
#[derive(Debug, Clone, PartialEq)]
pub struct XlsxInnerShadow {
// children
pub color: Option<XlsxColorEnum>,
// attribute
/// blurRad
///
/// Specifies the blur radius in emu.
pub blur_rad: Option<u64>,
/// Specifies the direction to offset the shadow as angle
pub dir: Option<u64>,
/// Specifies how far to offset the shadow
pub dist: Option<u64>,
}
impl XlsxInnerShadow {
pub(crate) fn load(reader: &mut XmlReader<impl Read>, e: &BytesStart) -> anyhow::Result<Self> {
let attributes = e.attributes();
let mut shadow = Self {
color: None,
blur_rad: None,
dir: None,
dist: None,
};
for a in attributes {
match a {
Ok(a) => {
let string_value = String::from_utf8(a.value.to_vec())?;
match a.key.local_name().as_ref() {
b"blurRad" => {
shadow.blur_rad = string_to_unsignedint(&string_value);
}
b"dir" => {
shadow.dir = string_to_unsignedint(&string_value);
}
b"dist" => {
shadow.dist = string_to_unsignedint(&string_value);
}
_ => {}
}
}
Err(error) => {
bail!(error.to_string())
}
}
}
shadow.color = XlsxColorEnum::load(reader, b"innerShdw")?;
Ok(shadow)
}
}