umya_spreadsheet/structs/
strike.rs

1// strike
2use super::BooleanValue;
3use crate::reader::driver::*;
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, Eq, Ord, PartialEq, PartialOrd)]
11pub struct Strike {
12    pub(crate) val: BooleanValue,
13}
14
15impl Strike {
16    #[inline]
17    pub fn get_val(&self) -> &bool {
18        self.val.get_value()
19    }
20
21    #[inline]
22    pub fn set_val(&mut self, value: bool) -> &mut Self {
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    ) {
33        self.val.set_value(true);
34        set_string_from_xml!(self, e, val, "val");
35    }
36
37    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
38        // strike
39        if !self.val.has_value() {
40            return;
41        }
42
43        let mut attributes: Vec<(&str, &str)> = Vec::new();
44        if !*self.val.get_value() {
45            attributes.push(("val", self.val.get_value_string()));
46        }
47        write_start_tag(writer, "strike", attributes, true);
48    }
49}