use std::str::FromStr;
use crate::oxml::color::SchemeColor;
use crate::oxml::sppr::Dash;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
pub enum Alignment {
#[default]
Left,
Center,
Right,
Justify,
Distribute,
}
impl Alignment {
pub fn as_str(self) -> &'static str {
match self {
Alignment::Left => "l",
Alignment::Center => "ctr",
Alignment::Right => "r",
Alignment::Justify => "just",
Alignment::Distribute => "dist",
}
}
}
impl FromStr for Alignment {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"l" => Alignment::Left,
"ctr" => Alignment::Center,
"r" => Alignment::Right,
"just" => Alignment::Justify,
"dist" => Alignment::Distribute,
_ => return Err(()),
})
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum PresetGeometry {
Rectangle,
RoundRectangle,
Ellipse,
Line,
RightTriangle,
Diamond,
Parallelogram,
Trapezoid,
Hexagon,
Octagon,
Star5,
Star6,
Star10,
Arrow,
RightArrow,
LeftArrow,
UpArrow,
DownArrow,
BentArrow,
CurvedRightArrow,
Callout1,
Callout2,
Cloud,
Heart,
LightningBolt,
Sun,
Moon,
SmileyFace,
Donut,
Cube,
Can,
Bevel,
NoSmoking,
BlockArc,
Plus,
Minus,
Plaque,
Wave,
Pie,
Bevel2,
FoldedCorner,
Pentagon,
Chevron,
RightBracket,
LeftBracket,
DoubleBracket,
StraightConnector1,
BentConnector2,
BentConnector3,
BentConnector4,
BentConnector5,
CurvedConnector2,
CurvedConnector3,
CurvedConnector4,
CurvedConnector5,
Other,
}
impl PresetGeometry {
pub fn as_str(self) -> &'static str {
use PresetGeometry::*;
match self {
Rectangle => "rect",
RoundRectangle => "roundRect",
Ellipse => "ellipse",
Line => "line",
RightTriangle => "rtTriangle",
Diamond => "diamond",
Parallelogram => "parallelogram",
Trapezoid => "trapezoid",
Hexagon => "hexagon",
Octagon => "octagon",
Star5 => "star5",
Star6 => "star6",
Star10 => "star10",
Arrow => "arrow",
RightArrow => "rightArrow",
LeftArrow => "leftArrow",
UpArrow => "upArrow",
DownArrow => "downArrow",
BentArrow => "bentArrow",
CurvedRightArrow => "curvedRightArrow",
Callout1 => "wedgeRectCallout",
Callout2 => "wedgeRoundRectCallout",
Cloud => "cloud",
Heart => "heart",
LightningBolt => "lightningBolt",
Sun => "sun",
Moon => "moon",
SmileyFace => "smileyFace",
Donut => "donut",
Cube => "cube",
Can => "can",
Bevel => "bevel",
NoSmoking => "noSmoking",
BlockArc => "blockArc",
Plus => "mathPlus",
Minus => "mathMinus",
Plaque => "plaque",
Wave => "wave",
Pie => "pie",
Bevel2 => "bevel2",
FoldedCorner => "foldedCorner",
Pentagon => "homePlate",
Chevron => "chevron",
RightBracket => "rightBracket",
LeftBracket => "leftBracket",
DoubleBracket => "doubleBracket",
StraightConnector1 => "straightConnector1",
BentConnector2 => "bentConnector2",
BentConnector3 => "bentConnector3",
BentConnector4 => "bentConnector4",
BentConnector5 => "bentConnector5",
CurvedConnector2 => "curvedConnector2",
CurvedConnector3 => "curvedConnector3",
CurvedConnector4 => "curvedConnector4",
CurvedConnector5 => "curvedConnector5",
Other => "rect",
}
}
}
impl FromStr for PresetGeometry {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PresetGeometry::*;
Ok(match s {
"rect" => Rectangle,
"roundRect" => RoundRectangle,
"ellipse" => Ellipse,
"line" => Line,
"rtTriangle" => RightTriangle,
"diamond" => Diamond,
"parallelogram" => Parallelogram,
"trapezoid" => Trapezoid,
"hexagon" => Hexagon,
"octagon" => Octagon,
"star5" => Star5,
"star6" => Star6,
"star10" => Star10,
"arrow" => Arrow,
"rightArrow" => RightArrow,
"leftArrow" => LeftArrow,
"upArrow" => UpArrow,
"downArrow" => DownArrow,
"bentArrow" => BentArrow,
"curvedRightArrow" => CurvedRightArrow,
"wedgeRectCallout" => Callout1,
"wedgeRoundRectCallout" => Callout2,
"cloud" => Cloud,
"heart" => Heart,
"lightningBolt" => LightningBolt,
"sun" => Sun,
"moon" => Moon,
"smileyFace" => SmileyFace,
"donut" => Donut,
"cube" => Cube,
"can" => Can,
"bevel" => Bevel,
"noSmoking" => NoSmoking,
"blockArc" => BlockArc,
"mathPlus" => Plus,
"mathMinus" => Minus,
"plaque" => Plaque,
"wave" => Wave,
"pie" => Pie,
"bevel2" => Bevel2,
"foldedCorner" => FoldedCorner,
"homePlate" => Pentagon,
"chevron" => Chevron,
"rightBracket" => RightBracket,
"leftBracket" => LeftBracket,
"doubleBracket" => DoubleBracket,
"straightConnector1" => StraightConnector1,
"bentConnector2" => BentConnector2,
"bentConnector3" => BentConnector3,
"bentConnector4" => BentConnector4,
"bentConnector5" => BentConnector5,
"curvedConnector2" => CurvedConnector2,
"curvedConnector3" => CurvedConnector3,
"curvedConnector4" => CurvedConnector4,
"curvedConnector5" => CurvedConnector5,
_ => Other,
})
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Underline {
None,
Single,
Double,
Heavy,
Dotted,
Dashed,
Wavy,
}
impl Underline {
pub fn as_str(self) -> &'static str {
match self {
Underline::None => "none",
Underline::Single => "sng",
Underline::Double => "dbl",
Underline::Heavy => "heavy",
Underline::Dotted => "dotted",
Underline::Dashed => "dash",
Underline::Wavy => "wavy",
}
}
}
impl FromStr for Underline {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"none" => Underline::None,
"sng" => Underline::Single,
"dbl" => Underline::Double,
"heavy" => Underline::Heavy,
"dotted" => Underline::Dotted,
"dash" => Underline::Dashed,
"wavy" => Underline::Wavy,
_ => return Err(()),
})
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Cap {
Flat,
Small,
All,
}
impl Cap {
pub fn as_str(self) -> &'static str {
match self {
Cap::Flat => "flat",
Cap::Small => "small",
Cap::All => "all",
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum TextDirection {
Horizontal,
Vertical,
VerticalEastAsia,
}
impl TextDirection {
pub fn as_str(self) -> &'static str {
match self {
TextDirection::Horizontal => "horz",
TextDirection::Vertical => "vert",
TextDirection::VerticalEastAsia => "vert270",
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
pub enum MsoAutoSize {
#[default]
None,
ShapeToFitText,
TextToFitShape,
}
impl MsoAutoSize {
pub fn tag_name(self) -> Option<&'static str> {
match self {
MsoAutoSize::None => None,
MsoAutoSize::ShapeToFitText => Some("a:spAutoFit"),
MsoAutoSize::TextToFitShape => Some("a:normAutofit"),
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
pub enum MsoAnchor {
#[default]
Top,
Middle,
Bottom,
}
impl MsoAnchor {
pub fn as_str(self) -> &'static str {
match self {
MsoAnchor::Top => "t",
MsoAnchor::Middle => "ctr",
MsoAnchor::Bottom => "b",
}
}
}
impl FromStr for MsoAnchor {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"t" => MsoAnchor::Top,
"ctr" => MsoAnchor::Middle,
"b" => MsoAnchor::Bottom,
_ => return Err(()),
})
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum MsoConnectorType {
Straight,
Elbow,
Curve,
BentConnector3,
BentConnector4,
BentConnector5,
CurvedConnector3,
CurvedConnector4,
CurvedConnector5,
}
impl MsoConnectorType {
pub fn as_str(self) -> &'static str {
match self {
MsoConnectorType::Straight => "straightConnector1",
MsoConnectorType::Elbow => "bentConnector2",
MsoConnectorType::Curve => "curvedConnector2",
MsoConnectorType::BentConnector3 => "bentConnector3",
MsoConnectorType::BentConnector4 => "bentConnector4",
MsoConnectorType::BentConnector5 => "bentConnector5",
MsoConnectorType::CurvedConnector3 => "curvedConnector3",
MsoConnectorType::CurvedConnector4 => "curvedConnector4",
MsoConnectorType::CurvedConnector5 => "curvedConnector5",
}
}
}
impl FromStr for MsoConnectorType {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"straightConnector1" => MsoConnectorType::Straight,
"bentConnector2" => MsoConnectorType::Elbow,
"curvedConnector2" => MsoConnectorType::Curve,
"bentConnector3" => MsoConnectorType::BentConnector3,
"bentConnector4" => MsoConnectorType::BentConnector4,
"bentConnector5" => MsoConnectorType::BentConnector5,
"curvedConnector3" => MsoConnectorType::CurvedConnector3,
"curvedConnector4" => MsoConnectorType::CurvedConnector4,
"curvedConnector5" => MsoConnectorType::CurvedConnector5,
_ => return Err(()),
})
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum MsoShapeType {
AutoShape,
TextBox,
Placeholder,
Picture,
Group,
Connector,
GraphicFrame,
}
impl MsoShapeType {
pub fn as_str(self) -> &'static str {
match self {
MsoShapeType::AutoShape => "auto_shape",
MsoShapeType::TextBox => "text_box",
MsoShapeType::Placeholder => "placeholder",
MsoShapeType::Picture => "picture",
MsoShapeType::Group => "group",
MsoShapeType::Connector => "connector",
MsoShapeType::GraphicFrame => "table",
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
pub enum TextWrapping {
None,
#[default]
Square,
}
impl TextWrapping {
pub fn as_str(self) -> &'static str {
match self {
TextWrapping::None => "none",
TextWrapping::Square => "square",
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
pub enum TabAlignment {
#[default]
Left,
Center,
Right,
Decimal,
}
impl TabAlignment {
pub fn as_str(self) -> &'static str {
match self {
TabAlignment::Left => "l",
TabAlignment::Center => "ctr",
TabAlignment::Right => "r",
TabAlignment::Decimal => "dec",
}
}
}
impl FromStr for TabAlignment {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"l" => TabAlignment::Left,
"ctr" => TabAlignment::Center,
"r" => TabAlignment::Right,
"dec" => TabAlignment::Decimal,
_ => return Err(()),
})
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum MsoFillType {
Background,
Gradient,
Pattern,
Picture,
Solid,
Inherit,
Mixed,
}
impl MsoFillType {
pub fn as_str(self) -> &'static str {
match self {
MsoFillType::Background => "background",
MsoFillType::Gradient => "gradient",
MsoFillType::Pattern => "pattern",
MsoFillType::Picture => "picture",
MsoFillType::Solid => "solid",
MsoFillType::Inherit => "inherit",
MsoFillType::Mixed => "mixed",
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum MsoThemeColorIndex {
NotThemeColor,
Background1,
Background2,
Text1,
Text2,
Accent1,
Accent2,
Accent3,
Accent4,
Accent5,
Accent6,
Hyperlink,
FollowedHyperlink,
Light1,
Light2,
Dark1,
Dark2,
Mixed,
}
impl MsoThemeColorIndex {
pub fn as_str(self) -> Option<&'static str> {
match self {
MsoThemeColorIndex::NotThemeColor => None,
MsoThemeColorIndex::Background1 => Some("bg1"),
MsoThemeColorIndex::Background2 => Some("bg2"),
MsoThemeColorIndex::Text1 => Some("tx1"),
MsoThemeColorIndex::Text2 => Some("tx2"),
MsoThemeColorIndex::Accent1 => Some("accent1"),
MsoThemeColorIndex::Accent2 => Some("accent2"),
MsoThemeColorIndex::Accent3 => Some("accent3"),
MsoThemeColorIndex::Accent4 => Some("accent4"),
MsoThemeColorIndex::Accent5 => Some("accent5"),
MsoThemeColorIndex::Accent6 => Some("accent6"),
MsoThemeColorIndex::Hyperlink => Some("hlink"),
MsoThemeColorIndex::FollowedHyperlink => Some("folHlink"),
MsoThemeColorIndex::Light1 => Some("lt1"),
MsoThemeColorIndex::Light2 => Some("lt2"),
MsoThemeColorIndex::Dark1 => Some("dk1"),
MsoThemeColorIndex::Dark2 => Some("dk2"),
MsoThemeColorIndex::Mixed => None,
}
}
pub fn from_scheme(c: SchemeColor) -> Self {
match c {
SchemeColor::Background1 => MsoThemeColorIndex::Background1,
SchemeColor::Background2 => MsoThemeColorIndex::Background2,
SchemeColor::Text1 => MsoThemeColorIndex::Text1,
SchemeColor::Text2 => MsoThemeColorIndex::Text2,
SchemeColor::Accent1 => MsoThemeColorIndex::Accent1,
SchemeColor::Accent2 => MsoThemeColorIndex::Accent2,
SchemeColor::Accent3 => MsoThemeColorIndex::Accent3,
SchemeColor::Accent4 => MsoThemeColorIndex::Accent4,
SchemeColor::Accent5 => MsoThemeColorIndex::Accent5,
SchemeColor::Accent6 => MsoThemeColorIndex::Accent6,
SchemeColor::Hlink => MsoThemeColorIndex::Hyperlink,
SchemeColor::FolHlink => MsoThemeColorIndex::FollowedHyperlink,
SchemeColor::Lt1 => MsoThemeColorIndex::Light1,
SchemeColor::Lt2 => MsoThemeColorIndex::Light2,
SchemeColor::Dk1 => MsoThemeColorIndex::Dark1,
SchemeColor::Dk2 => MsoThemeColorIndex::Dark2,
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum MsoColorType {
SystemColor,
Rgb,
PresetColor,
SchemeColor,
Mixed,
}
impl MsoColorType {
pub fn as_str(self) -> &'static str {
match self {
MsoColorType::SystemColor => "system",
MsoColorType::Rgb => "rgb",
MsoColorType::PresetColor => "preset",
MsoColorType::SchemeColor => "scheme",
MsoColorType::Mixed => "mixed",
}
}
}
pub type PpAlign = Alignment;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum PpPlaceholderType {
Title,
Body,
CenterTitle,
Subtitle,
Date,
SlideNumber,
Footer,
Header,
Object,
Chart,
Table,
ClipArt,
OrgChart,
MediaClip,
Picture,
Other,
}
impl PpPlaceholderType {
pub fn as_str(self) -> &'static str {
match self {
PpPlaceholderType::Title => "title",
PpPlaceholderType::Body => "body",
PpPlaceholderType::CenterTitle => "ctrTitle",
PpPlaceholderType::Subtitle => "subTitle",
PpPlaceholderType::Date => "dt",
PpPlaceholderType::SlideNumber => "sldNum",
PpPlaceholderType::Footer => "ftr",
PpPlaceholderType::Header => "hdr",
PpPlaceholderType::Object => "obj",
PpPlaceholderType::Chart => "chart",
PpPlaceholderType::Table => "tbl",
PpPlaceholderType::ClipArt => "clipArt",
PpPlaceholderType::OrgChart => "orgChart",
PpPlaceholderType::MediaClip => "media",
PpPlaceholderType::Picture => "pic",
PpPlaceholderType::Other => "body",
}
}
pub fn parse(s: &str) -> Self {
match s {
"title" => PpPlaceholderType::Title,
"body" => PpPlaceholderType::Body,
"ctrTitle" => PpPlaceholderType::CenterTitle,
"subTitle" => PpPlaceholderType::Subtitle,
"dt" => PpPlaceholderType::Date,
"sldNum" => PpPlaceholderType::SlideNumber,
"ftr" => PpPlaceholderType::Footer,
"hdr" => PpPlaceholderType::Header,
"obj" => PpPlaceholderType::Object,
"chart" => PpPlaceholderType::Chart,
"tbl" => PpPlaceholderType::Table,
"clipArt" => PpPlaceholderType::ClipArt,
"orgChart" => PpPlaceholderType::OrgChart,
"media" => PpPlaceholderType::MediaClip,
"pic" => PpPlaceholderType::Picture,
_ => PpPlaceholderType::Other,
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum MsoLineDashStyle {
Solid,
Dash,
DashDot,
DashDotDot,
Dot,
LongDash,
LongDashDot,
LongDashDotDot,
RoundDot,
SysDash,
SysDashDot,
SysDashDotDot,
SysDot,
Mixed,
}
impl MsoLineDashStyle {
pub fn as_str(self) -> &'static str {
match self {
MsoLineDashStyle::Solid => "solid",
MsoLineDashStyle::Dash => "dash",
MsoLineDashStyle::DashDot => "dashDot",
MsoLineDashStyle::DashDotDot => "dashDotDot",
MsoLineDashStyle::Dot => "dot",
MsoLineDashStyle::LongDash => "lgDash",
MsoLineDashStyle::LongDashDot => "lgDashDot",
MsoLineDashStyle::LongDashDotDot => "lgDashDotDot",
MsoLineDashStyle::RoundDot => "sysDot",
MsoLineDashStyle::SysDash => "sysDash",
MsoLineDashStyle::SysDashDot => "sysDashDot",
MsoLineDashStyle::SysDashDotDot => "sysDashDotDot",
MsoLineDashStyle::SysDot => "sysDot",
MsoLineDashStyle::Mixed => "solid",
}
}
}
impl From<MsoLineDashStyle> for Dash {
fn from(s: MsoLineDashStyle) -> Self {
match s {
MsoLineDashStyle::Solid => Dash::Solid,
MsoLineDashStyle::Dash => Dash::Dash,
MsoLineDashStyle::DashDot => Dash::DashDot,
MsoLineDashStyle::DashDotDot => Dash::LgDashDotDot,
MsoLineDashStyle::Dot => Dash::Dot,
MsoLineDashStyle::LongDash => Dash::LgDash,
MsoLineDashStyle::LongDashDot => Dash::LgDashDot,
MsoLineDashStyle::LongDashDotDot => Dash::LgDashDotDot,
MsoLineDashStyle::RoundDot => Dash::SysDot,
MsoLineDashStyle::SysDash => Dash::SysDash,
MsoLineDashStyle::SysDashDot => Dash::SysDashDot,
MsoLineDashStyle::SysDashDotDot => Dash::SysDashDotDot,
MsoLineDashStyle::SysDot => Dash::SysDot,
MsoLineDashStyle::Mixed => Dash::Solid,
}
}
}