umya_spreadsheet/structs/drawing/
preset_dash.rs

1// a:prstDash
2use super::super::EnumValue;
3use super::PresetLineDashValues;
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 PresetDash {
13    val: EnumValue<PresetLineDashValues>,
14}
15impl PresetDash {
16    #[inline]
17    pub fn get_val(&self) -> &PresetLineDashValues {
18        self.val.get_value()
19    }
20
21    #[inline]
22    pub fn set_val(&mut self, value: PresetLineDashValues) -> &mut PresetDash {
23        self.val.set_value(value);
24        self
25    }
26
27    #[inline]
28    pub(crate) fn set_attributes<R: std::io::BufRead>(
29        &mut self,
30        reader: &mut Reader<R>,
31        e: &BytesStart,
32        empty_flag: bool,
33    ) {
34        self.val.set_value_string(get_attribute(e, b"val").unwrap());
35
36        if empty_flag {
37            return;
38        }
39
40        xml_read_loop!(
41            reader,
42            Event::End(ref e) => {
43                if e.name().into_inner() == b"a:prstDash" {
44                    return;
45                }
46            },
47            Event::Eof => panic!("Error: Could not find {} end element", "a:prstDash")
48        );
49    }
50
51    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
52        // a:prstDash
53        write_start_tag(
54            writer,
55            "a:prstDash",
56            vec![("val", self.val.get_value_string())],
57            true,
58        );
59    }
60}