umya_spreadsheet/structs/drawing/charts/
scaling.rs1use super::Orientation;
3use crate::reader::driver::*;
4use crate::writer::driver::*;
5use quick_xml::events::{BytesStart, Event};
6use quick_xml::Reader;
7use quick_xml::Writer;
8use std::io::Cursor;
9
10#[derive(Clone, Default, Debug)]
11pub struct Scaling {
12 orientation: Orientation,
13}
14
15impl Scaling {
16 pub fn get_orientation(&self) -> &Orientation {
17 &self.orientation
18 }
19
20 pub fn get_orientation_mut(&mut self) -> &mut Orientation {
21 &mut self.orientation
22 }
23
24 pub fn set_orientation(&mut self, value: Orientation) -> &mut Self {
25 self.orientation = value;
26 self
27 }
28
29 pub(crate) fn set_attributes<R: std::io::BufRead>(
30 &mut self,
31 reader: &mut Reader<R>,
32 _e: &BytesStart,
33 ) {
34 xml_read_loop!(
35 reader,
36 Event::Empty(ref e) => {
37 if e.name().0 == b"c:orientation" {
38 self.orientation.set_attributes(reader, e);
39 }
40 },
41 Event::End(ref e) => {
42 if e.name().0 == b"c:scaling" {
43 return;
44 }
45 },
46 Event::Eof => panic!("Error: Could not find {} end element", "c:scaling")
47 );
48 }
49
50 pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
51 write_start_tag(writer, "c:scaling", vec![], false);
53
54 self.orientation.write_to(writer);
56
57 write_end_tag(writer, "c:scaling");
58 }
59}