umya_spreadsheet/structs/drawing/
extents.rs

1// a:ext
2use super::super::super::Int64Value;
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)]
11pub struct Extents {
12    cx: Int64Value,
13    cy: Int64Value,
14}
15impl Extents {
16    #[inline]
17    pub fn get_cx(&self) -> &i64 {
18        self.cx.get_value()
19    }
20
21    #[inline]
22    pub fn set_cx(&mut self, value: i64) -> &mut Extents {
23        self.cx.set_value(value);
24        self
25    }
26
27    #[inline]
28    pub fn get_cy(&self) -> &i64 {
29        self.cy.get_value()
30    }
31
32    #[inline]
33    pub fn set_cy(&mut self, value: i64) -> &mut Extents {
34        self.cy.set_value(value);
35        self
36    }
37
38    #[inline]
39    pub(crate) fn set_attributes<R: std::io::BufRead>(
40        &mut self,
41        _reader: &mut Reader<R>,
42        e: &BytesStart,
43    ) {
44        self.cx.set_value_string(get_attribute(e, b"cx").unwrap());
45        self.cy.set_value_string(get_attribute(e, b"cy").unwrap());
46    }
47
48    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
49        // a:ext
50        write_start_tag(
51            writer,
52            "a:ext",
53            vec![
54                ("cx", &self.cx.get_value_string()),
55                ("cy", &self.cy.get_value_string()),
56            ],
57            true,
58        );
59    }
60}