Skip to main content

umya_spreadsheet/structs/drawing/
group_shape_locks.rs

1// a:grpSpLocks
2use std::io::Cursor;
3
4use quick_xml::{
5    Reader,
6    Writer,
7    events::BytesStart,
8};
9
10use crate::{
11    reader::driver::{
12        get_attribute,
13        set_string_from_xml,
14    },
15    structs::BooleanValue,
16    writer::driver::write_start_tag,
17};
18
19#[derive(Clone, Default, Debug)]
20pub struct GroupShapeLocks {
21    no_change_aspect: BooleanValue,
22    no_grouping:      BooleanValue,
23    no_move:          BooleanValue,
24    no_resize:        BooleanValue,
25    no_rotation:      BooleanValue,
26    no_selection:     BooleanValue,
27    no_ungrouping:    BooleanValue,
28}
29
30impl GroupShapeLocks {
31    #[inline]
32    #[must_use]
33    pub fn no_change_aspect(&self) -> bool {
34        self.no_change_aspect.value()
35    }
36
37    #[inline]
38    #[must_use]
39    #[deprecated(since = "3.0.0", note = "Use no_change_aspect()")]
40    pub fn get_no_change_aspect(&self) -> bool {
41        self.no_change_aspect()
42    }
43
44    #[inline]
45    pub fn set_no_change_aspect(&mut self, value: bool) {
46        self.no_change_aspect.set_value(value);
47    }
48
49    #[inline]
50    #[must_use]
51    pub fn no_grouping(&self) -> bool {
52        self.no_grouping.value()
53    }
54
55    #[inline]
56    pub fn set_no_grouping(&mut self, value: bool) {
57        self.no_grouping.set_value(value);
58    }
59
60    #[inline]
61    #[must_use]
62    pub fn no_move(&self) -> bool {
63        self.no_move.value()
64    }
65
66    #[inline]
67    pub fn set_no_move(&mut self, value: bool) {
68        self.no_move.set_value(value);
69    }
70
71    #[inline]
72    #[must_use]
73    pub fn no_resize(&self) -> bool {
74        self.no_resize.value()
75    }
76
77    #[inline]
78    pub fn set_no_resize(&mut self, value: bool) {
79        self.no_resize.set_value(value);
80    }
81
82    #[inline]
83    #[must_use]
84    pub fn no_rotation(&self) -> bool {
85        self.no_rotation.value()
86    }
87
88    #[inline]
89    pub fn set_no_rotation(&mut self, value: bool) {
90        self.no_rotation.set_value(value);
91    }
92
93    #[inline]
94    #[must_use]
95    pub fn no_selection(&self) -> bool {
96        self.no_selection.value()
97    }
98
99    #[inline]
100    pub fn set_no_selection(&mut self, value: bool) {
101        self.no_selection.set_value(value);
102    }
103
104    #[inline]
105    #[must_use]
106    pub fn no_ungrouping(&self) -> bool {
107        self.no_ungrouping.value()
108    }
109
110    #[inline]
111    pub fn set_no_ungrouping(&mut self, value: bool) {
112        self.no_ungrouping.set_value(value);
113    }
114
115    pub(crate) fn set_attributes<R: std::io::BufRead>(
116        &mut self,
117        _reader: &mut Reader<R>,
118        e: &BytesStart,
119    ) {
120        set_string_from_xml!(self, e, no_change_aspect, "noChangeAspect");
121        set_string_from_xml!(self, e, no_grouping, "noGrp");
122        set_string_from_xml!(self, e, no_move, "noMove");
123        set_string_from_xml!(self, e, no_resize, "noResize");
124        set_string_from_xml!(self, e, no_rotation, "noRot");
125        set_string_from_xml!(self, e, no_selection, "noSelect");
126        set_string_from_xml!(self, e, no_ungrouping, "noUngrp");
127    }
128
129    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
130        // a:grpSpLocks
131        let mut attributes: crate::structs::AttrCollection = Vec::new();
132
133        let no_change_aspect_str = self.no_change_aspect.value_string();
134        if self.no_change_aspect.has_value() {
135            attributes.push(("noChangeAspect", no_change_aspect_str).into());
136        }
137
138        let no_grouping_str = self.no_grouping.value_string();
139        if self.no_grouping.has_value() {
140            attributes.push(("noGrp", no_grouping_str).into());
141        }
142
143        let no_move_str = self.no_move.value_string();
144        if self.no_move.has_value() {
145            attributes.push(("noMove", no_move_str).into());
146        }
147
148        let no_resize_str = self.no_resize.value_string();
149        if self.no_resize.has_value() {
150            attributes.push(("noResize", no_resize_str).into());
151        }
152
153        let no_rotation_str = self.no_rotation.value_string();
154        if self.no_rotation.has_value() {
155            attributes.push(("noRot", no_rotation_str).into());
156        }
157
158        let no_selection_str = self.no_selection.value_string();
159        if self.no_selection.has_value() {
160            attributes.push(("noSelect", no_selection_str).into());
161        }
162
163        let no_ungrouping_str = self.no_ungrouping.value_string();
164        if self.no_ungrouping.has_value() {
165            attributes.push(("noUngrp", no_ungrouping_str).into());
166        }
167
168        write_start_tag(writer, "a:grpSpLocks", attributes, true);
169    }
170}