umya_spreadsheet/structs/drawing/charts/
side_wall.rs

1// c:sideWall
2use super::ShapeProperties;
3use super::Thickness;
4use crate::reader::driver::*;
5use crate::writer::driver::*;
6use quick_xml::events::{BytesStart, Event};
7use quick_xml::Reader;
8use quick_xml::Writer;
9use std::io::Cursor;
10
11#[derive(Clone, Default, Debug)]
12pub struct SideWall {
13    thickness: Option<Thickness>,
14    shape_properties: Option<ShapeProperties>,
15}
16
17impl SideWall {
18    pub fn get_thickness(&self) -> Option<&Thickness> {
19        self.thickness.as_ref()
20    }
21
22    pub fn get_thickness_mut(&mut self) -> Option<&mut Thickness> {
23        self.thickness.as_mut()
24    }
25
26    pub fn set_thickness(&mut self, value: Thickness) -> &mut SideWall {
27        self.thickness = Some(value);
28        self
29    }
30
31    pub fn get_shape_properties(&self) -> Option<&ShapeProperties> {
32        self.shape_properties.as_ref()
33    }
34
35    pub fn get_shape_properties_mut(&mut self) -> Option<&mut ShapeProperties> {
36        self.shape_properties.as_mut()
37    }
38
39    pub fn set_shape_properties(&mut self, value: ShapeProperties) -> &mut Self {
40        self.shape_properties = Some(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        xml_read_loop!(
50            reader,
51            Event::Empty(ref e) => {
52                if e.name().0 == b"c:thickness" {
53                    let mut obj = Thickness::default();
54                    obj.set_attributes(reader, e);
55                    self.set_thickness(obj);
56                }
57            },
58            Event::Start(ref e) => {
59                if  e.name().0 == b"c:spPr" {
60                    let mut obj = ShapeProperties::default();
61                    obj.set_attributes(reader, e);
62                    self.set_shape_properties(obj);
63                }
64            },
65            Event::End(ref e) => {
66                if e.name().0 == b"c:sideWall" {
67                    return;
68                }
69            },
70            Event::Eof => panic!("Error: Could not find {} end element", "c:sideWall")
71        );
72    }
73
74    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
75        // c:sideWall
76        write_start_tag(writer, "c:sideWall", vec![], false);
77
78        // c:thickness
79        if let Some(v) = &self.thickness {
80            v.write_to(writer);
81        }
82
83        // c:spPr
84        if let Some(v) = &self.shape_properties {
85            v.write_to(writer);
86        }
87
88        write_end_tag(writer, "c:sideWall");
89    }
90}