umya_spreadsheet/structs/drawing/
effect_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::EffectStyle;
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 EffectStyleList {
23 effect_style_collection: Vec<EffectStyle>,
24}
25
26impl EffectStyleList {
27 #[inline]
28 #[must_use]
29 pub fn effect_style_collection(&self) -> &[EffectStyle] {
30 &self.effect_style_collection
31 }
32
33 #[inline]
34 #[must_use]
35 #[deprecated(since = "3.0.0", note = "Use effect_style_collection()")]
36 pub fn get_effect_style_collection(&self) -> &[EffectStyle] {
37 self.effect_style_collection()
38 }
39
40 #[inline]
41 pub fn effect_style_collection_mut(&mut self) -> &mut Vec<EffectStyle> {
42 &mut self.effect_style_collection
43 }
44
45 #[inline]
46 #[deprecated(since = "3.0.0", note = "Use effect_style_collection_mut()")]
47 pub fn get_effect_style_collection_mut(&mut self) -> &mut Vec<EffectStyle> {
48 self.effect_style_collection_mut()
49 }
50
51 #[inline]
52 pub fn set_effect_style_collection(&mut self, value: impl Into<Vec<EffectStyle>>) -> &mut Self {
53 self.effect_style_collection = value.into();
54 self
55 }
56
57 #[inline]
58 pub fn add_effect_style_collection(&mut self, value: EffectStyle) -> &mut Self {
59 self.effect_style_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:effectStyle" {
72 let mut obj = EffectStyle::default();
73 obj.set_attributes(reader, e);
74 self.effect_style_collection.push(obj);
75 }
76 },
77 Event::End(ref e) => {
78 if e.name().into_inner() == b"a:effectStyleLst" {
79 return
80 }
81 },
82 Event::Eof => panic!("Error: Could not find {} end element", "a:effectStyleLst")
83 );
84 }
85
86 pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
87 write_start_tag(writer, "a:effectStyleLst", vec![], false);
89
90 for v in &self.effect_style_collection {
92 v.write_to(writer);
93 }
94
95 write_end_tag(writer, "a:effectStyleLst");
96 }
97}