diff --git a/docx-core/src/documents/document.rs b/docx-core/src/documents/document.rs index 43302bb..95660f0 100644 --- a/docx-core/src/documents/document.rs +++ b/docx-core/src/documents/document.rs @@ -228,6 +228,11 @@ impl Document { self.section_property.text_direction = direction; self } + + pub fn page_num_type(mut self, p: PageNumType) -> Self { + self.section_property = self.section_property.page_num_type(p); + self + } } impl BuildXML for DocumentChild { diff --git a/docx-core/src/documents/elements/mod.rs b/docx-core/src/documents/elements/mod.rs index e40db51..f5b079e 100644 --- a/docx-core/src/documents/elements/mod.rs +++ b/docx-core/src/documents/elements/mod.rs @@ -61,6 +61,7 @@ mod numbering_id; mod numbering_property; mod outline_lvl; mod page_margin; +mod page_num_type; mod page_size; mod paragraph; mod paragraph_borders; @@ -185,6 +186,7 @@ pub use numbering_id::*; pub use numbering_property::*; pub use outline_lvl::*; pub use page_margin::*; +pub use page_num_type::*; pub use page_size::*; pub use paragraph::*; pub use paragraph_borders::*; diff --git a/docx-core/src/documents/elements/page_num_type.rs b/docx-core/src/documents/elements/page_num_type.rs new file mode 100644 index 0000000..23d52a2 --- /dev/null +++ b/docx-core/src/documents/elements/page_num_type.rs @@ -0,0 +1,42 @@ +use crate::documents::BuildXML; +use crate::xml_builder::*; +use serde::Serialize; + +#[derive(Debug, Clone, PartialEq, Serialize, Default)] +#[cfg_attr(feature = "wasm", derive(ts_rs::TS))] +#[cfg_attr(feature = "wasm", ts(export))] +#[serde(rename_all = "camelCase")] +pub struct PageNumType { + #[serde(skip_serializing_if = "Option::is_none")] + pub start: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub chap_style: Option, +} + +impl PageNumType { + pub fn new() -> Self { + Default::default() + } + + pub fn start(self, s: u32) -> Self { + Self { + start: Some(s), + ..self + } + } + + pub fn chap_style(self, s: impl Into) -> Self { + Self { + chap_style: Some(s.into()), + ..self + } + } +} + +impl BuildXML for PageNumType { + fn build(&self) -> Vec { + XMLBuilder::new() + .page_num_type(self.start, self.chap_style.clone()) + .build() + } +} diff --git a/docx-core/src/documents/elements/section_property.rs b/docx-core/src/documents/elements/section_property.rs index 8d70b8e..f51b325 100644 --- a/docx-core/src/documents/elements/section_property.rs +++ b/docx-core/src/documents/elements/section_property.rs @@ -43,6 +43,8 @@ pub struct SectionProperty { pub even_footer: Option