umya_spreadsheet/structs/drawing/
group_shape_locks.rs1use crate::reader::driver::*;
3use crate::structs::BooleanValue;
4use crate::writer::driver::*;
5use quick_xml::events::BytesStart;
6use quick_xml::Reader;
7use quick_xml::Writer;
8use std::io::Cursor;
9
10#[derive(Clone, Default, Debug)]
11pub struct GroupShapeLocks {
12 no_change_aspect: BooleanValue,
13 no_grouping: BooleanValue,
14 no_move: BooleanValue,
15 no_resize: BooleanValue,
16 no_rotation: BooleanValue,
17 no_selection: BooleanValue,
18 no_ungrouping: BooleanValue,
19}
20
21impl GroupShapeLocks {
22 #[inline]
23 pub fn get_no_change_aspect(&self) -> &bool {
24 self.no_change_aspect.get_value()
25 }
26
27 #[inline]
28 pub fn set_no_change_aspect(&mut self, value: bool) {
29 self.no_change_aspect.set_value(value);
30 }
31
32 pub(crate) fn set_attributes<R: std::io::BufRead>(
33 &mut self,
34 _reader: &mut Reader<R>,
35 e: &BytesStart,
36 ) {
37 set_string_from_xml!(self, e, no_change_aspect, "noChangeAspect");
38 set_string_from_xml!(self, e, no_grouping, "noGrp");
39 set_string_from_xml!(self, e, no_move, "noMove");
40 set_string_from_xml!(self, e, no_resize, "noResize");
41 set_string_from_xml!(self, e, no_rotation, "noRot");
42 set_string_from_xml!(self, e, no_selection, "noSelect");
43 set_string_from_xml!(self, e, no_ungrouping, "noUngrp");
44 }
45
46 pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
47 let mut attributes: Vec<(&str, &str)> = Vec::new();
49
50 let no_change_aspect_str = self.no_change_aspect.get_value_string();
51 if self.no_change_aspect.has_value() {
52 attributes.push(("noChangeAspect", &no_change_aspect_str));
53 }
54
55 let no_grouping_str = self.no_grouping.get_value_string();
56 if self.no_grouping.has_value() {
57 attributes.push(("noGrp", &no_grouping_str));
58 }
59
60 let no_move_str = self.no_move.get_value_string();
61 if self.no_move.has_value() {
62 attributes.push(("noMove", &no_move_str));
63 }
64
65 let no_resize_str = self.no_resize.get_value_string();
66 if self.no_resize.has_value() {
67 attributes.push(("noResize", &no_resize_str));
68 }
69
70 let no_rotation_str = self.no_rotation.get_value_string();
71 if self.no_rotation.has_value() {
72 attributes.push(("noRot", &no_rotation_str));
73 }
74
75 let no_selection_str = self.no_selection.get_value_string();
76 if self.no_selection.has_value() {
77 attributes.push(("noSelect", &no_selection_str));
78 }
79
80 let no_ungrouping_str = self.no_ungrouping.get_value_string();
81 if self.no_ungrouping.has_value() {
82 attributes.push(("noUngrp", &no_ungrouping_str));
83 }
84
85 write_start_tag(writer, "a:grpSpLocks", attributes, true);
86 }
87}