umya_spreadsheet/structs/drawing/
line_style_list.rs1use std::io::Cursor;
2
3use quick_xml::{
4 Reader,
5 Writer,
6 events::{
7 BytesStart,
8 Event,
9 },
10};
11
12use super::Outline;
13use crate::{
14 reader::driver::xml_read_loop,
15 writer::driver::{
16 write_end_tag,
17 write_start_tag,
18 },
19};
20
21#[derive(Clone, Default, Debug)]
22pub struct LineStyleList {
23 outline_collection: Vec<Outline>,
24}
25
26impl LineStyleList {
27 #[inline]
28 #[must_use]
29 pub fn outline_collection(&self) -> &[Outline] {
30 &self.outline_collection
31 }
32
33 #[inline]
34 #[must_use]
35 #[deprecated(since = "3.0.0", note = "Use outline_collection()")]
36 pub fn get_outline_collection(&self) -> &[Outline] {
37 self.outline_collection()
38 }
39
40 #[inline]
41 pub fn outline_collection_mut(&mut self) -> &mut Vec<Outline> {
42 &mut self.outline_collection
43 }
44
45 #[inline]
46 #[deprecated(since = "3.0.0", note = "Use outline_collection_mut()")]
47 pub fn get_outline_collection_mut(&mut self) -> &mut Vec<Outline> {
48 self.outline_collection_mut()
49 }
50
51 #[inline]
52 pub fn set_outline_collection(&mut self, value: impl Into<Vec<Outline>>) -> &mut Self {
53 self.outline_collection = value.into();
54 self
55 }
56
57 #[inline]
58 pub fn add_outline_collection(&mut self, value: Outline) -> &mut Self {
59 self.outline_collection.push(value);
60 self
61 }
62
63 pub(crate) fn set_attributes<R: std::io::BufRead>(
64 &mut self,
65 reader: &mut Reader<R>,
66 _e: &BytesStart,
67 ) {
68 xml_read_loop!(
69 reader,
70 Event::Start(ref e) => {
71 if e.name().into_inner() == b"a:ln" {
72 let mut obj = Outline::default();
73 obj.set_attributes(reader, e);
74 self.outline_collection.push(obj);
75 }
76 },
77 Event::End(ref e) => {
78 if e.name().into_inner() == b"a:lnStyleLst" {
79 return
80 }
81 },
82 Event::Eof => panic!("Error: Could not find {} end element", "lnStyleLst")
83 );
84 }
85
86 pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
87 write_start_tag(writer, "a:lnStyleLst", vec![], false);
89
90 for v in &self.outline_collection {
92 v.write_to(writer);
93 }
94
95 write_end_tag(writer, "a:lnStyleLst");
96 }
97}