pub use super::autoshape_type::{MsoAutoShapeType, MsoShape};
pub use super::preset_geometry::PresetGeometry;
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PpPlaceholderType {
Bitmap,
Body,
CenterTitle,
Chart,
Date,
Footer,
Header,
MediaClip,
Object,
OrgChart,
Picture,
SlideImage,
SlideNumber,
Subtitle,
Table,
Title,
VerticalBody,
VerticalObject,
VerticalTitle,
}
pub type PpPlaceholder = PpPlaceholderType;
impl PpPlaceholderType {
#[must_use]
pub const fn to_xml_str(self) -> &'static str {
match self {
Self::Bitmap => "clipArt",
Self::Body => "body",
Self::CenterTitle => "ctrTitle",
Self::Chart => "chart",
Self::Date => "dt",
Self::Footer => "ftr",
Self::Header => "hdr",
Self::MediaClip => "media",
Self::Object => "obj",
Self::OrgChart => "dgm",
Self::Picture => "pic",
Self::SlideImage => "sldImg",
Self::SlideNumber => "sldNum",
Self::Subtitle => "subTitle",
Self::Table => "tbl",
Self::Title => "title",
Self::VerticalBody | Self::VerticalObject | Self::VerticalTitle => "",
}
}
#[must_use]
pub fn from_xml_str(s: &str) -> Option<Self> {
match s {
"clipArt" => Some(Self::Bitmap),
"body" => Some(Self::Body),
"ctrTitle" => Some(Self::CenterTitle),
"chart" => Some(Self::Chart),
"dt" => Some(Self::Date),
"ftr" => Some(Self::Footer),
"hdr" => Some(Self::Header),
"media" => Some(Self::MediaClip),
"obj" => Some(Self::Object),
"dgm" => Some(Self::OrgChart),
"pic" => Some(Self::Picture),
"sldImg" => Some(Self::SlideImage),
"sldNum" => Some(Self::SlideNumber),
"subTitle" => Some(Self::Subtitle),
"tbl" => Some(Self::Table),
"title" => Some(Self::Title),
_ => None,
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MsoShapeType {
AutoShape,
Callout,
Canvas,
Chart,
Comment,
Diagram,
EmbeddedOleObject,
FormControl,
Freeform,
Group,
IgxGraphic,
Ink,
InkComment,
Line,
LinkedOleObject,
LinkedPicture,
Media,
OleControlObject,
Picture,
Placeholder,
ScriptAnchor,
Table,
TextBox,
TextEffect,
WebVideo,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MsoConnectorType {
Curve,
Elbow,
Straight,
}
impl MsoConnectorType {
#[must_use]
pub const fn to_xml_str(self) -> &'static str {
match self {
Self::Curve => "curvedConnector3",
Self::Elbow => "bentConnector3",
Self::Straight => "line",
}
}
#[must_use]
pub fn from_xml_str(s: &str) -> Option<Self> {
match s {
"curvedConnector3" => Some(Self::Curve),
"bentConnector3" => Some(Self::Elbow),
"line" => Some(Self::Straight),
_ => None,
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PlaceholderOrientation {
Horizontal,
Vertical,
}
impl PlaceholderOrientation {
#[must_use]
pub const fn to_xml_str(self) -> &'static str {
match self {
Self::Horizontal => "horz",
Self::Vertical => "vert",
}
}
#[must_use]
pub fn from_xml_str(s: &str) -> Option<Self> {
match s {
"horz" => Some(Self::Horizontal),
"vert" => Some(Self::Vertical),
_ => None,
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PlaceholderSize {
Full,
Half,
Quarter,
}
impl PlaceholderSize {
#[must_use]
pub const fn to_xml_str(self) -> &'static str {
match self {
Self::Full => "full",
Self::Half => "half",
Self::Quarter => "quarter",
}
}
#[must_use]
pub fn from_xml_str(s: &str) -> Option<Self> {
match s {
"full" => Some(Self::Full),
"half" => Some(Self::Half),
"quarter" => Some(Self::Quarter),
_ => None,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_placeholder_to_xml_str() {
assert_eq!(PpPlaceholderType::Title.to_xml_str(), "title");
assert_eq!(PpPlaceholderType::Body.to_xml_str(), "body");
assert_eq!(PpPlaceholderType::Date.to_xml_str(), "dt");
}
#[test]
fn test_placeholder_from_xml_str() {
assert_eq!(
PpPlaceholderType::from_xml_str("title"),
Some(PpPlaceholderType::Title)
);
assert_eq!(
PpPlaceholderType::from_xml_str("body"),
Some(PpPlaceholderType::Body)
);
assert_eq!(PpPlaceholderType::from_xml_str("unknown"), None);
}
#[test]
fn test_connector_roundtrip() {
let connectors = [
MsoConnectorType::Curve,
MsoConnectorType::Elbow,
MsoConnectorType::Straight,
];
for c in connectors {
let xml = c.to_xml_str();
assert_eq!(MsoConnectorType::from_xml_str(xml), Some(c));
}
}
#[test]
fn test_placeholder_orientation_roundtrip() {
assert_eq!(
PlaceholderOrientation::from_xml_str("horz"),
Some(PlaceholderOrientation::Horizontal)
);
assert_eq!(
PlaceholderOrientation::from_xml_str("vert"),
Some(PlaceholderOrientation::Vertical)
);
assert_eq!(PlaceholderOrientation::from_xml_str("unknown"), None);
assert_eq!(PlaceholderOrientation::Horizontal.to_xml_str(), "horz");
assert_eq!(PlaceholderOrientation::Vertical.to_xml_str(), "vert");
}
#[test]
fn test_placeholder_size_roundtrip() {
assert_eq!(
PlaceholderSize::from_xml_str("full"),
Some(PlaceholderSize::Full)
);
assert_eq!(
PlaceholderSize::from_xml_str("half"),
Some(PlaceholderSize::Half)
);
assert_eq!(
PlaceholderSize::from_xml_str("quarter"),
Some(PlaceholderSize::Quarter)
);
assert_eq!(PlaceholderSize::from_xml_str("unknown"), None);
assert_eq!(PlaceholderSize::Full.to_xml_str(), "full");
assert_eq!(PlaceholderSize::Half.to_xml_str(), "half");
assert_eq!(PlaceholderSize::Quarter.to_xml_str(), "quarter");
}
}