umya_spreadsheet/structs/drawing/
picture_locks.rs1use crate::reader::driver::*;
3use crate::writer::driver::*;
4use quick_xml::events::BytesStart;
5use quick_xml::Reader;
6use quick_xml::Writer;
7use std::io::Cursor;
8
9#[derive(Clone, Default, Debug)]
10pub struct PictureLocks {
11 no_change_aspect: bool,
12}
13
14impl PictureLocks {
15 #[inline]
16 pub fn get_no_change_aspect(&self) -> &bool {
17 &self.no_change_aspect
18 }
19
20 #[inline]
21 pub fn set_no_change_aspect(&mut self, value: bool) {
22 self.no_change_aspect = value;
23 }
24
25 #[inline]
26 pub(crate) fn set_attributes<R: std::io::BufRead>(
27 &mut self,
28 _reader: &mut Reader<R>,
29 e: &BytesStart,
30 ) {
31 if let Some(v) = get_attribute(e, b"noChangeAspect") {
32 if v == "1" {
33 self.set_no_change_aspect(true);
34 }
35 }
36 }
37
38 #[inline]
39 pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
40 let no_change_aspect = if self.no_change_aspect { "1" } else { "2" };
42 write_start_tag(
43 writer,
44 "a:picLocks",
45 vec![("noChangeAspect", no_change_aspect)],
46 true,
47 );
48 }
49}