umya_spreadsheet/structs/drawing/
miter.rs1use std::io::Cursor;
3
4use quick_xml::{
5 Reader,
6 Writer,
7 events::{
8 BytesStart,
9 Event,
10 },
11};
12
13use crate::{
14 Int32Value,
15 reader::driver::{
16 get_attribute,
17 set_string_from_xml,
18 xml_read_loop,
19 },
20 writer::driver::write_start_tag,
21};
22
23#[derive(Clone, Default, Debug)]
24pub struct Miter {
25 limit: Int32Value,
26}
27
28impl Miter {
29 #[inline]
30 #[must_use]
31 pub fn limit(&self) -> i32 {
32 self.limit.value()
33 }
34
35 #[inline]
36 #[must_use]
37 #[deprecated(since = "3.0.0", note = "Use limit()")]
38 pub fn get_limit(&self) -> i32 {
39 self.limit()
40 }
41
42 #[inline]
43 pub fn set_limit(&mut self, value: i32) -> &mut Self {
44 self.limit.set_value(value);
45 self
46 }
47
48 #[inline]
49 pub(crate) fn set_attributes<R: std::io::BufRead>(
50 &mut self,
51 reader: &mut Reader<R>,
52 e: &BytesStart,
53 empty_flag: bool,
54 ) {
55 set_string_from_xml!(self, e, limit, "lim");
56
57 if empty_flag {
58 return;
59 }
60
61 xml_read_loop!(
62 reader,
63 Event::End(ref e) => {
64 if e.name().into_inner() == b"a:miter" {
65 return;
66 }
67 },
68 Event::Eof => panic!("Error: Could not find {} end element", "a:miter")
69 );
70 }
71
72 pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
73 let mut attributes: crate::structs::AttrCollection = Vec::new();
75 let lim = self.limit.value_string();
76 if self.limit.has_value() {
77 attributes.push(("lim", &lim).into());
78 }
79 write_start_tag(writer, "a:miter", attributes, true);
80 }
81}