#[cfg(feature = "serde")]
use serde::Serialize;
use crate::raw::drawing::text::paragraph::auto_numbered_bullet::XlsxAutoNumberedBullet;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct AutoNumberedBullet {
pub start_number: u64,
pub bullet_type: TextAutoNumberSchemeValues,
}
impl AutoNumberedBullet {
pub(crate) fn from_raw(raw: XlsxAutoNumberedBullet) -> Self {
let start_number = if let Some(s) = raw.clone().start_at {
if (1..=32767).contains(&s) {
s
} else {
1
}
} else {
1
};
return Self {
start_number,
bullet_type: TextAutoNumberSchemeValues::from_string(raw.clone().r#type),
};
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
pub enum TextAutoNumberSchemeValues {
AlphaLowerCharacterParenBoth,
AlphaLowerCharacterParenR,
AlphaLowerCharacterPeriod,
AlphaUpperCharacterParenBoth,
AlphaUpperCharacterParenR,
AlphaUpperCharacterPeriod,
Arabic1Minus,
Arabic2Minus,
ArabicDoubleBytePeriod,
ArabicDoubleBytePlain,
ArabicParenBoth,
ArabicParenR,
ArabicPeriod,
ArabicPlain,
CircleNumberDoubleBytePlain,
CircleNumberWingdingsBlackPlain,
CircleNumberWingdingsWhitePlain,
EastAsianJapaneseDoubleBytePeriod,
EastAsianJapaneseKoreanPeriod,
EastAsianJapaneseKoreanPlain,
EastAsianSimplifiedChinesePeriod,
EastAsianSimplifiedChinesePlain,
EastAsianTraditionalChinesePeriod,
EastAsianTraditionalChinesePlain,
Hebrew2Minus,
HindiAlpha1Period,
HindiAlphaPeriod,
HindiNumberParenthesisRight,
HindiNumPeriod,
RomanLowerCharacterParenBoth,
RomanLowerCharacterParenR,
RomanLowerCharacterPeriod,
RomanUpperCharacterParenBoth,
RomanUpperCharacterParenR,
RomanUpperCharacterPeriod,
ThaiAlphaParenthesisBoth,
ThaiAlphaParenthesisRight,
ThaiAlphaPeriod,
ThaiNumberParenthesisBoth,
ThaiNumberParenthesisRight,
ThaiNumberPeriod,
}
impl TextAutoNumberSchemeValues {
pub(crate) fn default() -> Self {
Self::ArabicPeriod
}
pub(crate) fn from_string(s: Option<String>) -> Self {
let Some(s) = s else { return Self::default() };
return match s.as_ref() {
"alphaLcParenBoth" => Self::AlphaLowerCharacterParenBoth,
"alphaLcParenR" => Self::AlphaLowerCharacterParenR,
"alphaLcPeriod" => Self::AlphaLowerCharacterPeriod,
"alphaUcParenBoth" => Self::AlphaUpperCharacterParenBoth,
"alphaUcParenR" => Self::AlphaUpperCharacterParenR,
"alphaUcPeriod" => Self::AlphaUpperCharacterPeriod,
"arabic1Minus" => Self::Arabic1Minus,
"arabic2Minus" => Self::Arabic2Minus,
"arabicDbPeriod" => Self::ArabicDoubleBytePeriod,
"arabicDbPlain" => Self::ArabicDoubleBytePlain,
"arabicParenBoth" => Self::ArabicParenBoth,
"arabicParenR" => Self::ArabicParenR,
"arabicPeriod" => Self::ArabicPeriod,
"arabicPlain" => Self::ArabicPlain,
"circleNumDbPlain" => Self::CircleNumberDoubleBytePlain,
"circleNumWdBlackPlain" => Self::CircleNumberWingdingsBlackPlain,
"circleNumWdWhitePlain" => Self::CircleNumberWingdingsWhitePlain,
"ea1JpnChsDbPeriod" => Self::EastAsianJapaneseDoubleBytePeriod,
"ea1JpnKorPeriod" => Self::EastAsianJapaneseKoreanPeriod,
"ea1JpnKorPlain" => Self::EastAsianJapaneseKoreanPlain,
"ea1ChsPeriod" => Self::EastAsianSimplifiedChinesePeriod,
"ea1ChsPlain" => Self::EastAsianSimplifiedChinesePlain,
"ea1ChtPeriod" => Self::EastAsianTraditionalChinesePeriod,
"ea1ChtPlain" => Self::EastAsianTraditionalChinesePlain,
"hebrew2Minus" => Self::Hebrew2Minus,
"hindiAlpha1Period" => Self::HindiAlpha1Period,
"hindiAlphaPeriod" => Self::HindiAlphaPeriod,
"hindiNumParenR" => Self::HindiNumberParenthesisRight,
"hindiNumPeriod" => Self::HindiNumPeriod,
"romanLcParenBoth" => Self::RomanLowerCharacterParenBoth,
"romanLcParenR" => Self::RomanLowerCharacterParenR,
"romanLcPeriod" => Self::RomanLowerCharacterPeriod,
"romanUcParenBoth" => Self::RomanUpperCharacterParenBoth,
"romanUcParenR" => Self::RomanUpperCharacterParenR,
"romanUcPeriod" => Self::RomanUpperCharacterPeriod,
"thaiAlphaParenBoth" => Self::ThaiAlphaParenthesisBoth,
"thaiAlphaParenR" => Self::ThaiAlphaParenthesisRight,
"thaiAlphaPeriod" => Self::ThaiAlphaPeriod,
"thaiNumParenBoth" => Self::ThaiNumberParenthesisBoth,
"thaiNumParenR" => Self::ThaiNumberParenthesisRight,
"thaiNumPeriod" => Self::ThaiNumberPeriod,
_ => Self::default(),
};
}
}