umya_spreadsheet/structs/office2019/
threaded_comment_text.rs

1// text
2use crate::reader::driver::*;
3use crate::writer::driver::*;
4use md5::Digest;
5use quick_xml::events::{BytesStart, Event};
6use quick_xml::Reader;
7use quick_xml::Writer;
8use std::io::Cursor;
9
10#[derive(Clone, Default, Debug, Eq, Ord, PartialEq, PartialOrd)]
11pub(crate) struct ThreadedCommentText {
12    value: Box<str>,
13}
14
15impl ThreadedCommentText {
16    #[inline]
17    pub(crate) fn get_value(&self) -> &str {
18        &self.value
19    }
20
21    #[inline]
22    pub(crate) fn set_value<S: Into<String>>(&mut self, value: S) -> &mut Self {
23        self.value = value.into().into_boxed_str();
24        self
25    }
26
27    pub(crate) fn set_attributes<R: std::io::BufRead>(
28        &mut self,
29        reader: &mut Reader<R>,
30        _e: &BytesStart,
31    ) {
32        xml_read_loop!(
33            reader,
34            Event::Text(e) => {
35                self.set_value(e.unescape().unwrap());
36            },
37            Event::End(ref e) => {
38                if e.name().0 == b"text" {
39                    return
40                }
41            },
42            Event::Eof => panic!("Error: Could not find {} end element", "text")
43        );
44    }
45
46    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
47        // text
48        let mut attributes: Vec<(&str, &str)> = Vec::new();
49        write_start_tag(writer, "text", attributes, false);
50        write_text_node(writer, &*self.value);
51        write_end_tag(writer, "text");
52    }
53}