umya_spreadsheet/structs/
strike.rs1use std::io::Cursor;
3
4use quick_xml::{
5 Reader,
6 Writer,
7 events::BytesStart,
8};
9
10use super::BooleanValue;
11use crate::{
12 reader::driver::{
13 get_attribute,
14 set_string_from_xml,
15 },
16 writer::driver::write_start_tag,
17};
18
19#[derive(Clone, Default, Debug, Eq, Ord, PartialEq, PartialOrd)]
20pub struct Strike {
21 pub(crate) val: BooleanValue,
22}
23
24impl Strike {
25 #[inline]
26 #[must_use]
27 pub fn val(&self) -> bool {
28 self.val.value()
29 }
30
31 #[inline]
32 #[must_use]
33 #[deprecated(since = "3.0.0", note = "Use val()")]
34 pub fn get_val(&self) -> bool {
35 self.val()
36 }
37
38 #[inline]
39 pub fn set_val(&mut self, value: bool) -> &mut Self {
40 self.val.set_value(value);
41 self
42 }
43
44 #[inline]
45 pub(crate) fn set_attributes<R: std::io::BufRead>(
46 &mut self,
47 _reader: &mut Reader<R>,
48 e: &BytesStart,
49 ) {
50 self.val.set_value(true);
51 set_string_from_xml!(self, e, val, "val");
52 }
53
54 pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
55 if !self.val.has_value() {
57 return;
58 }
59
60 let mut attributes: crate::structs::AttrCollection = Vec::new();
61 if !self.val.value() {
62 attributes.push(("val", self.val.value_string()).into());
63 }
64 write_start_tag(writer, "strike", attributes, true);
65 }
66}