Skip to main content

umya_spreadsheet/structs/drawing/spreadsheet/
extent.rs

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