umya_spreadsheet/structs/drawing/charts/
string_point.rs1use crate::xml_read_loop;
2
3use super::NumericValue;
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 StringPoint {
13 numeric_value: NumericValue,
14}
15
16impl StringPoint {
17 pub fn get_numeric_value(&self) -> &NumericValue {
18 &self.numeric_value
19 }
20
21 pub fn get_numeric_value_mut(&mut self) -> &mut NumericValue {
22 &mut self.numeric_value
23 }
24
25 pub fn set_numeric_value(&mut self, value: NumericValue) -> &mut Self {
26 self.numeric_value = value;
27 self
28 }
29
30 pub(crate) fn set_attributes<R: std::io::BufRead>(
31 &mut self,
32 reader: &mut Reader<R>,
33 _e: &BytesStart,
34 ) {
35 xml_read_loop!(
36 reader,
37 Event::Start(ref e) => {
38 if e.name().0 == b"c:v" {
39 self.numeric_value.set_attributes(reader, e);
40 }
41 },
42 Event::End(ref e) => {
43 if e.name().0 == b"c:pt" {
44 return;
45 }
46 },
47 Event::Eof => panic!("Error: Could not find {} end element", "c:pt"),
48 );
49 }
50
51 pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>, index: &u32) {
52 let index_str = index.to_string();
54 write_start_tag(writer, "c:pt", vec![("idx", &index_str)], false);
55
56 self.numeric_value.write_to(writer);
58
59 write_end_tag(writer, "c:pt");
60 }
61}