docx_rust/formatting/
section_property.rs

1#![allow(dead_code)]
2use hard_xml::{XmlRead, XmlWrite};
3use std::borrow::Cow;
4
5use crate::{
6    __define_enum, __define_struct, __string_enum,
7    document::HeaderFooterReference,
8    formatting::{PageCols, PageGrid, PageMargin, PageSize},
9};
10
11use super::Bidi;
12
13/// Section Properties
14///
15#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
16#[cfg_attr(test, derive(PartialEq))]
17#[xml(tag = "w:sectPr")]
18pub struct SectionProperty<'a> {
19    //#[xml(attr = "w14:paraId")]
20    //pub id: Option<Cow<'a, str>>,
21    //#[xml(attr = "w14:textId")]
22    //pub text_id: Option<Cow<'a, str>>,
23    #[xml(attr = "w:rsidR")]
24    pub rsid_r: Option<Cow<'a, str>>,
25    #[xml(attr = "w:rsidRDefault")]
26    pub rsid_r_default: Option<Cow<'a, str>>,
27
28    #[xml(child = "w:headerReference", child = "w:footerReference")]
29    /// Specifies the content of a run
30    pub header_footer_references: Vec<HeaderFooterReference<'a>>,
31    ///  Section-Wide Footnote Properties
32    #[xml(child = "w:footnotePr")]
33    pub footnote_property: Option<FootnoteProperty>,
34    ///  Section-Wide Endnote Properties
35    #[xml(child = "w:endnotePr")]
36    pub endnote_property: Option<EndnoteProperty>,
37    ///  Section Type
38    #[xml(child = "w:type")]
39    pub ty: Option<SectionTypeP>,
40    #[xml(child = "w:pgSz")]
41    pub page_size: Option<PageSize>,
42    #[xml(child = "w:pgMar")]
43    pub page_margin: Option<PageMargin>,
44    ///  Paper Source Information
45    #[xml(child = "w:paperSrc")]
46    pub paper_source: Option<PaperSource>,
47    ///  Page Borders
48    #[xml(child = "w:pgBorders")]
49    pub page_borders: Option<PgBorders>,
50    ///  Line Numbering Settings
51    #[xml(child = "w:lnNumType")]
52    pub line_numbering: Option<PgLnNumType>,
53    ///  Page Numbering Settings
54    #[xml(child = "w:pgNumType")]
55    pub page_numbering: Option<PgNumType>,
56    ///  Column Definitions
57    #[xml(child = "w:cols")]
58    pub cols: Option<PageCols>,
59    ///  Only Allow Editing of Form Fields
60    #[xml(child = "w:formProt")]
61    pub form_prot: Option<FormProt>,
62    /////  Vertical Text Alignment on Page
63    #[xml(child = "w:vAlign")]
64    pub v_align: Option<VAlign>,
65    ///  Suppress Endnotes In Document
66    #[xml(child = "w:noEndnote")]
67    pub no_endnote: Option<NoEndnote>,
68    ///  Different First Page Headers and Footers
69    #[xml(child = "w:titlePg")]
70    pub title_page: Option<TitlePage>,
71    ///  Text Flow Direction
72    #[xml(child = "w:textDirection")]
73    pub text_direction: Option<TextDirection>,
74    ///  Right to Left Section Layout
75    #[xml(child = "w:bidi")]
76    pub bidi: Option<Bidi>,
77    ///  Gutter on Right Side of Page
78    #[xml(child = "w:rtlGutter")]
79    pub rtl_gutter: Option<RtlGutter>,
80    ///  Document Grid
81    #[xml(child = "w:docGrid")]
82    pub grid: Option<PageGrid>,
83    /////  Reference to Printer Settings Data
84    //#[xml(child = "w:printerSettings")]
85    //pub printer_settings: Option<PrinterSettings>,
86    /// Revision Information for Section Properties
87    #[xml(child = "w:sectPrChange")]
88    pub revision: Option<Revision<'a>>,
89}
90
91/// Previous Section Properties
92///
93#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
94#[cfg_attr(test, derive(PartialEq))]
95#[xml(tag = "w:sectPr")]
96pub struct PreviousSectionProperty<'a> {
97    //#[xml(attr = "w14:paraId")]
98    //pub id: Option<Cow<'a, str>>,
99    //#[xml(attr = "w14:textId")]
100    //pub text_id: Option<Cow<'a, str>>,
101    #[xml(attr = "w:rsidR")]
102    pub rsid_r: Option<Cow<'a, str>>,
103    #[xml(attr = "w:rsidRDefault")]
104    pub rsid_r_default: Option<Cow<'a, str>>,
105
106    ///  Section-Wide Footnote Properties
107    #[xml(child = "w:footnotePr")]
108    pub footnote_property: Option<FootnoteProperty>,
109    ///  Section-Wide Endnote Properties
110    #[xml(child = "w:endnotePr")]
111    pub endnote_property: Option<EndnoteProperty>,
112    ///  Section Type
113    #[xml(child = "w:type")]
114    pub ty: Option<SectionTypeP>,
115    #[xml(child = "w:pgSz")]
116    pub page_size: Option<PageSize>,
117    #[xml(child = "w:pgMar")]
118    pub page_margin: Option<PageMargin>,
119    ///  Paper Source Information
120    #[xml(child = "w:paperSrc")]
121    pub paper_source: Option<PaperSource>,
122    ///  Page Borders
123    #[xml(child = "w:pgBorders")]
124    pub page_borders: Option<PgBorders>,
125    ///  Line Numbering Settings
126    #[xml(child = "w:lnNumType")]
127    pub line_numbering: Option<PgLnNumType>,
128    ///  Page Numbering Settings
129    #[xml(child = "w:pgNumType")]
130    pub page_numbering: Option<PgNumType>,
131    ///  Column Definitions
132    #[xml(child = "w:cols")]
133    pub cols: Option<PageCols>,
134    ///  Only Allow Editing of Form Fields
135    #[xml(child = "w:formProt")]
136    pub form_prot: Option<FormProt>,
137    /////  Vertical Text Alignment on Page
138    #[xml(child = "w:vAlign")]
139    pub v_align: Option<VAlign>,
140    ///  Suppress Endnotes In Document
141    #[xml(child = "w:noEndnote")]
142    pub no_endnote: Option<NoEndnote>,
143    ///  Different First Page Headers and Footers
144    #[xml(child = "w:titlePg")]
145    pub title_page: Option<TitlePage>,
146    ///  Text Flow Direction
147    #[xml(child = "w:textDirection")]
148    pub text_direction: Option<TextDirection>,
149    ///  Right to Left Section Layout
150    #[xml(child = "w:bidi")]
151    pub bidi: Option<Bidi>,
152    ///  Gutter on Right Side of Page
153    #[xml(child = "w:rtlGutter")]
154    pub rtl_gutter: Option<RtlGutter>,
155    ///  Document Grid
156    #[xml(child = "w:docGrid")]
157    pub grid: Option<PageGrid>,
158    /////  Reference to Printer Settings Data
159    //#[xml(child = "w:printerSettings")]
160    //pub printer_settings: Option<PrinterSettings>,
161}
162
163__define_struct! {
164    ("w:pgBorders", PgBorders) {
165        "w:zOrder",	z_order, PageBorderZOrder	//Z-Ordering of Page Border
166        "w:display", display, PageBorderDisplay //Pages to Display Page Borders
167        "w:offsetFrom",	offset_from, PageBorderOffset 	//Page Border Positioning
168    } {
169        "w:top", top, PgTopBorder
170        "w:left", left, PgLeftBorder
171        "w:bottom", bottom, PgBottomBorder
172        "w:right", right, PgRightBorder
173    }
174}
175
176__define_enum! {
177    PageBorderZOrder {
178        Front = "front", // Page Border Ahead of Text
179        Back = "back", // Page Border Behind Text
180    }
181}
182
183__define_enum! {
184    PageBorderDisplay {
185        AllPages = "allPages", // Display Page Border on All Pages
186        FirstPage = "firstPage", // Display Page Border on First Page
187        NotFirstPage = "notFirstPage", // Display Page Border on All Pages Except First
188    }
189}
190
191__define_enum! {
192    PageBorderOffset {
193        Page = "page", // Page Border Is Positioned Relative to Page Edges
194        Text = "text", // Page Border Is Positioned Relative to Text Extents
195    }
196}
197
198__define_struct! {
199    ("w:top", PgTopBorder) {
200        "w:val", style, super::BorderStyle
201        "w:color", color, String
202        "w:themeColor", theme_color, crate::formatting::ThemeColor
203        "w:themeTint", theme_tint, String
204        "w:themeShade", theme_shade, String
205        "w:sz", size, isize // Measurement in Eighths of a Point
206        "w:space", space, isize
207        "w:shadow", shadow, bool
208        "w:frame", frame, bool
209    }
210}
211
212__define_struct! {
213    ("w:bottom", PgBottomBorder) {
214        "w:val", style, super::BorderStyle
215        "w:color", color, String
216        "w:themeColor", theme_color, crate::formatting::ThemeColor
217        "w:themeTint", theme_tint, String
218        "w:themeShade", theme_shade, String
219        "w:sz", size, isize // Measurement in Eighths of a Point
220        "w:space", space, isize
221        "w:shadow", shadow, bool
222        "w:frame", frame, bool
223    }
224}
225
226__define_struct! {
227    ("w:left", PgLeftBorder) {
228        "w:val", style, super::BorderStyle
229        "w:color", color, String
230        "w:themeColor", theme_color, crate::formatting::ThemeColor
231        "w:themeTint", theme_tint, String
232        "w:themeShade", theme_shade, String
233        "w:sz", size, isize // Measurement in Eighths of a Point
234        "w:space", space, isize
235        "w:shadow", shadow, bool
236        "w:frame", frame, bool
237    }
238}
239
240__define_struct! {
241    ("w:right", PgRightBorder) {
242        "w:val", style, super::BorderStyle
243        "w:color", color, String
244        "w:themeColor", theme_color, crate::formatting::ThemeColor
245        "w:themeTint", theme_tint, String
246        "w:themeShade", theme_shade, String
247        "w:sz", size, isize // Measurement in Eighths of a Point
248        "w:space", space, isize
249        "w:shadow", shadow, bool
250        "w:frame", frame, bool
251    }
252}
253
254__define_struct! {
255    ("w:lnNumType", PgLnNumType) {
256        "w:countBy", count_by, isize //	[0..1]	w:ST_DecimalNumber	Line Number Increments to Display
257        "w:start", start, isize //	[0..1]	w:ST_DecimalNumber	Line Numbering Starting Value
258        "w:distance", distance, isize //	[0..1]	w:ST_TwipsMeasure	Distance Between Text and Line Numbering
259        "w:restart", restart, LineNumberRestart //	[0..1]	w:ST_LineNumberRestart	Line Numbering Restart Setting
260    }
261}
262
263__define_enum! {
264    LineNumberRestart
265    {
266        NewPage = "newPage", // Restart Line Numbering on Each Page
267        NewSection = "newSection", // Restart Line Numbering for Each Section
268        Continuous = "continuous", // Continue Line Numbering From Previous Section
269    }
270}
271
272__define_struct! {
273    ("w:pgNumType", PgNumType) {
274        "w:fmt", fmt, NumberFormat	//Page Number Format
275        "w:start", start, isize //	[0..1]	w:ST_DecimalNumber	Starting Page Number
276        "w:chapStyle", chap_style, isize//	[0..1]	w:ST_DecimalNumber	Chapter Heading Style
277        "w:chapSep", chap_sep, ChapterSep//	Chapter Separator Character
278    }
279}
280
281__define_enum! {
282    NumberFormat {
283        Decimal = "decimal", // Decimal Numbers
284        UpperRoman = "upperRoman", // Uppercase Roman Numerals
285        LowerRoman = "lowerRoman", // Lowercase Roman Numerals
286        UpperLetter = "upperLetter", // Uppercase Latin Alphabet
287        LowerLetter = "lowerLetter", // Lowercase Latin Alphabet
288        Ordinal = "ordinal", // Ordinal
289        CardinalText = "cardinalText", // Cardinal Text
290        OrdinalText = "ordinalText", // Ordinal Text
291        Hex = "hex", // Hexadecimal Numbering
292        Chicago = "chicago", // Chicago Manual of Style
293        IdeographDigital = "ideographDigital", // Ideographs
294        JapaneseCounting = "japaneseCounting", // Japanese Counting System
295        Aiueo = "aiueo", // AIUEO Order Hiragana
296        Iroha = "iroha", // Iroha Ordered Katakana
297        DecimalFullWidth = "decimalFullWidth", // Double Byte Arabic Numerals
298        DecimalHalfWidth = "decimalHalfWidth", // Single Byte Arabic Numerals
299        JapaneseLegal = "japaneseLegal", // Japanese Legal Numbering
300        JapaneseDigitalTenThousand = "japaneseDigitalTenThousand", // Japanese Digital Ten Thousand Counting System
301        DecimalEnclosedCircle = "decimalEnclosedCircle", // Decimal Numbers Enclosed in a Circle
302        DecimalFullWidth2 = "decimalFullWidth2", // Double Byte Arabic Numerals Alternate
303        AiueoFullWidth = "aiueoFullWidth", // Full-Width AIUEO Order Hiragana
304        IrohaFullWidth = "irohaFullWidth", // Full-Width Iroha Ordered Katakana
305        DecimalZero = "decimalZero", // Initial Zero Arabic Numerals
306        Bullet = "bullet", // Bullet
307        Ganada = "ganada", // Korean Ganada Numbering
308        Chosung = "chosung", // Korean Chosung Numbering
309        DecimalEnclosedFullstop = "decimalEnclosedFullstop", // Decimal Numbers Followed by a Period
310        DecimalEnclosedParen = "decimalEnclosedParen", // Decimal Numbers Enclosed in Parenthesis
311        DecimalEnclosedCircleChinese = "decimalEnclosedCircleChinese", // Decimal Numbers Enclosed in a Circle
312        IdeographEnclosedCircle = "ideographEnclosedCircle", // Ideographs Enclosed in a Circle
313        IdeographTraditional = "ideographTraditional", // Traditional Ideograph Format
314        IdeographZodiac = "ideographZodiac", // Zodiac Ideograph Format
315        IdeographZodiacTraditional = "ideographZodiacTraditional", // Traditional Zodiac Ideograph Format
316        TaiwaneseCounting = "taiwaneseCounting", // Taiwanese Counting System
317        IdeographLegalTraditional = "ideographLegalTraditional", // Traditional Legal Ideograph Format
318        TaiwaneseCountingThousand = "taiwaneseCountingThousand", // Taiwanese Counting Thousand System
319        TaiwaneseDigital = "taiwaneseDigital", // Taiwanese Digital Counting System
320        ChineseCounting = "chineseCounting", // Chinese Counting System
321        ChineseLegalSimplified = "chineseLegalSimplified", // Chinese Legal Simplified Format
322        ChineseCountingThousand = "chineseCountingThousand", // Chinese Counting Thousand System
323        KoreanDigital = "koreanDigital", // Korean Digital Counting System
324        KoreanCounting = "koreanCounting", // Korean Counting System
325        KoreanLegal = "koreanLegal", // Korean Legal Numbering
326        KoreanDigital2 = "koreanDigital2", // Korean Digital Counting System Alternate
327        VietnameseCounting = "vietnameseCounting", // Vietnamese Numerals
328        RussianLower = "russianLower", // Lowercase Russian Alphabet
329        RussianUpper = "russianUpper", // Uppercase Russian Alphabet
330        None = "none", // No Numbering
331        NumberInDash = "numberInDash", // Number With Dashes
332        Hebrew1 = "hebrew1", // Hebrew Numerals
333        Hebrew2 = "hebrew2", // Hebrew Alphabet
334        ArabicAlpha = "arabicAlpha", // Arabic Alphabet
335        ArabicAbjad = "arabicAbjad", // Arabic Abjad Numerals
336        HindiVowels = "hindiVowels", // Hindi Vowels
337        HindiConsonants = "hindiConsonants", // Hindi Consonants
338        HindiNumbers = "hindiNumbers", // Hindi Numbers
339        HindiCounting = "hindiCounting", // Hindi Counting System
340        ThaiLetters = "thaiLetters", // Thai Letters
341        ThaiNumbers = "thaiNumbers", // Thai Numerals
342        ThaiCounting = "thaiCounting", // Thai Counting System
343    }
344}
345
346__define_enum! {
347    ChapterSep {
348        Hyphen = "hyphen", // Hyphen Chapter Separator
349        Period = "period", // Period Chapter Separator
350        Colon = "colon", // Colon Chapter Separator
351        EmDash = "emDash", // Em Dash Chapter Separator
352        EnDash = "enDash", // En Dash Chapter Separator
353    }
354}
355
356#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
357#[cfg_attr(test, derive(PartialEq))]
358#[xml(tag = "w:sectPrChange")]
359pub struct Revision<'a> {
360    #[xml(attr = "w:id")]
361    pub id: isize,
362    #[xml(attr = "w:author")]
363    pub author: Cow<'a, str>,
364    #[xml(attr = "w:date")]
365    pub date: Option<Cow<'a, str>>,
366
367    #[xml(child = "w:secPr")]
368    pub section_property: Option<PreviousSectionProperty<'a>>,
369}
370
371#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
372#[cfg_attr(test, derive(PartialEq))]
373#[xml(tag = "w:type")]
374pub struct SectionTypeP {
375    #[xml(attr = "w:val")]
376    pub ty: Option<SectionType>,
377}
378
379#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
380#[cfg_attr(test, derive(PartialEq))]
381#[xml(tag = "w:formProt")]
382pub struct FormProt {
383    #[xml(attr = "w:val")]
384    pub val: Option<bool>,
385}
386
387#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
388#[cfg_attr(test, derive(PartialEq))]
389#[xml(tag = "w:noEndnote")]
390pub struct NoEndnote {
391    #[xml(attr = "w:val")]
392    pub val: Option<bool>,
393}
394
395// #[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
396// #[cfg_attr(test, derive(PartialEq))]
397// #[xml(tag = "w:bidi")]
398// pub struct Bidi {
399//     #[xml(attr = "w:val")]
400//     pub val: Option<bool>,
401// }
402
403#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
404#[cfg_attr(test, derive(PartialEq))]
405#[xml(tag = "w:paperSrc")]
406pub struct PaperSource {
407    #[xml(attr = "w:first")]
408    pub first: Option<isize>,
409    #[xml(attr = "w:other")]
410    pub other: Option<isize>,
411}
412
413__define_struct! {
414    ("w:textAlignment", TextAlignment) {
415        "w:val", val, TextAlignmentType
416    }
417}
418
419__define_enum! {
420    TextAlignmentType {
421        Top = "top", // Align Text at Top
422        Center = "center", // Align Text at Center
423        Baseline = "baseline", // Align Text at Baseline
424        Bottom = "bottom", // Align Text at Bottom
425        Auto = "auto", // Automatically Determine Alignment
426    }
427}
428
429__define_struct! {
430    ("w:textboxTightWrap", TextboxTightWrap) {
431        "w:val", val, TextboxTightWrapType
432    }
433}
434
435__define_enum! {
436    TextboxTightWrapType {
437        None = "none", // Do Not Tight Wrap
438        AllLines = "allLines", // Tight Wrap All Lines
439        FirstAndLastLine = "firstAndLastLine", // Tight Wrap First and Last Lines
440        FirstLineOnly = "firstLineOnly", // Tight Wrap First Line
441        LastLineOnly = "lastLineOnly", // Tight Wrap Last Line
442    }
443}
444
445#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
446#[cfg_attr(test, derive(PartialEq))]
447#[xml(tag = "w:textDirection")]
448pub struct TextDirection {
449    #[xml(attr = "w:val")]
450    pub val: TextDirectionType,
451}
452
453#[derive(Debug, Default, Clone)]
454#[cfg_attr(test, derive(PartialEq))]
455pub enum TextDirectionType {
456    #[default]
457    LrTb, //	Left to Right, Top to Bottom
458    TbRl,  //		Top to Bottom, Right to Left
459    BtLr,  //		Bottom to Top, Left to Right
460    LrTbV, //		Left to Right, Top to Bottom Rotated
461    TbRlV, //		Top to Bottom, Right to Left Rotated
462    TbLrV, //		Top to Bottom, Left to Right Rotated
463}
464
465__string_enum! {
466    TextDirectionType {
467        LrTb = "lrTb",
468        TbRl = "tbRl",
469        BtLr = "btLr",
470        LrTbV = "lrTbV",
471        TbRlV = "tbRlV",
472        TbLrV = "tbLrV",
473    }
474}
475
476#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
477#[cfg_attr(test, derive(PartialEq))]
478#[xml(tag = "w:vAlign")]
479pub struct VAlign {
480    #[xml(attr = "w:val")]
481    pub val: VAlignType,
482}
483
484impl From<VAlignType> for VAlign {
485    fn from(al_type: VAlignType) -> Self {
486        Self { val: al_type }
487    }
488}
489
490#[derive(Debug, Default, Clone)]
491#[cfg_attr(test, derive(PartialEq))]
492pub enum VAlignType {
493    #[default]
494    Top, //	Align Top
495    Center, //	Align Center
496    Both,   //	Vertical Justification
497    Bottom, //	Align Bottom
498}
499
500__string_enum! {
501    VAlignType {
502        Top = "top",
503        Center = "center",
504        Both = "both",
505        Bottom = "bottom",
506    }
507}
508
509#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
510#[cfg_attr(test, derive(PartialEq))]
511#[xml(tag = "w:rtlGutter")]
512pub struct RtlGutter {
513    #[xml(attr = "w:val")]
514    pub val: Option<bool>,
515}
516
517#[derive(Debug, Clone)]
518#[cfg_attr(test, derive(PartialEq))]
519pub enum SectionType {
520    NextPage,
521    NextColumn,
522    Continuous,
523    EvenPage,
524    OddPage,
525}
526
527__string_enum! {
528    SectionType {
529        NextPage = "nextPage",
530        NextColumn = "nextColumn",
531        Continuous = "continuous",
532        EvenPage = "evenPage",
533        OddPage = "oddPage",
534    }
535}
536
537#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
538#[cfg_attr(test, derive(PartialEq))]
539#[xml(tag = "w:titlePg")]
540pub struct TitlePage {}
541
542#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
543#[cfg_attr(test, derive(PartialEq))]
544#[xml(tag = "w:footnotePr")]
545pub struct FootnoteProperty {
546    #[xml(child = "w:pos")]
547    pub position: Option<FootnotePosition>,
548    #[xml(child = "w:numFmt")]
549    pub num_fmt: Option<NumFmt>,
550    /// Footnote and Endnote Numbering Starting Value
551    #[xml(child = "w:numStart")]
552    pub num_start: Option<NumStart>,
553    /// Footnote and Endnote Numbering Restart Location
554    #[xml(child = "w:numRestart")]
555    pub num_restart: Option<NumRestart>,
556}
557
558#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
559#[cfg_attr(test, derive(PartialEq))]
560#[xml(tag = "w:endnotePr")]
561pub struct EndnoteProperty {
562    #[xml(child = "w:pos")]
563    pub position: Option<EndnotePosition>,
564    #[xml(child = "w:numFmt")]
565    pub num_fmt: Option<NumFmt>,
566    /// Footnote and Endnote Numbering Starting Value
567    #[xml(child = "w:numStart")]
568    pub num_start: Option<NumStart>,
569    /// Footnote and Endnote Numbering Restart Location
570    #[xml(child = "w:numRestart")]
571    pub num_restart: Option<NumRestart>,
572}
573
574#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
575#[cfg_attr(test, derive(PartialEq))]
576#[xml(tag = "w:footnotePr")]
577pub struct FootnoteProperty2 {
578    #[xml(child = "w:pos")]
579    pub position: Option<FootnotePosition>,
580    #[xml(child = "w:numFmt")]
581    pub num_fmt: Option<NumFmt>,
582    /// Footnote and Endnote Numbering Starting Value
583    #[xml(child = "w:numStart")]
584    pub num_start: Option<NumStart>,
585    /// Footnote and Endnote Numbering Restart Location
586    #[xml(child = "w:numRestart")]
587    pub num_restart: Option<NumRestart>,
588    #[xml(child = "w:footnote")]
589    pub footnote: Vec<Footnote>,
590}
591
592#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
593#[cfg_attr(test, derive(PartialEq))]
594#[xml(tag = "w:footnote")]
595pub struct Footnote {
596    #[xml(attr = "w:id")]
597    pub id: isize,
598}
599
600#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
601#[cfg_attr(test, derive(PartialEq))]
602#[xml(tag = "w:endnotePr")]
603pub struct EndnoteProperty2 {
604    #[xml(child = "w:pos")]
605    pub position: Option<EndnotePosition>,
606    #[xml(child = "w:numFmt")]
607    pub num_fmt: Option<NumFmt>,
608    /// Footnote and Endnote Numbering Starting Value
609    #[xml(child = "w:numStart")]
610    pub num_start: Option<NumStart>,
611    /// Footnote and Endnote Numbering Restart Location
612    #[xml(child = "w:numRestart")]
613    pub num_restart: Option<NumRestart>,
614    #[xml(child = "w:endnote")]
615    pub endnote: Vec<Endnote>,
616}
617
618#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
619#[cfg_attr(test, derive(PartialEq))]
620#[xml(tag = "w:endnote")]
621pub struct Endnote {
622    #[xml(attr = "w:id")]
623    pub id: isize,
624}
625
626#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
627#[cfg_attr(test, derive(PartialEq))]
628#[xml(tag = "w:numRestart")]
629pub struct NumRestart {
630    #[xml(attr = "w:val")]
631    pub val: NumRestartType,
632}
633
634#[derive(Debug, Default, Clone)]
635#[cfg_attr(test, derive(PartialEq))]
636pub enum NumRestartType {
637    #[default]
638    Continuous, //	Continue Numbering From Previous Section
639    EachSect, //	Restart Numbering For Each Section
640    EachPage, //	Restart Numbering On Each Page
641}
642
643__string_enum! {
644    NumRestartType {
645        Continuous = "continuous",
646        EachSect = "eachSect",
647        EachPage = "eachPage",
648    }
649}
650
651#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
652#[cfg_attr(test, derive(PartialEq))]
653#[xml(tag = "w:numStart")]
654pub struct NumStart {
655    #[xml(attr = "w:val")]
656    pub val: Option<isize>,
657}
658
659#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
660#[cfg_attr(test, derive(PartialEq))]
661#[xml(tag = "w:numFmt")]
662pub struct NumFmt {
663    #[xml(attr = "w:val")]
664    pub ty: NumFmtType,
665}
666
667#[derive(Debug, Default, Clone)]
668#[cfg_attr(test, derive(PartialEq))]
669pub enum NumFmtType {
670    #[default]
671    Decimal, //Decimal Numbers.
672    UpperRoman,                   //Uppercase Roman Numerals.
673    LowerRoman,                   //Lowercase Roman Numerals.
674    UpperLetter,                  //Uppercase Latin Alphabet.
675    LowerLetter,                  //Lowercase Latin Alphabet.
676    Ordinal,                      //Ordinal.
677    CardinalText,                 //Cardinal Text.
678    OrdinalText,                  //Ordinal Text.
679    Hex,                          //Hexadecimal Numbering.
680    Chicago,                      //Chicago Manual of Style.
681    IdeographDigital,             //Ideographs.
682    JapaneseCounting,             //Japanese Counting System.
683    Aiueo,                        //AIUEO Order Hiragana.
684    Iroha,                        //Iroha Ordered Katakana.
685    DecimalFullWidth,             //Double Byte Arabic Numerals.
686    DecimalHalfWidth,             //Single Byte Arabic Numerals.
687    JapaneseLegal,                //Japanese Legal Numbering.
688    JapaneseDigitalTenThousand,   //Japanese Digital Ten Thousand Counting System.
689    DecimalEnclosedCircle,        //Decimal Numbers Enclosed in a Circle.
690    DecimalFullWidth2,            //Double Byte Arabic Numerals Alternate.
691    AiueoFullWidth,               //Full-Width AIUEO Order Hiragana.
692    IrohaFullWidth,               //Full-Width Iroha Ordered Katakana.
693    DecimalZero,                  //Initial Zero Arabic Numerals.
694    Bullet,                       //Bullet.
695    Ganada,                       //Korean Ganada Numbering.
696    Chosung,                      //Korean Chosung Numbering.
697    DecimalEnclosedFullstop,      //Decimal Numbers Followed by a Period.
698    DecimalEnclosedParen,         //Decimal Numbers Enclosed in Parenthesis.
699    DecimalEnclosedCircleChinese, //Decimal Numbers Enclosed in a Circle.
700    IdeographEnclosedCircle,      //Ideographs Enclosed in a Circle.
701    IdeographTraditional,         //Traditional Ideograph Format.
702    IdeographZodiac,              //Zodiac Ideograph Format.
703    IdeographZodiacTraditional,   //Traditional Zodiac Ideograph Format.
704    TaiwaneseCounting,            //Taiwanese Counting System.
705    IdeographLegalTraditional,    //Traditional Legal Ideograph Format.
706    TaiwaneseCountingThousand,    //Taiwanese Counting Thousand System.
707    TaiwaneseDigital,             //Taiwanese Digital Counting System.
708    ChineseCounting,              //Chinese Counting System.
709    ChineseLegalSimplified,       //Chinese Legal Simplified Format.
710    ChineseCountingThousand,      //Chinese Counting Thousand System.
711    KoreanDigital,                //Korean Digital Counting System.
712    KoreanCounting,               //Korean Counting System.
713    KoreanLegal,                  //Korean Legal Numbering.
714    KoreanDigital2,               //Korean Digital Counting System Alternate.
715    VietnameseCounting,           //Vietnamese Numerals.
716    RussianLower,                 //Lowercase Russian Alphabet.
717    RussianUpper,                 //Uppercase Russian Alphabet.
718    None,                         //No Numbering.
719    NumberInDash,                 //Number With Dashes.
720    Hebrew1,                      //Hebrew Numerals.
721    Hebrew2,                      //Hebrew Alphabet.
722    ArabicAlpha,                  //Arabic Alphabet.
723    ArabicAbjad,                  //Arabic Abjad Numerals.
724    HindiVowels,                  //Hindi Vowels.
725    HindiConsonants,              //Hindi Consonants.
726    HindiNumbers,                 //Hindi Numbers.
727    HindiCounting,                //Hindi Counting System.
728    ThaiLetters,                  //Thai Letters.
729    ThaiNumbers,                  //Thai Numerals.
730    ThaiCounting,                 //Thai Counting System.
731}
732
733__string_enum! {
734    NumFmtType {
735        Decimal = "decimal",
736        UpperRoman = "upperRoman",
737        LowerRoman = "lowerRoman",
738        UpperLetter = "upperLetter",
739        LowerLetter = "lowerLetter",
740        Ordinal = "ordinal",
741        CardinalText = "cardinalText",
742        OrdinalText = "ordinalText",
743        Hex = "hex",
744        Chicago = "chicago",
745        IdeographDigital = "ideographDigital",
746        JapaneseCounting = "japaneseCounting",
747        Aiueo = "aiueo",
748        Iroha = "iroha",
749        DecimalFullWidth = "decimalFullWidth",
750        DecimalHalfWidth = "decimalHalfWidth",
751        JapaneseLegal = "japaneseLegal",
752        JapaneseDigitalTenThousand = "japaneseDigitalTenThousand",
753        DecimalEnclosedCircle = "decimalEnclosedCircle",
754        DecimalFullWidth2 = "decimalFullWidth2",
755        AiueoFullWidth = "aiueoFullWidth",
756        IrohaFullWidth = "irohaFullWidth",
757        DecimalZero = "decimalZero",
758        Bullet = "bullet",
759        Ganada = "ganada",
760        Chosung = "chosung",
761        DecimalEnclosedFullstop = "decimalEnclosedFullstop",
762        DecimalEnclosedParen = "decimalEnclosedParen",
763        DecimalEnclosedCircleChinese = "decimalEnclosedCircleChinese",
764        IdeographEnclosedCircle = "ideographEnclosedCircle",
765        IdeographTraditional = "ideographTraditional",
766        IdeographZodiac = "ideographZodiac",
767        IdeographZodiacTraditional = "ideographZodiacTraditional",
768        TaiwaneseCounting = "taiwaneseCounting",
769        IdeographLegalTraditional = "ideographLegalTraditional",
770        TaiwaneseCountingThousand = "taiwaneseCountingThousand",
771        TaiwaneseDigital = "taiwaneseDigital",
772        ChineseCounting = "chineseCounting",
773        ChineseLegalSimplified = "chineseLegalSimplified",
774        ChineseCountingThousand = "chineseCountingThousand",
775        KoreanDigital = "koreanDigital",
776        KoreanCounting = "koreanCounting",
777        KoreanLegal = "koreanLegal",
778        KoreanDigital2 = "koreanDigital2",
779        VietnameseCounting = "vietnameseCounting",
780        RussianLower = "russianLower",
781        RussianUpper = "russianUpper",
782        None = "none",
783        NumberInDash = "numberInDash",
784        Hebrew1 = "hebrew1",
785        Hebrew2 = "hebrew2",
786        ArabicAlpha = "arabicAlpha",
787        ArabicAbjad = "arabicAbjad",
788        HindiVowels = "hindiVowels",
789        HindiConsonants = "hindiConsonants",
790        HindiNumbers = "hindiNumbers",
791        HindiCounting = "hindiCounting",
792        ThaiLetters = "thaiLetters",
793        ThaiNumbers = "thaiNumbers",
794        ThaiCounting = "thaiCounting",
795    }
796}
797
798#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
799#[cfg_attr(test, derive(PartialEq))]
800#[xml(tag = "w:pos")]
801pub struct FootnotePosition {
802    #[xml(attr = "w:val")]
803    pub val: PositionType,
804}
805
806#[derive(Debug, Default, Clone)]
807#[cfg_attr(test, derive(PartialEq))]
808pub enum PositionType {
809    #[default]
810    PageBottom, //	Footnotes Positioned at Page Bottom
811    BeneathText, //	Footnotes Positioned Beneath Text
812    SectEnd,     //	Footnotes Positioned At End of Section
813    DocEnd,      //	Footnotes Positioned At End of Document
814}
815
816__string_enum! {
817    PositionType {
818        PageBottom = "pageBottom",
819        BeneathText = "beneathText",
820        SectEnd = "sectEnd",
821        DocEnd = "docEnd",
822    }
823}
824
825#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
826#[cfg_attr(test, derive(PartialEq))]
827#[xml(tag = "w:pos")]
828pub struct EndnotePosition {
829    #[xml(attr = "w:val")]
830    pub val: EndnotePositionType,
831}
832
833#[derive(Debug, Default, Clone)]
834#[cfg_attr(test, derive(PartialEq))]
835pub enum EndnotePositionType {
836    #[default]
837    SectEnd, //	Footnotes Positioned At End of Section
838    DocEnd, //	Footnotes Positioned At End of Document
839}
840
841__string_enum! {
842    EndnotePositionType {
843        SectEnd = "sectEnd",
844        DocEnd = "docEnd",
845    }
846}
847
848impl<'a> SectionProperty<'a> {
849    //     __setter!(style_id: Option<SectionStyleId<'a>>);
850    //     __setter!(justification: Option<Justification>);
851    //     __setter!(border: Option<Borders<'a>>);
852    //     __setter!(numbering: Option<NumberingProperty>);
853    //     __setter!(spacing: Option<Spacing>);
854    //     __setter!(indent: Option<Indent>);
855    fn first_page_has_diffrent_header_and_footer(&mut self, val: bool) -> &mut Self {
856        if val {
857            self.title_page = Some(TitlePage::default());
858        } else {
859            self.title_page = None;
860        }
861        self
862    }
863}
864
865// #[derive(Debug, XmlRead, XmlWrite, Clone)]
866// #[cfg_attr(test, derive(PartialEq))]
867// #[xml(tag = "w:pStyle")]
868// pub struct SectionStyleId<'a> {
869//     #[xml(attr = "w:val")]
870//     pub value: Cow<'a, str>,
871// }
872
873// impl<'a, T: Into<Cow<'a, str>>> From<T> for SectionStyleId<'a> {
874//     fn from(val: T) -> Self {
875//         SectionStyleId { value: val.into() }
876//     }
877// }
878
879// #[cfg(test)]
880// use crate::formatting::JustificationVal;
881
882// __xml_test_suites!(
883//     SectionProperty,
884//     SectionProperty::default(),
885//     r#"<w:pPr/>"#,
886//     SectionProperty::default().style_id("id"),
887//     r#"<w:pPr><w:pStyle w:val="id"/></w:pPr>"#,
888//     SectionProperty::default().justification(JustificationVal::Start),
889//     r#"<w:pPr><w:jc w:val="start"/></w:pPr>"#,
890//     SectionProperty::default().border(Borders::default()),
891//     r#"<w:pPr><w:pBdr/></w:pPr>"#,
892//     SectionProperty::default().numbering(NumberingProperty::default()),
893//     r#"<w:pPr><w:numPr><w:numId w:val="0"/><w:ilvl w:val="0"/></w:numPr></w:pPr>"#,
894// );