Skip to main content

umya_spreadsheet/structs/drawing/
extents.rs

1// a:ext
2use std::io::Cursor;
3
4use quick_xml::{
5    Reader,
6    Writer,
7    events::BytesStart,
8};
9
10use super::super::super::Int64Value;
11use crate::{
12    reader::driver::get_attribute,
13    writer::driver::write_start_tag,
14};
15
16#[derive(Clone, Default, Debug)]
17pub struct Extents {
18    cx: Int64Value,
19    cy: Int64Value,
20}
21impl Extents {
22    #[inline]
23    #[must_use]
24    pub fn cx(&self) -> i64 {
25        self.cx.value()
26    }
27
28    #[inline]
29    #[must_use]
30    #[deprecated(since = "3.0.0", note = "Use cx()")]
31    pub fn get_cx(&self) -> i64 {
32        self.cx()
33    }
34
35    #[inline]
36    pub fn set_cx(&mut self, value: i64) -> &mut Extents {
37        self.cx.set_value(value);
38        self
39    }
40
41    #[inline]
42    #[must_use]
43    pub fn cy(&self) -> i64 {
44        self.cy.value()
45    }
46
47    #[inline]
48    #[must_use]
49    #[deprecated(since = "3.0.0", note = "Use cy()")]
50    pub fn get_cy(&self) -> i64 {
51        self.cy()
52    }
53
54    #[inline]
55    pub fn set_cy(&mut self, value: i64) -> &mut Extents {
56        self.cy.set_value(value);
57        self
58    }
59
60    #[inline]
61    pub(crate) fn set_attributes<R: std::io::BufRead>(
62        &mut self,
63        _reader: &mut Reader<R>,
64        e: &BytesStart,
65    ) {
66        self.cx.set_value_string(get_attribute(e, b"cx").unwrap());
67        self.cy.set_value_string(get_attribute(e, b"cy").unwrap());
68    }
69
70    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
71        // a:ext
72        write_start_tag(
73            writer,
74            "a:ext",
75            vec![
76                ("cx", self.cx.value_string()).into(),
77                ("cy", self.cy.value_string()).into(),
78            ],
79            true,
80        );
81    }
82}