1use std::str::FromStr;
17
18use crate::oxml::color::SchemeColor;
19use crate::oxml::sppr::Dash;
20
21#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
23pub enum Alignment {
24 #[default]
26 Left,
27 Center,
29 Right,
31 Justify,
33 Distribute,
35}
36
37impl Alignment {
38 pub fn as_str(self) -> &'static str {
40 match self {
41 Alignment::Left => "l",
42 Alignment::Center => "ctr",
43 Alignment::Right => "r",
44 Alignment::Justify => "just",
45 Alignment::Distribute => "dist",
46 }
47 }
48}
49
50impl FromStr for Alignment {
51 type Err = ();
52 fn from_str(s: &str) -> Result<Self, Self::Err> {
53 Ok(match s {
54 "l" => Alignment::Left,
55 "ctr" => Alignment::Center,
56 "r" => Alignment::Right,
57 "just" => Alignment::Justify,
58 "dist" => Alignment::Distribute,
59 _ => return Err(()),
60 })
61 }
62}
63
64#[derive(Copy, Clone, Debug, Eq, PartialEq)]
69pub enum PresetGeometry {
70 Rectangle,
72 RoundRectangle,
74 Ellipse,
76 Line,
78 RightTriangle,
80 Diamond,
82 Parallelogram,
84 Trapezoid,
86 Hexagon,
88 Octagon,
90 Star5,
92 Star6,
94 Star10,
96 Arrow,
98 RightArrow,
100 LeftArrow,
102 UpArrow,
104 DownArrow,
106 BentArrow,
108 CurvedRightArrow,
110 Callout1,
112 Callout2,
114 Cloud,
116 Heart,
118 LightningBolt,
120 Sun,
122 Moon,
124 SmileyFace,
126 Donut,
128 Cube,
130 Can,
132 Bevel,
134 NoSmoking,
136 BlockArc,
138 Plus,
140 Minus,
142 Plaque,
144 Wave,
146 Pie,
148 Bevel2,
150 FoldedCorner,
152 Pentagon,
154 Chevron,
156 RightBracket,
158 LeftBracket,
160 DoubleBracket,
162 StraightConnector1,
164 BentConnector2,
166 BentConnector3,
168 BentConnector4,
170 BentConnector5,
172 CurvedConnector2,
174 CurvedConnector3,
176 CurvedConnector4,
178 CurvedConnector5,
180 Other,
182}
183
184impl PresetGeometry {
185 pub fn as_str(self) -> &'static str {
187 use PresetGeometry::*;
188 match self {
189 Rectangle => "rect",
190 RoundRectangle => "roundRect",
191 Ellipse => "ellipse",
192 Line => "line",
193 RightTriangle => "rtTriangle",
194 Diamond => "diamond",
195 Parallelogram => "parallelogram",
196 Trapezoid => "trapezoid",
197 Hexagon => "hexagon",
198 Octagon => "octagon",
199 Star5 => "star5",
200 Star6 => "star6",
201 Star10 => "star10",
202 Arrow => "arrow",
203 RightArrow => "rightArrow",
204 LeftArrow => "leftArrow",
205 UpArrow => "upArrow",
206 DownArrow => "downArrow",
207 BentArrow => "bentArrow",
208 CurvedRightArrow => "curvedRightArrow",
209 Callout1 => "wedgeRectCallout",
210 Callout2 => "wedgeRoundRectCallout",
211 Cloud => "cloud",
212 Heart => "heart",
213 LightningBolt => "lightningBolt",
214 Sun => "sun",
215 Moon => "moon",
216 SmileyFace => "smileyFace",
217 Donut => "donut",
218 Cube => "cube",
219 Can => "can",
220 Bevel => "bevel",
221 NoSmoking => "noSmoking",
222 BlockArc => "blockArc",
223 Plus => "mathPlus",
224 Minus => "mathMinus",
225 Plaque => "plaque",
226 Wave => "wave",
227 Pie => "pie",
228 Bevel2 => "bevel2",
229 FoldedCorner => "foldedCorner",
230 Pentagon => "homePlate",
231 Chevron => "chevron",
232 RightBracket => "rightBracket",
233 LeftBracket => "leftBracket",
234 DoubleBracket => "doubleBracket",
235 StraightConnector1 => "straightConnector1",
236 BentConnector2 => "bentConnector2",
237 BentConnector3 => "bentConnector3",
238 BentConnector4 => "bentConnector4",
239 BentConnector5 => "bentConnector5",
240 CurvedConnector2 => "curvedConnector2",
241 CurvedConnector3 => "curvedConnector3",
242 CurvedConnector4 => "curvedConnector4",
243 CurvedConnector5 => "curvedConnector5",
244 Other => "rect",
245 }
246 }
247}
248
249impl FromStr for PresetGeometry {
250 type Err = ();
251 fn from_str(s: &str) -> Result<Self, Self::Err> {
252 use PresetGeometry::*;
253 Ok(match s {
254 "rect" => Rectangle,
255 "roundRect" => RoundRectangle,
256 "ellipse" => Ellipse,
257 "line" => Line,
258 "rtTriangle" => RightTriangle,
259 "diamond" => Diamond,
260 "parallelogram" => Parallelogram,
261 "trapezoid" => Trapezoid,
262 "hexagon" => Hexagon,
263 "octagon" => Octagon,
264 "star5" => Star5,
265 "star6" => Star6,
266 "star10" => Star10,
267 "arrow" => Arrow,
268 "rightArrow" => RightArrow,
269 "leftArrow" => LeftArrow,
270 "upArrow" => UpArrow,
271 "downArrow" => DownArrow,
272 "bentArrow" => BentArrow,
273 "curvedRightArrow" => CurvedRightArrow,
274 "wedgeRectCallout" => Callout1,
275 "wedgeRoundRectCallout" => Callout2,
276 "cloud" => Cloud,
277 "heart" => Heart,
278 "lightningBolt" => LightningBolt,
279 "sun" => Sun,
280 "moon" => Moon,
281 "smileyFace" => SmileyFace,
282 "donut" => Donut,
283 "cube" => Cube,
284 "can" => Can,
285 "bevel" => Bevel,
286 "noSmoking" => NoSmoking,
287 "blockArc" => BlockArc,
288 "mathPlus" => Plus,
289 "mathMinus" => Minus,
290 "plaque" => Plaque,
291 "wave" => Wave,
292 "pie" => Pie,
293 "bevel2" => Bevel2,
294 "foldedCorner" => FoldedCorner,
295 "homePlate" => Pentagon,
296 "chevron" => Chevron,
297 "rightBracket" => RightBracket,
298 "leftBracket" => LeftBracket,
299 "doubleBracket" => DoubleBracket,
300 "straightConnector1" => StraightConnector1,
301 "bentConnector2" => BentConnector2,
302 "bentConnector3" => BentConnector3,
303 "bentConnector4" => BentConnector4,
304 "bentConnector5" => BentConnector5,
305 "curvedConnector2" => CurvedConnector2,
306 "curvedConnector3" => CurvedConnector3,
307 "curvedConnector4" => CurvedConnector4,
308 "curvedConnector5" => CurvedConnector5,
309 _ => Other,
310 })
311 }
312}
313
314#[derive(Copy, Clone, Debug, Eq, PartialEq)]
316pub enum Underline {
317 None,
319 Single,
321 Double,
323 Heavy,
325 Dotted,
327 Dashed,
329 Wavy,
331}
332
333impl Underline {
334 pub fn as_str(self) -> &'static str {
336 match self {
337 Underline::None => "none",
338 Underline::Single => "sng",
339 Underline::Double => "dbl",
340 Underline::Heavy => "heavy",
341 Underline::Dotted => "dotted",
342 Underline::Dashed => "dash",
343 Underline::Wavy => "wavy",
344 }
345 }
346}
347
348impl FromStr for Underline {
349 type Err = ();
350 fn from_str(s: &str) -> Result<Self, Self::Err> {
351 Ok(match s {
352 "none" => Underline::None,
353 "sng" => Underline::Single,
354 "dbl" => Underline::Double,
355 "heavy" => Underline::Heavy,
356 "dotted" => Underline::Dotted,
357 "dash" => Underline::Dashed,
358 "wavy" => Underline::Wavy,
359 _ => return Err(()),
360 })
361 }
362}
363
364#[derive(Copy, Clone, Debug, Eq, PartialEq)]
366pub enum Cap {
367 Flat,
369 Small,
371 All,
373}
374
375impl Cap {
376 pub fn as_str(self) -> &'static str {
378 match self {
379 Cap::Flat => "flat",
380 Cap::Small => "small",
381 Cap::All => "all",
382 }
383 }
384}
385
386#[derive(Copy, Clone, Debug, Eq, PartialEq)]
388pub enum TextDirection {
389 Horizontal,
391 Vertical,
393 VerticalEastAsia,
395}
396
397impl TextDirection {
398 pub fn as_str(self) -> &'static str {
400 match self {
401 TextDirection::Horizontal => "horz",
402 TextDirection::Vertical => "vert",
403 TextDirection::VerticalEastAsia => "vert270",
404 }
405 }
406}
407
408#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
413pub enum MsoAutoSize {
414 #[default]
416 None,
417 ShapeToFitText,
419 TextToFitShape,
421}
422
423impl MsoAutoSize {
424 pub fn tag_name(self) -> Option<&'static str> {
430 match self {
431 MsoAutoSize::None => None,
432 MsoAutoSize::ShapeToFitText => Some("a:spAutoFit"),
433 MsoAutoSize::TextToFitShape => Some("a:normAutofit"),
434 }
435 }
436}
437
438#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
443pub enum MsoAnchor {
444 #[default]
446 Top,
447 Middle,
449 Bottom,
451}
452
453impl MsoAnchor {
454 pub fn as_str(self) -> &'static str {
456 match self {
457 MsoAnchor::Top => "t",
458 MsoAnchor::Middle => "ctr",
459 MsoAnchor::Bottom => "b",
460 }
461 }
462}
463
464impl FromStr for MsoAnchor {
465 type Err = ();
466 fn from_str(s: &str) -> Result<Self, Self::Err> {
467 Ok(match s {
468 "t" => MsoAnchor::Top,
469 "ctr" => MsoAnchor::Middle,
470 "b" => MsoAnchor::Bottom,
471 _ => return Err(()),
472 })
473 }
474}
475
476#[derive(Copy, Clone, Debug, Eq, PartialEq)]
481pub enum MsoConnectorType {
482 Straight,
484 Elbow,
486 Curve,
488 BentConnector3,
490 BentConnector4,
492 BentConnector5,
494 CurvedConnector3,
496 CurvedConnector4,
498 CurvedConnector5,
500}
501
502impl MsoConnectorType {
503 pub fn as_str(self) -> &'static str {
505 match self {
506 MsoConnectorType::Straight => "straightConnector1",
507 MsoConnectorType::Elbow => "bentConnector2",
508 MsoConnectorType::Curve => "curvedConnector2",
509 MsoConnectorType::BentConnector3 => "bentConnector3",
510 MsoConnectorType::BentConnector4 => "bentConnector4",
511 MsoConnectorType::BentConnector5 => "bentConnector5",
512 MsoConnectorType::CurvedConnector3 => "curvedConnector3",
513 MsoConnectorType::CurvedConnector4 => "curvedConnector4",
514 MsoConnectorType::CurvedConnector5 => "curvedConnector5",
515 }
516 }
517}
518
519impl FromStr for MsoConnectorType {
520 type Err = ();
521 fn from_str(s: &str) -> Result<Self, Self::Err> {
522 Ok(match s {
523 "straightConnector1" => MsoConnectorType::Straight,
524 "bentConnector2" => MsoConnectorType::Elbow,
525 "curvedConnector2" => MsoConnectorType::Curve,
526 "bentConnector3" => MsoConnectorType::BentConnector3,
527 "bentConnector4" => MsoConnectorType::BentConnector4,
528 "bentConnector5" => MsoConnectorType::BentConnector5,
529 "curvedConnector3" => MsoConnectorType::CurvedConnector3,
530 "curvedConnector4" => MsoConnectorType::CurvedConnector4,
531 "curvedConnector5" => MsoConnectorType::CurvedConnector5,
532 _ => return Err(()),
533 })
534 }
535}
536
537#[derive(Copy, Clone, Debug, Eq, PartialEq)]
542pub enum MsoShapeType {
543 AutoShape,
545 TextBox,
547 Placeholder,
549 Picture,
551 Group,
553 Connector,
555 GraphicFrame,
557}
558
559impl MsoShapeType {
560 pub fn as_str(self) -> &'static str {
562 match self {
563 MsoShapeType::AutoShape => "auto_shape",
564 MsoShapeType::TextBox => "text_box",
565 MsoShapeType::Placeholder => "placeholder",
566 MsoShapeType::Picture => "picture",
567 MsoShapeType::Group => "group",
568 MsoShapeType::Connector => "connector",
569 MsoShapeType::GraphicFrame => "table",
570 }
571 }
572}
573
574#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
576pub enum TextWrapping {
577 None,
579 #[default]
581 Square,
582}
583
584impl TextWrapping {
585 pub fn as_str(self) -> &'static str {
587 match self {
588 TextWrapping::None => "none",
589 TextWrapping::Square => "square",
590 }
591 }
592}
593
594#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
599pub enum TabAlignment {
600 #[default]
602 Left,
603 Center,
605 Right,
607 Decimal,
609}
610
611impl TabAlignment {
612 pub fn as_str(self) -> &'static str {
614 match self {
615 TabAlignment::Left => "l",
616 TabAlignment::Center => "ctr",
617 TabAlignment::Right => "r",
618 TabAlignment::Decimal => "dec",
619 }
620 }
621}
622
623impl FromStr for TabAlignment {
624 type Err = ();
625 fn from_str(s: &str) -> Result<Self, Self::Err> {
626 Ok(match s {
627 "l" => TabAlignment::Left,
628 "ctr" => TabAlignment::Center,
629 "r" => TabAlignment::Right,
630 "dec" => TabAlignment::Decimal,
631 _ => return Err(()),
632 })
633 }
634}
635
636#[derive(Copy, Clone, Debug, Eq, PartialEq)]
649pub enum MsoFillType {
650 Background,
652 Gradient,
654 Pattern,
656 Picture,
658 Solid,
660 Inherit,
662 Mixed,
664}
665
666impl MsoFillType {
667 pub fn as_str(self) -> &'static str {
669 match self {
670 MsoFillType::Background => "background",
671 MsoFillType::Gradient => "gradient",
672 MsoFillType::Pattern => "pattern",
673 MsoFillType::Picture => "picture",
674 MsoFillType::Solid => "solid",
675 MsoFillType::Inherit => "inherit",
676 MsoFillType::Mixed => "mixed",
677 }
678 }
679}
680
681#[derive(Copy, Clone, Debug, Eq, PartialEq)]
687pub enum MsoThemeColorIndex {
688 NotThemeColor,
690 Background1,
692 Background2,
694 Text1,
696 Text2,
698 Accent1,
700 Accent2,
702 Accent3,
704 Accent4,
706 Accent5,
708 Accent6,
710 Hyperlink,
712 FollowedHyperlink,
714 Light1,
716 Light2,
718 Dark1,
720 Dark2,
722 Mixed,
724}
725
726impl MsoThemeColorIndex {
727 pub fn as_str(self) -> Option<&'static str> {
729 match self {
730 MsoThemeColorIndex::NotThemeColor => None,
731 MsoThemeColorIndex::Background1 => Some("bg1"),
732 MsoThemeColorIndex::Background2 => Some("bg2"),
733 MsoThemeColorIndex::Text1 => Some("tx1"),
734 MsoThemeColorIndex::Text2 => Some("tx2"),
735 MsoThemeColorIndex::Accent1 => Some("accent1"),
736 MsoThemeColorIndex::Accent2 => Some("accent2"),
737 MsoThemeColorIndex::Accent3 => Some("accent3"),
738 MsoThemeColorIndex::Accent4 => Some("accent4"),
739 MsoThemeColorIndex::Accent5 => Some("accent5"),
740 MsoThemeColorIndex::Accent6 => Some("accent6"),
741 MsoThemeColorIndex::Hyperlink => Some("hlink"),
742 MsoThemeColorIndex::FollowedHyperlink => Some("folHlink"),
743 MsoThemeColorIndex::Light1 => Some("lt1"),
744 MsoThemeColorIndex::Light2 => Some("lt2"),
745 MsoThemeColorIndex::Dark1 => Some("dk1"),
746 MsoThemeColorIndex::Dark2 => Some("dk2"),
747 MsoThemeColorIndex::Mixed => None,
748 }
749 }
750
751 pub fn from_scheme(c: SchemeColor) -> Self {
753 match c {
754 SchemeColor::Background1 => MsoThemeColorIndex::Background1,
755 SchemeColor::Background2 => MsoThemeColorIndex::Background2,
756 SchemeColor::Text1 => MsoThemeColorIndex::Text1,
757 SchemeColor::Text2 => MsoThemeColorIndex::Text2,
758 SchemeColor::Accent1 => MsoThemeColorIndex::Accent1,
759 SchemeColor::Accent2 => MsoThemeColorIndex::Accent2,
760 SchemeColor::Accent3 => MsoThemeColorIndex::Accent3,
761 SchemeColor::Accent4 => MsoThemeColorIndex::Accent4,
762 SchemeColor::Accent5 => MsoThemeColorIndex::Accent5,
763 SchemeColor::Accent6 => MsoThemeColorIndex::Accent6,
764 SchemeColor::Hlink => MsoThemeColorIndex::Hyperlink,
765 SchemeColor::FolHlink => MsoThemeColorIndex::FollowedHyperlink,
766 SchemeColor::Lt1 => MsoThemeColorIndex::Light1,
767 SchemeColor::Lt2 => MsoThemeColorIndex::Light2,
768 SchemeColor::Dk1 => MsoThemeColorIndex::Dark1,
769 SchemeColor::Dk2 => MsoThemeColorIndex::Dark2,
770 }
771 }
772}
773
774#[derive(Copy, Clone, Debug, Eq, PartialEq)]
778pub enum MsoColorType {
779 SystemColor,
781 Rgb,
783 PresetColor,
785 SchemeColor,
787 Mixed,
789}
790
791impl MsoColorType {
792 pub fn as_str(self) -> &'static str {
794 match self {
795 MsoColorType::SystemColor => "system",
796 MsoColorType::Rgb => "rgb",
797 MsoColorType::PresetColor => "preset",
798 MsoColorType::SchemeColor => "scheme",
799 MsoColorType::Mixed => "mixed",
800 }
801 }
802}
803
804pub type PpAlign = Alignment;
809
810#[derive(Copy, Clone, Debug, Eq, PartialEq)]
815pub enum PpPlaceholderType {
816 Title,
818 Body,
820 CenterTitle,
822 Subtitle,
824 Date,
826 SlideNumber,
828 Footer,
830 Header,
832 Object,
834 Chart,
836 Table,
838 ClipArt,
840 OrgChart,
842 MediaClip,
844 Picture,
849 Other,
851}
852
853impl PpPlaceholderType {
854 pub fn as_str(self) -> &'static str {
856 match self {
857 PpPlaceholderType::Title => "title",
858 PpPlaceholderType::Body => "body",
859 PpPlaceholderType::CenterTitle => "ctrTitle",
860 PpPlaceholderType::Subtitle => "subTitle",
861 PpPlaceholderType::Date => "dt",
862 PpPlaceholderType::SlideNumber => "sldNum",
863 PpPlaceholderType::Footer => "ftr",
864 PpPlaceholderType::Header => "hdr",
865 PpPlaceholderType::Object => "obj",
866 PpPlaceholderType::Chart => "chart",
867 PpPlaceholderType::Table => "tbl",
868 PpPlaceholderType::ClipArt => "clipArt",
869 PpPlaceholderType::OrgChart => "orgChart",
870 PpPlaceholderType::MediaClip => "media",
871 PpPlaceholderType::Picture => "pic",
872 PpPlaceholderType::Other => "body",
875 }
876 }
877
878 pub fn parse(s: &str) -> Self {
884 match s {
885 "title" => PpPlaceholderType::Title,
886 "body" => PpPlaceholderType::Body,
887 "ctrTitle" => PpPlaceholderType::CenterTitle,
888 "subTitle" => PpPlaceholderType::Subtitle,
889 "dt" => PpPlaceholderType::Date,
890 "sldNum" => PpPlaceholderType::SlideNumber,
891 "ftr" => PpPlaceholderType::Footer,
892 "hdr" => PpPlaceholderType::Header,
893 "obj" => PpPlaceholderType::Object,
894 "chart" => PpPlaceholderType::Chart,
895 "tbl" => PpPlaceholderType::Table,
896 "clipArt" => PpPlaceholderType::ClipArt,
897 "orgChart" => PpPlaceholderType::OrgChart,
898 "media" => PpPlaceholderType::MediaClip,
899 "pic" => PpPlaceholderType::Picture,
900 _ => PpPlaceholderType::Other,
901 }
902 }
903}
904
905#[derive(Copy, Clone, Debug, Eq, PartialEq)]
911pub enum MsoLineDashStyle {
912 Solid,
913 Dash,
914 DashDot,
915 DashDotDot,
916 Dot,
917 LongDash,
918 LongDashDot,
919 LongDashDotDot,
920 RoundDot,
921 SysDash,
922 SysDashDot,
923 SysDashDotDot,
924 SysDot,
925 Mixed,
926}
927
928impl MsoLineDashStyle {
929 pub fn as_str(self) -> &'static str {
931 match self {
932 MsoLineDashStyle::Solid => "solid",
933 MsoLineDashStyle::Dash => "dash",
934 MsoLineDashStyle::DashDot => "dashDot",
935 MsoLineDashStyle::DashDotDot => "dashDotDot",
936 MsoLineDashStyle::Dot => "dot",
937 MsoLineDashStyle::LongDash => "lgDash",
938 MsoLineDashStyle::LongDashDot => "lgDashDot",
939 MsoLineDashStyle::LongDashDotDot => "lgDashDotDot",
940 MsoLineDashStyle::RoundDot => "sysDot",
941 MsoLineDashStyle::SysDash => "sysDash",
942 MsoLineDashStyle::SysDashDot => "sysDashDot",
943 MsoLineDashStyle::SysDashDotDot => "sysDashDotDot",
944 MsoLineDashStyle::SysDot => "sysDot",
945 MsoLineDashStyle::Mixed => "solid",
946 }
947 }
948}
949
950impl From<MsoLineDashStyle> for Dash {
951 fn from(s: MsoLineDashStyle) -> Self {
952 match s {
953 MsoLineDashStyle::Solid => Dash::Solid,
954 MsoLineDashStyle::Dash => Dash::Dash,
955 MsoLineDashStyle::DashDot => Dash::DashDot,
956 MsoLineDashStyle::DashDotDot => Dash::LgDashDotDot,
957 MsoLineDashStyle::Dot => Dash::Dot,
958 MsoLineDashStyle::LongDash => Dash::LgDash,
959 MsoLineDashStyle::LongDashDot => Dash::LgDashDot,
960 MsoLineDashStyle::LongDashDotDot => Dash::LgDashDotDot,
961 MsoLineDashStyle::RoundDot => Dash::SysDot,
962 MsoLineDashStyle::SysDash => Dash::SysDash,
963 MsoLineDashStyle::SysDashDot => Dash::SysDashDot,
964 MsoLineDashStyle::SysDashDotDot => Dash::SysDashDotDot,
965 MsoLineDashStyle::SysDot => Dash::SysDot,
966 MsoLineDashStyle::Mixed => Dash::Solid,
967 }
968 }
969}