#![allow(dead_code)]
use hard_xml::{XmlRead, XmlWrite};
use std::borrow::Cow;
use crate::{
__define_enum, __define_struct, __string_enum,
document::HeaderFooterReference,
formatting::{PageCols, PageGrid, PageMargin, PageSize},
};
use super::Bidi;
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:sectPr")]
pub struct SectionProperty<'a> {
#[xml(attr = "w:rsidR")]
pub rsid_r: Option<Cow<'a, str>>,
#[xml(attr = "w:rsidRDefault")]
pub rsid_r_default: Option<Cow<'a, str>>,
#[xml(child = "w:headerReference", child = "w:footerReference")]
pub header_footer_references: Vec<HeaderFooterReference<'a>>,
#[xml(child = "w:footnotePr")]
pub footnote_property: Option<FootnoteProperty>,
#[xml(child = "w:endnotePr")]
pub endnote_property: Option<EndnoteProperty>,
#[xml(child = "w:type")]
pub ty: Option<SectionTypeP>,
#[xml(child = "w:pgSz")]
pub page_size: Option<PageSize>,
#[xml(child = "w:pgMar")]
pub page_margin: Option<PageMargin>,
#[xml(child = "w:paperSrc")]
pub paper_source: Option<PaperSource>,
#[xml(child = "w:pgBorders")]
pub page_borders: Option<PgBorders>,
#[xml(child = "w:lnNumType")]
pub line_numbering: Option<PgLnNumType>,
#[xml(child = "w:pgNumType")]
pub page_numbering: Option<PgNumType>,
#[xml(child = "w:cols")]
pub cols: Option<PageCols>,
#[xml(child = "w:formProt")]
pub form_prot: Option<FormProt>,
#[xml(child = "w:vAlign")]
pub v_align: Option<VAlign>,
#[xml(child = "w:noEndnote")]
pub no_endnote: Option<NoEndnote>,
#[xml(child = "w:titlePg")]
pub title_page: Option<TitlePage>,
#[xml(child = "w:textDirection")]
pub text_direction: Option<TextDirection>,
#[xml(child = "w:bidi")]
pub bidi: Option<Bidi>,
#[xml(child = "w:rtlGutter")]
pub rtl_gutter: Option<RtlGutter>,
#[xml(child = "w:docGrid")]
pub grid: Option<PageGrid>,
#[xml(child = "w:sectPrChange")]
pub revision: Option<Revision<'a>>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:sectPr")]
pub struct PreviousSectionProperty<'a> {
#[xml(attr = "w:rsidR")]
pub rsid_r: Option<Cow<'a, str>>,
#[xml(attr = "w:rsidRDefault")]
pub rsid_r_default: Option<Cow<'a, str>>,
#[xml(child = "w:footnotePr")]
pub footnote_property: Option<FootnoteProperty>,
#[xml(child = "w:endnotePr")]
pub endnote_property: Option<EndnoteProperty>,
#[xml(child = "w:type")]
pub ty: Option<SectionTypeP>,
#[xml(child = "w:pgSz")]
pub page_size: Option<PageSize>,
#[xml(child = "w:pgMar")]
pub page_margin: Option<PageMargin>,
#[xml(child = "w:paperSrc")]
pub paper_source: Option<PaperSource>,
#[xml(child = "w:pgBorders")]
pub page_borders: Option<PgBorders>,
#[xml(child = "w:lnNumType")]
pub line_numbering: Option<PgLnNumType>,
#[xml(child = "w:pgNumType")]
pub page_numbering: Option<PgNumType>,
#[xml(child = "w:cols")]
pub cols: Option<PageCols>,
#[xml(child = "w:formProt")]
pub form_prot: Option<FormProt>,
#[xml(child = "w:vAlign")]
pub v_align: Option<VAlign>,
#[xml(child = "w:noEndnote")]
pub no_endnote: Option<NoEndnote>,
#[xml(child = "w:titlePg")]
pub title_page: Option<TitlePage>,
#[xml(child = "w:textDirection")]
pub text_direction: Option<TextDirection>,
#[xml(child = "w:bidi")]
pub bidi: Option<Bidi>,
#[xml(child = "w:rtlGutter")]
pub rtl_gutter: Option<RtlGutter>,
#[xml(child = "w:docGrid")]
pub grid: Option<PageGrid>,
}
__define_struct! {
("w:pgBorders", PgBorders) {
"w:zOrder", z_order, PageBorderZOrder "w:display", display, PageBorderDisplay "w:offsetFrom", offset_from, PageBorderOffset } {
"w:top", top, PgTopBorder
"w:left", left, PgLeftBorder
"w:bottom", bottom, PgBottomBorder
"w:right", right, PgRightBorder
}
}
__define_enum! {
PageBorderZOrder {
Front = "front", Back = "back", }
}
__define_enum! {
PageBorderDisplay {
AllPages = "allPages", FirstPage = "firstPage", NotFirstPage = "notFirstPage", }
}
__define_enum! {
PageBorderOffset {
Page = "page", Text = "text", }
}
__define_struct! {
("w:top", PgTopBorder) {
"w:val", style, super::BorderStyle
"w:color", color, String
"w:themeColor", theme_color, crate::formatting::ThemeColor
"w:themeTint", theme_tint, String
"w:themeShade", theme_shade, String
"w:sz", size, isize "w:space", space, isize
"w:shadow", shadow, bool
"w:frame", frame, bool
}
}
__define_struct! {
("w:bottom", PgBottomBorder) {
"w:val", style, super::BorderStyle
"w:color", color, String
"w:themeColor", theme_color, crate::formatting::ThemeColor
"w:themeTint", theme_tint, String
"w:themeShade", theme_shade, String
"w:sz", size, isize "w:space", space, isize
"w:shadow", shadow, bool
"w:frame", frame, bool
}
}
__define_struct! {
("w:left", PgLeftBorder) {
"w:val", style, super::BorderStyle
"w:color", color, String
"w:themeColor", theme_color, crate::formatting::ThemeColor
"w:themeTint", theme_tint, String
"w:themeShade", theme_shade, String
"w:sz", size, isize "w:space", space, isize
"w:shadow", shadow, bool
"w:frame", frame, bool
}
}
__define_struct! {
("w:right", PgRightBorder) {
"w:val", style, super::BorderStyle
"w:color", color, String
"w:themeColor", theme_color, crate::formatting::ThemeColor
"w:themeTint", theme_tint, String
"w:themeShade", theme_shade, String
"w:sz", size, isize "w:space", space, isize
"w:shadow", shadow, bool
"w:frame", frame, bool
}
}
__define_struct! {
("w:lnNumType", PgLnNumType) {
"w:countBy", count_by, isize "w:start", start, isize "w:distance", distance, isize "w:restart", restart, LineNumberRestart }
}
__define_enum! {
LineNumberRestart
{
NewPage = "newPage", NewSection = "newSection", Continuous = "continuous", }
}
__define_struct! {
("w:pgNumType", PgNumType) {
"w:fmt", fmt, NumberFormat "w:start", start, isize "w:chapStyle", chap_style, isize"w:chapSep", chap_sep, ChapterSep}
}
__define_enum! {
NumberFormat {
Decimal = "decimal", UpperRoman = "upperRoman", LowerRoman = "lowerRoman", UpperLetter = "upperLetter", LowerLetter = "lowerLetter", Ordinal = "ordinal", CardinalText = "cardinalText", OrdinalText = "ordinalText", Hex = "hex", Chicago = "chicago", IdeographDigital = "ideographDigital", JapaneseCounting = "japaneseCounting", Aiueo = "aiueo", Iroha = "iroha", DecimalFullWidth = "decimalFullWidth", DecimalHalfWidth = "decimalHalfWidth", JapaneseLegal = "japaneseLegal", JapaneseDigitalTenThousand = "japaneseDigitalTenThousand", DecimalEnclosedCircle = "decimalEnclosedCircle", DecimalFullWidth2 = "decimalFullWidth2", AiueoFullWidth = "aiueoFullWidth", IrohaFullWidth = "irohaFullWidth", DecimalZero = "decimalZero", Bullet = "bullet", Ganada = "ganada", Chosung = "chosung", DecimalEnclosedFullstop = "decimalEnclosedFullstop", DecimalEnclosedParen = "decimalEnclosedParen", DecimalEnclosedCircleChinese = "decimalEnclosedCircleChinese", IdeographEnclosedCircle = "ideographEnclosedCircle", IdeographTraditional = "ideographTraditional", IdeographZodiac = "ideographZodiac", IdeographZodiacTraditional = "ideographZodiacTraditional", TaiwaneseCounting = "taiwaneseCounting", IdeographLegalTraditional = "ideographLegalTraditional", TaiwaneseCountingThousand = "taiwaneseCountingThousand", TaiwaneseDigital = "taiwaneseDigital", ChineseCounting = "chineseCounting", ChineseLegalSimplified = "chineseLegalSimplified", ChineseCountingThousand = "chineseCountingThousand", KoreanDigital = "koreanDigital", KoreanCounting = "koreanCounting", KoreanLegal = "koreanLegal", KoreanDigital2 = "koreanDigital2", VietnameseCounting = "vietnameseCounting", RussianLower = "russianLower", RussianUpper = "russianUpper", None = "none", NumberInDash = "numberInDash", Hebrew1 = "hebrew1", Hebrew2 = "hebrew2", ArabicAlpha = "arabicAlpha", ArabicAbjad = "arabicAbjad", HindiVowels = "hindiVowels", HindiConsonants = "hindiConsonants", HindiNumbers = "hindiNumbers", HindiCounting = "hindiCounting", ThaiLetters = "thaiLetters", ThaiNumbers = "thaiNumbers", ThaiCounting = "thaiCounting", }
}
__define_enum! {
ChapterSep {
Hyphen = "hyphen", Period = "period", Colon = "colon", EmDash = "emDash", EnDash = "enDash", }
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:sectPrChange")]
pub struct Revision<'a> {
#[xml(attr = "w:id")]
pub id: isize,
#[xml(attr = "w:author")]
pub author: Cow<'a, str>,
#[xml(attr = "w:date")]
pub date: Option<Cow<'a, str>>,
#[xml(child = "w:secPr")]
pub section_property: Option<PreviousSectionProperty<'a>>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:type")]
pub struct SectionTypeP {
#[xml(attr = "w:val")]
pub ty: Option<SectionType>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:formProt")]
pub struct FormProt {
#[xml(attr = "w:val")]
pub val: Option<bool>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:noEndnote")]
pub struct NoEndnote {
#[xml(attr = "w:val")]
pub val: Option<bool>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:paperSrc")]
pub struct PaperSource {
#[xml(attr = "w:first")]
pub first: Option<isize>,
#[xml(attr = "w:other")]
pub other: Option<isize>,
}
__define_struct! {
("w:textAlignment", TextAlignment) {
"w:val", val, TextAlignmentType
}
}
__define_enum! {
TextAlignmentType {
Top = "top", Center = "center", Baseline = "baseline", Bottom = "bottom", Auto = "auto", }
}
__define_struct! {
("w:textboxTightWrap", TextboxTightWrap) {
"w:val", val, TextboxTightWrapType
}
}
__define_enum! {
TextboxTightWrapType {
None = "none", AllLines = "allLines", FirstAndLastLine = "firstAndLastLine", FirstLineOnly = "firstLineOnly", LastLineOnly = "lastLineOnly", }
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:textDirection")]
pub struct TextDirection {
#[xml(attr = "w:val")]
pub val: TextDirectionType,
}
#[derive(Debug, Default, Clone)]
#[cfg_attr(test, derive(PartialEq))]
pub enum TextDirectionType {
#[default]
LrTb, TbRl, BtLr, LrTbV, TbRlV, TbLrV, }
__string_enum! {
TextDirectionType {
LrTb = "lrTb",
TbRl = "tbRl",
BtLr = "btLr",
LrTbV = "lrTbV",
TbRlV = "tbRlV",
TbLrV = "tbLrV",
}
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:vAlign")]
pub struct VAlign {
#[xml(attr = "w:val")]
pub val: TextDirectionType,
}
#[derive(Debug, Default, Clone)]
#[cfg_attr(test, derive(PartialEq))]
pub enum VAlignType {
#[default]
Top, Center, Both, Bottom, }
__string_enum! {
VAlignType {
Top = "top",
Center = "center",
Both = "both",
Bottom = "bottom",
}
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:rtlGutter")]
pub struct RtlGutter {
#[xml(attr = "w:val")]
pub val: Option<bool>,
}
#[derive(Debug, Clone)]
#[cfg_attr(test, derive(PartialEq))]
pub enum SectionType {
NextPage,
NextColumn,
Continuous,
EvenPage,
OddPage,
}
__string_enum! {
SectionType {
NextPage = "nextPage",
NextColumn = "nextColumn",
Continuous = "continuous",
EvenPage = "evenPage",
OddPage = "oddPage",
}
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:titlePg")]
pub struct TitlePage {}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:footnotePr")]
pub struct FootnoteProperty {
#[xml(child = "w:pos")]
pub position: Option<FootnotePosition>,
#[xml(child = "w:numFmt")]
pub num_fmt: Option<NumFmt>,
#[xml(child = "w:numStart")]
pub num_start: Option<NumStart>,
#[xml(child = "w:numRestart")]
pub num_restart: Option<NumRestart>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:endnotePr")]
pub struct EndnoteProperty {
#[xml(child = "w:pos")]
pub position: Option<EndnotePosition>,
#[xml(child = "w:numFmt")]
pub num_fmt: Option<NumFmt>,
#[xml(child = "w:numStart")]
pub num_start: Option<NumStart>,
#[xml(child = "w:numRestart")]
pub num_restart: Option<NumRestart>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:footnotePr")]
pub struct FootnoteProperty2 {
#[xml(child = "w:pos")]
pub position: Option<FootnotePosition>,
#[xml(child = "w:numFmt")]
pub num_fmt: Option<NumFmt>,
#[xml(child = "w:numStart")]
pub num_start: Option<NumStart>,
#[xml(child = "w:numRestart")]
pub num_restart: Option<NumRestart>,
#[xml(child = "w:footnote")]
pub footnote: Vec<Footnote>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:footnote")]
pub struct Footnote {
#[xml(attr = "w:id")]
pub id: isize,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:endnotePr")]
pub struct EndnoteProperty2 {
#[xml(child = "w:pos")]
pub position: Option<EndnotePosition>,
#[xml(child = "w:numFmt")]
pub num_fmt: Option<NumFmt>,
#[xml(child = "w:numStart")]
pub num_start: Option<NumStart>,
#[xml(child = "w:numRestart")]
pub num_restart: Option<NumRestart>,
#[xml(child = "w:endnote")]
pub endnote: Vec<Endnote>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:endnote")]
pub struct Endnote {
#[xml(attr = "w:id")]
pub id: isize,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:numRestart")]
pub struct NumRestart {
#[xml(attr = "w:val")]
pub val: NumRestartType,
}
#[derive(Debug, Default, Clone)]
#[cfg_attr(test, derive(PartialEq))]
pub enum NumRestartType {
#[default]
Continuous, EachSect, EachPage, }
__string_enum! {
NumRestartType {
Continuous = "continuous",
EachSect = "eachSect",
EachPage = "eachPage",
}
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:numStart")]
pub struct NumStart {
#[xml(attr = "w:val")]
pub val: Option<isize>,
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:numFmt")]
pub struct NumFmt {
#[xml(attr = "w:val")]
pub ty: NumFmtType,
}
#[derive(Debug, Default, Clone)]
#[cfg_attr(test, derive(PartialEq))]
pub enum NumFmtType {
#[default]
Decimal, UpperRoman, LowerRoman, UpperLetter, LowerLetter, Ordinal, CardinalText, OrdinalText, Hex, Chicago, IdeographDigital, JapaneseCounting, Aiueo, Iroha, DecimalFullWidth, DecimalHalfWidth, JapaneseLegal, JapaneseDigitalTenThousand, DecimalEnclosedCircle, DecimalFullWidth2, AiueoFullWidth, IrohaFullWidth, DecimalZero, Bullet, Ganada, Chosung, DecimalEnclosedFullstop, DecimalEnclosedParen, DecimalEnclosedCircleChinese, IdeographEnclosedCircle, IdeographTraditional, IdeographZodiac, IdeographZodiacTraditional, TaiwaneseCounting, IdeographLegalTraditional, TaiwaneseCountingThousand, TaiwaneseDigital, ChineseCounting, ChineseLegalSimplified, ChineseCountingThousand, KoreanDigital, KoreanCounting, KoreanLegal, KoreanDigital2, VietnameseCounting, RussianLower, RussianUpper, None, NumberInDash, Hebrew1, Hebrew2, ArabicAlpha, ArabicAbjad, HindiVowels, HindiConsonants, HindiNumbers, HindiCounting, ThaiLetters, ThaiNumbers, ThaiCounting, }
__string_enum! {
NumFmtType {
Decimal = "decimal",
UpperRoman = "upperRoman",
LowerRoman = "lowerRoman",
UpperLetter = "upperLetter",
LowerLetter = "lowerLetter",
Ordinal = "ordinal",
CardinalText = "cardinalText",
OrdinalText = "ordinalText",
Hex = "hex",
Chicago = "chicago",
IdeographDigital = "ideographDigital",
JapaneseCounting = "japaneseCounting",
Aiueo = "aiueo",
Iroha = "iroha",
DecimalFullWidth = "decimalFullWidth",
DecimalHalfWidth = "decimalHalfWidth",
JapaneseLegal = "japaneseLegal",
JapaneseDigitalTenThousand = "japaneseDigitalTenThousand",
DecimalEnclosedCircle = "decimalEnclosedCircle",
DecimalFullWidth2 = "decimalFullWidth2",
AiueoFullWidth = "aiueoFullWidth",
IrohaFullWidth = "irohaFullWidth",
DecimalZero = "decimalZero",
Bullet = "bullet",
Ganada = "ganada",
Chosung = "chosung",
DecimalEnclosedFullstop = "decimalEnclosedFullstop",
DecimalEnclosedParen = "decimalEnclosedParen",
DecimalEnclosedCircleChinese = "decimalEnclosedCircleChinese",
IdeographEnclosedCircle = "ideographEnclosedCircle",
IdeographTraditional = "ideographTraditional",
IdeographZodiac = "ideographZodiac",
IdeographZodiacTraditional = "ideographZodiacTraditional",
TaiwaneseCounting = "taiwaneseCounting",
IdeographLegalTraditional = "ideographLegalTraditional",
TaiwaneseCountingThousand = "taiwaneseCountingThousand",
TaiwaneseDigital = "taiwaneseDigital",
ChineseCounting = "chineseCounting",
ChineseLegalSimplified = "chineseLegalSimplified",
ChineseCountingThousand = "chineseCountingThousand",
KoreanDigital = "koreanDigital",
KoreanCounting = "koreanCounting",
KoreanLegal = "koreanLegal",
KoreanDigital2 = "koreanDigital2",
VietnameseCounting = "vietnameseCounting",
RussianLower = "russianLower",
RussianUpper = "russianUpper",
None = "none",
NumberInDash = "numberInDash",
Hebrew1 = "hebrew1",
Hebrew2 = "hebrew2",
ArabicAlpha = "arabicAlpha",
ArabicAbjad = "arabicAbjad",
HindiVowels = "hindiVowels",
HindiConsonants = "hindiConsonants",
HindiNumbers = "hindiNumbers",
HindiCounting = "hindiCounting",
ThaiLetters = "thaiLetters",
ThaiNumbers = "thaiNumbers",
ThaiCounting = "thaiCounting",
}
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:pos")]
pub struct FootnotePosition {
#[xml(attr = "w:val")]
pub val: PositionType,
}
#[derive(Debug, Default, Clone)]
#[cfg_attr(test, derive(PartialEq))]
pub enum PositionType {
#[default]
PageBottom, BeneathText, SectEnd, DocEnd, }
__string_enum! {
PositionType {
PageBottom = "pageBottom",
BeneathText = "beneathText",
SectEnd = "sectEnd",
DocEnd = "docEnd",
}
}
#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:pos")]
pub struct EndnotePosition {
#[xml(attr = "w:val")]
pub val: EndnotePositionType,
}
#[derive(Debug, Default, Clone)]
#[cfg_attr(test, derive(PartialEq))]
pub enum EndnotePositionType {
#[default]
SectEnd, DocEnd, }
__string_enum! {
EndnotePositionType {
SectEnd = "sectEnd",
DocEnd = "docEnd",
}
}
impl<'a> SectionProperty<'a> {
fn first_page_has_diffrent_header_and_footer(&mut self, val: bool) -> &mut Self {
if val {
self.title_page = Some(TitlePage::default());
} else {
self.title_page = None;
}
self
}
}