umya_spreadsheet/structs/vml/
shadow.rs1use crate::reader::driver::*;
2use crate::structs::StringValue;
3use crate::structs::TrueFalseValue;
4use crate::writer::driver::*;
5use quick_xml::events::BytesStart;
6use quick_xml::Reader;
7use quick_xml::Writer;
8use std::io::Cursor;
9
10#[derive(Clone, Default, Debug)]
11pub struct Shadow {
12 on: TrueFalseValue,
13 color: StringValue,
14 obscured: TrueFalseValue,
15}
16impl Shadow {
17 pub fn get_on(&self) -> &bool {
18 self.on.get_value()
19 }
20
21 pub fn set_on(&mut self, value: bool) -> &mut Self {
22 self.on.set_value(value);
23 self
24 }
25
26 pub fn get_color(&self) -> &str {
27 self.color.get_value_str()
28 }
29
30 pub fn set_color<S: Into<String>>(&mut self, value: S) -> &mut Self {
31 self.color.set_value(value);
32 self
33 }
34
35 pub fn get_obscured(&self) -> &bool {
36 self.obscured.get_value()
37 }
38
39 pub fn set_obscured(&mut self, value: bool) -> &mut Self {
40 self.obscured.set_value(value);
41 self
42 }
43
44 pub(crate) fn set_attributes<R: std::io::BufRead>(
45 &mut self,
46 _reader: &mut Reader<R>,
47 e: &BytesStart,
48 ) {
49 set_string_from_xml!(self, e, on, "on");
50 set_string_from_xml!(self, e, color, "color");
51 set_string_from_xml!(self, e, obscured, "obscured");
52 }
53
54 pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
55 let mut attributes: Vec<(&str, &str)> = Vec::new();
57 if self.on.has_value() {
58 attributes.push(("on", self.on.get_value_string()));
59 }
60 if self.color.has_value() {
61 attributes.push(("color", self.color.get_value_str()));
62 }
63 if self.obscured.has_value() {
64 attributes.push(("obscured", self.obscured.get_value_string()));
65 }
66 write_start_tag(writer, "v:shadow", attributes, true);
67 }
68}