Skip to main content

umya_spreadsheet/structs/drawing/
preset_geometry.rs

1// a:prstGeom
2use std::io::Cursor;
3
4use quick_xml::{
5    Reader,
6    Writer,
7    events::{
8        BytesStart,
9        Event,
10    },
11};
12
13use super::adjust_value_list::AdjustValueList;
14use crate::{
15    reader::driver::{
16        get_attribute,
17        xml_read_loop,
18    },
19    writer::driver::{
20        write_end_tag,
21        write_start_tag,
22    },
23};
24
25#[derive(Clone, Default, Debug)]
26pub struct PresetGeometry {
27    geometry:          Box<str>,
28    adjust_value_list: AdjustValueList,
29}
30
31impl PresetGeometry {
32    // Geometry
33    pub const GEOMETRY_ACCENTBORDERCALLOUT1: &'static str = "accentBorderCallout1";
34    pub const GEOMETRY_ACCENTBORDERCALLOUT2: &'static str = "accentBorderCallout2";
35    pub const GEOMETRY_ACCENTBORDERCALLOUT3: &'static str = "accentBorderCallout3";
36    pub const GEOMETRY_ACCENTCALLOUT1: &'static str = "accentCallout1";
37    pub const GEOMETRY_ACCENTCALLOUT2: &'static str = "accentCallout2";
38    pub const GEOMETRY_ACCENTCALLOUT3: &'static str = "accentCallout3";
39    pub const GEOMETRY_ACTIONBUTTONBACKPREVIOUS: &'static str = "actionButtonBackPrevious";
40    pub const GEOMETRY_ACTIONBUTTONBEGINNING: &'static str = "actionButtonBeginning";
41    pub const GEOMETRY_ACTIONBUTTONBLANK: &'static str = "actionButtonBlank";
42    pub const GEOMETRY_ACTIONBUTTONDOCUMENT: &'static str = "actionButtonDocument";
43    pub const GEOMETRY_ACTIONBUTTONEND: &'static str = "actionButtonEnd";
44    pub const GEOMETRY_ACTIONBUTTONFORWARDNEXT: &'static str = "actionButtonForwardNext";
45    pub const GEOMETRY_ACTIONBUTTONHELP: &'static str = "actionButtonHelp";
46    pub const GEOMETRY_ACTIONBUTTONHOME: &'static str = "actionButtonHome";
47    pub const GEOMETRY_ACTIONBUTTONINFORMATION: &'static str = "actionButtonInformation";
48    pub const GEOMETRY_ACTIONBUTTONMOVIE: &'static str = "actionButtonMovie";
49    pub const GEOMETRY_ACTIONBUTTONRETURN: &'static str = "actionButtonReturn";
50    pub const GEOMETRY_ACTIONBUTTONSOUND: &'static str = "actionButtonSound";
51    pub const GEOMETRY_ARC: &'static str = "arc";
52    pub const GEOMETRY_BENTARROW: &'static str = "bentArrow";
53    pub const GEOMETRY_BENTCONNECTOR2: &'static str = "bentConnector2";
54    pub const GEOMETRY_BENTCONNECTOR3: &'static str = "bentConnector3";
55    pub const GEOMETRY_BENTCONNECTOR4: &'static str = "bentConnector4";
56    pub const GEOMETRY_BENTCONNECTOR5: &'static str = "bentConnector5";
57    pub const GEOMETRY_BENTUPARROW: &'static str = "bentUpArrow";
58    pub const GEOMETRY_BEVEL: &'static str = "bevel";
59    pub const GEOMETRY_BLOCKARC: &'static str = "blockArc";
60    pub const GEOMETRY_BORDERCALLOUT1: &'static str = "borderCallout1";
61    pub const GEOMETRY_BORDERCALLOUT2: &'static str = "borderCallout2";
62    pub const GEOMETRY_BORDERCALLOUT3: &'static str = "borderCallout3";
63    pub const GEOMETRY_BRACEPAIR: &'static str = "bracePair";
64    pub const GEOMETRY_BRACKETPAIR: &'static str = "bracketPair";
65    pub const GEOMETRY_CALLOUT1: &'static str = "callout1";
66    pub const GEOMETRY_CALLOUT2: &'static str = "callout2";
67    pub const GEOMETRY_CALLOUT3: &'static str = "callout3";
68    pub const GEOMETRY_CAN: &'static str = "can";
69    pub const GEOMETRY_CHARTPLUS: &'static str = "chartPlus";
70    pub const GEOMETRY_CHARTSTAR: &'static str = "chartStar";
71    pub const GEOMETRY_CHARTX: &'static str = "chartX";
72    pub const GEOMETRY_CHEVRON: &'static str = "chevron";
73    pub const GEOMETRY_CHORD: &'static str = "chord";
74    pub const GEOMETRY_CIRCULARARROW: &'static str = "circularArrow";
75    pub const GEOMETRY_CLOUD: &'static str = "cloud";
76    pub const GEOMETRY_CLOUDCALLOUT: &'static str = "cloudCallout";
77    pub const GEOMETRY_CORNER: &'static str = "corner";
78    pub const GEOMETRY_CORNERTABS: &'static str = "cornerTabs";
79    pub const GEOMETRY_CUBE: &'static str = "cube";
80    pub const GEOMETRY_CURVEDCONNECTOR2: &'static str = "curvedConnector2";
81    pub const GEOMETRY_CURVEDCONNECTOR3: &'static str = "curvedConnector3";
82    pub const GEOMETRY_CURVEDCONNECTOR4: &'static str = "curvedConnector4";
83    pub const GEOMETRY_CURVEDCONNECTOR5: &'static str = "curvedConnector5";
84    pub const GEOMETRY_CURVEDDOWNARROW: &'static str = "curvedDownArrow";
85    pub const GEOMETRY_CURVEDLEFTARROW: &'static str = "curvedLeftArrow";
86    pub const GEOMETRY_CURVEDRIGHTARROW: &'static str = "curvedRightArrow";
87    pub const GEOMETRY_CURVEDUPARROW: &'static str = "curvedUpArrow";
88    pub const GEOMETRY_DECAGON: &'static str = "decagon";
89    pub const GEOMETRY_DIAGSTRIPE: &'static str = "diagStripe";
90    pub const GEOMETRY_DIAMOND: &'static str = "diamond";
91    pub const GEOMETRY_DODECAGON: &'static str = "dodecagon";
92    pub const GEOMETRY_DONUT: &'static str = "donut";
93    pub const GEOMETRY_DOUBLEWAVE: &'static str = "doubleWave";
94    pub const GEOMETRY_DOWNARROW: &'static str = "downArrow";
95    pub const GEOMETRY_DOWNARROWCALLOUT: &'static str = "downArrowCallout";
96    pub const GEOMETRY_ELLIPSE: &'static str = "ellipse";
97    pub const GEOMETRY_ELLIPSERIBBON: &'static str = "ellipseRibbon";
98    pub const GEOMETRY_ELLIPSERIBBON2: &'static str = "ellipseRibbon2";
99    pub const GEOMETRY_FLOWCHARTALTERNATEPROCESS: &'static str = "flowChartAlternateProcess";
100    pub const GEOMETRY_FLOWCHARTCOLLATE: &'static str = "flowChartCollate";
101    pub const GEOMETRY_FLOWCHARTCONNECTOR: &'static str = "flowChartConnector";
102    pub const GEOMETRY_FLOWCHARTDECISION: &'static str = "flowChartDecision";
103    pub const GEOMETRY_FLOWCHARTDELAY: &'static str = "flowChartDelay";
104    pub const GEOMETRY_FLOWCHARTDISPLAY: &'static str = "flowChartDisplay";
105    pub const GEOMETRY_FLOWCHARTDOCUMENT: &'static str = "flowChartDocument";
106    pub const GEOMETRY_FLOWCHARTEXTRACT: &'static str = "flowChartExtract";
107    pub const GEOMETRY_FLOWCHARTINPUTOUTPUT: &'static str = "flowChartInputOutput";
108    pub const GEOMETRY_FLOWCHARTINTERNALSTORAGE: &'static str = "flowChartInternalStorage";
109    pub const GEOMETRY_FLOWCHARTMAGNETICDISK: &'static str = "flowChartMagneticDisk";
110    pub const GEOMETRY_FLOWCHARTMAGNETICDRUM: &'static str = "flowChartMagneticDrum";
111    pub const GEOMETRY_FLOWCHARTMAGNETICTAPE: &'static str = "flowChartMagneticTape";
112    pub const GEOMETRY_FLOWCHARTMANUALINPUT: &'static str = "flowChartManualInput";
113    pub const GEOMETRY_FLOWCHARTMANUALOPERATION: &'static str = "flowChartManualOperation";
114    pub const GEOMETRY_FLOWCHARTMERGE: &'static str = "flowChartMerge";
115    pub const GEOMETRY_FLOWCHARTMULTIDOCUMENT: &'static str = "flowChartMultidocument";
116    pub const GEOMETRY_FLOWCHARTOFFLINESTORAGE: &'static str = "flowChartOfflineStorage";
117    pub const GEOMETRY_FLOWCHARTOFFPAGECONNECTOR: &'static str = "flowChartOffpageConnector";
118    pub const GEOMETRY_FLOWCHARTONLINESTORAGE: &'static str = "flowChartOnlineStorage";
119    pub const GEOMETRY_FLOWCHARTOR: &'static str = "flowChartOr";
120    pub const GEOMETRY_FLOWCHARTPREDEFINEDPROCESS: &'static str = "flowChartPredefinedProcess";
121    pub const GEOMETRY_FLOWCHARTPREPARATION: &'static str = "flowChartPreparation";
122    pub const GEOMETRY_FLOWCHARTPROCESS: &'static str = "flowChartProcess";
123    pub const GEOMETRY_FLOWCHARTPUNCHEDCARD: &'static str = "flowChartPunchedCard";
124    pub const GEOMETRY_FLOWCHARTPUNCHEDTAPE: &'static str = "flowChartPunchedTape";
125    pub const GEOMETRY_FLOWCHARTSORT: &'static str = "flowChartSort";
126    pub const GEOMETRY_FLOWCHARTSUMMINGJUNCTION: &'static str = "flowChartSummingJunction";
127    pub const GEOMETRY_FLOWCHARTTERMINATOR: &'static str = "flowChartTerminator";
128    pub const GEOMETRY_FOLDERCORNER: &'static str = "folderCorner";
129    pub const GEOMETRY_FRAME: &'static str = "frame";
130    pub const GEOMETRY_FUNNEL: &'static str = "funnel";
131    pub const GEOMETRY_GEAR6: &'static str = "gear6";
132    pub const GEOMETRY_GEAR9: &'static str = "gear9";
133    pub const GEOMETRY_HALFFRAME: &'static str = "halfFrame";
134    pub const GEOMETRY_HEART: &'static str = "heart";
135    pub const GEOMETRY_HEPTAGON: &'static str = "heptagon";
136    pub const GEOMETRY_HEXAGON: &'static str = "hexagon";
137    pub const GEOMETRY_HOMEPLATE: &'static str = "homePlate";
138    pub const GEOMETRY_HORIZONTALSCROLL: &'static str = "horizontalScroll";
139    pub const GEOMETRY_IRREGULARSEAL1: &'static str = "irregularSeal1";
140    pub const GEOMETRY_IRREGULARSEAL2: &'static str = "irregularSeal2";
141    pub const GEOMETRY_LEFTARROW: &'static str = "leftArrow";
142    pub const GEOMETRY_LEFTARROWCALLOUT: &'static str = "leftArrowCallout";
143    pub const GEOMETRY_LEFTBRACE: &'static str = "leftBrace";
144    pub const GEOMETRY_LEFTBRACKET: &'static str = "leftBracket";
145    pub const GEOMETRY_LEFTCIRCULARARROW: &'static str = "leftCircularArrow";
146    pub const GEOMETRY_LEFTRIGHTARROW: &'static str = "leftRightArrow";
147    pub const GEOMETRY_LEFTRIGHTARROWCALLOUT: &'static str = "leftRightArrowCallout";
148    pub const GEOMETRY_LEFTRIGHTCIRCULARARROW: &'static str = "leftRightCircularArrow";
149    pub const GEOMETRY_LEFTRIGHTRIBBON: &'static str = "leftRightRibbon";
150    pub const GEOMETRY_LEFTRIGHTUPARROW: &'static str = "leftRightUpArrow";
151    pub const GEOMETRY_LEFTUPARROW: &'static str = "leftUpArrow";
152    pub const GEOMETRY_LIGHTNINGBOLT: &'static str = "lightningBolt";
153    pub const GEOMETRY_LINE: &'static str = "line";
154    pub const GEOMETRY_LINEINV: &'static str = "lineInv";
155    pub const GEOMETRY_MATHDIVIDE: &'static str = "mathDivide";
156    pub const GEOMETRY_MATHEQUAL: &'static str = "mathEqual";
157    pub const GEOMETRY_MATHMINUS: &'static str = "mathMinus";
158    pub const GEOMETRY_MATHMULTIPLY: &'static str = "mathMultiply";
159    pub const GEOMETRY_MATHNOTEQUAL: &'static str = "mathNotEqual";
160    pub const GEOMETRY_MATHPLUS: &'static str = "mathPlus";
161    pub const GEOMETRY_MOON: &'static str = "moon";
162    pub const GEOMETRY_NONISOSCELESTRAPEZOID: &'static str = "nonIsoscelesTrapezoid";
163    pub const GEOMETRY_NOSMOKING: &'static str = "noSmoking";
164    pub const GEOMETRY_NOTCHEDRIGHTARROW: &'static str = "notchedRightArrow";
165    pub const GEOMETRY_OCTAGON: &'static str = "octagon";
166    pub const GEOMETRY_PARALLELOGRAM: &'static str = "parallelogram";
167    pub const GEOMETRY_PENTAGON: &'static str = "pentagon";
168    pub const GEOMETRY_PIE: &'static str = "pie";
169    pub const GEOMETRY_PIEWEDGE: &'static str = "pieWedge";
170    pub const GEOMETRY_PLAQUE: &'static str = "plaque";
171    pub const GEOMETRY_PLAQUETABS: &'static str = "plaqueTabs";
172    pub const GEOMETRY_PLUS: &'static str = "plus";
173    pub const GEOMETRY_QUADARROW: &'static str = "quadArrow";
174    pub const GEOMETRY_QUADARROWCALLOUT: &'static str = "quadArrowCallout";
175    pub const GEOMETRY_RECT: &'static str = "rect";
176    pub const GEOMETRY_RIBBON: &'static str = "ribbon";
177    pub const GEOMETRY_RIBBON2: &'static str = "ribbon2";
178    pub const GEOMETRY_RIGHTARROW: &'static str = "rightArrow";
179    pub const GEOMETRY_RIGHTARROWCALLOUT: &'static str = "rightArrowCallout";
180    pub const GEOMETRY_RIGHTBRACE: &'static str = "rightBrace";
181    pub const GEOMETRY_RIGHTBRACKET: &'static str = "rightBracket";
182    pub const GEOMETRY_ROUND1RECT: &'static str = "round1Rect";
183    pub const GEOMETRY_ROUND2DIAGRECT: &'static str = "round2DiagRect";
184    pub const GEOMETRY_ROUND2SAMERECT: &'static str = "round2SameRect";
185    pub const GEOMETRY_ROUNDRECT: &'static str = "roundRect";
186    pub const GEOMETRY_RTTRIANGLE: &'static str = "rtTriangle";
187    pub const GEOMETRY_SMILEYFACE: &'static str = "smileyFace";
188    pub const GEOMETRY_SNIP1RECT: &'static str = "snip1Rect";
189    pub const GEOMETRY_SNIP2DIAGRECT: &'static str = "snip2DiagRect";
190    pub const GEOMETRY_SNIP2SAMERECT: &'static str = "snip2SameRect";
191    pub const GEOMETRY_SNIPROUNDRECT: &'static str = "snipRoundRect";
192    pub const GEOMETRY_SQUARETABS: &'static str = "squareTabs";
193    pub const GEOMETRY_STAR10: &'static str = "star10";
194    pub const GEOMETRY_STAR12: &'static str = "star12";
195    pub const GEOMETRY_STAR16: &'static str = "star16";
196    pub const GEOMETRY_STAR24: &'static str = "star24";
197    pub const GEOMETRY_STAR32: &'static str = "star32";
198    pub const GEOMETRY_STAR4: &'static str = "star4";
199    pub const GEOMETRY_STAR5: &'static str = "star5";
200    pub const GEOMETRY_STAR6: &'static str = "star6";
201    pub const GEOMETRY_STAR7: &'static str = "star7";
202    pub const GEOMETRY_STAR8: &'static str = "star8";
203    pub const GEOMETRY_STRAIGHTCONNECTOR1: &'static str = "straightConnector1";
204    pub const GEOMETRY_STRIPEDRIGHTARROW: &'static str = "stripedRightArrow";
205    pub const GEOMETRY_SUN: &'static str = "sun";
206    pub const GEOMETRY_SWOOSHARROW: &'static str = "swooshArrow";
207    pub const GEOMETRY_TEARDROP: &'static str = "teardrop";
208    pub const GEOMETRY_TRAPEZOID: &'static str = "trapezoid";
209    pub const GEOMETRY_TRIANGLE: &'static str = "triangle";
210    pub const GEOMETRY_UPARROW: &'static str = "upArrow";
211    pub const GEOMETRY_UPARROWCALLOUT: &'static str = "upArrowCallout";
212    pub const GEOMETRY_UPDOWNARROW: &'static str = "upDownArrow";
213    pub const GEOMETRY_UPDOWNARROWCALLOUT: &'static str = "upDownArrowCallout";
214    pub const GEOMETRY_UTURNARROW: &'static str = "uturnArrow";
215    pub const GEOMETRY_VERTICALSCROLL: &'static str = "verticalScroll";
216    pub const GEOMETRY_WAVE: &'static str = "wave";
217    pub const GEOMETRY_WEDGEELLIPSECALLOUT: &'static str = "wedgeEllipseCallout";
218    pub const GEOMETRY_WEDGERECTCALLOUT: &'static str = "wedgeRectCallout";
219    pub const GEOMETRY_WEDGEROUNDRECTCALLOUT: &'static str = "wedgeRoundRectCallout";
220
221    #[inline]
222    #[must_use]
223    pub fn geometry(&self) -> &str {
224        &self.geometry
225    }
226
227    #[inline]
228    #[must_use]
229    #[deprecated(since = "3.0.0", note = "Use geometry()")]
230    pub fn get_geometry(&self) -> &str {
231        self.geometry()
232    }
233
234    #[inline]
235    pub fn set_geometry<S: Into<String>>(&mut self, value: S) -> &mut Self {
236        self.geometry = value.into().into_boxed_str();
237        self
238    }
239
240    #[inline]
241    #[must_use]
242    pub fn adjust_value_list(&self) -> &AdjustValueList {
243        &self.adjust_value_list
244    }
245
246    #[inline]
247    #[must_use]
248    #[deprecated(since = "3.0.0", note = "Use adjust_value_list()")]
249    pub fn get_adjust_value_list(&self) -> &AdjustValueList {
250        self.adjust_value_list()
251    }
252
253    #[inline]
254    pub fn adjust_value_list_mut(&mut self) -> &mut AdjustValueList {
255        &mut self.adjust_value_list
256    }
257
258    #[inline]
259    #[deprecated(since = "3.0.0", note = "Use adjust_value_list_mut()")]
260    pub fn get_adjust_value_list_mut(&mut self) -> &mut AdjustValueList {
261        self.adjust_value_list_mut()
262    }
263
264    #[inline]
265    pub fn set_adjust_value_list(&mut self, value: AdjustValueList) -> &mut Self {
266        self.adjust_value_list = value;
267        self
268    }
269
270    pub(crate) fn set_attributes<R: std::io::BufRead>(
271        &mut self,
272        reader: &mut Reader<R>,
273        e: &BytesStart,
274    ) {
275        self.set_geometry(get_attribute(e, b"prst").unwrap());
276
277        xml_read_loop!(
278            reader,
279            Event::Start(ref e) => {
280                if e.name().into_inner() == b"a:avLst" {
281                    self.adjust_value_list_mut().set_attributes(reader, e);
282                }
283            },
284            Event::End(ref e) => {
285                if e.name().into_inner() == b"a:prstGeom" {
286                    return;
287                }
288            },
289            Event::Eof => panic!("Error: Could not find {} end element", "a:prstGeom")
290        );
291    }
292
293    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
294        // a:prstGeom
295        write_start_tag(
296            writer,
297            "a:prstGeom",
298            vec![("prst", &self.geometry).into()],
299            false,
300        );
301
302        // a:avLst
303        self.adjust_value_list.write_to(writer);
304
305        write_end_tag(writer, "a:prstGeom");
306    }
307}