docx_reader/documents/elements/
paragraph_style.rs

1use serde::{Serialize, Serializer};
2
3#[derive(Debug, Clone, PartialEq)]
4pub struct ParagraphStyle {
5	pub val: String,
6}
7
8impl Default for ParagraphStyle {
9	fn default() -> Self {
10		ParagraphStyle {
11			val: "Normal".to_owned(),
12		}
13	}
14}
15
16// 17.9.23
17// pStyle (Paragraph Style's Associated Numbering Level)
18// This element specifies the name of a paragraph style which shall automatically this numbering level when
19// applied to the contents of the document. When a paragraph style is defined to include a numbering definition,
20// any numbering level defined by the numPr element (ยง17.3.1.19) shall be ignored, and instead this element shall
21// specify the numbering level associated with that paragraph style.
22impl ParagraphStyle {
23	pub fn new(val: Option<impl Into<String>>) -> ParagraphStyle {
24		if let Some(v) = val {
25			ParagraphStyle { val: v.into() }
26		} else {
27			Default::default()
28		}
29	}
30}
31
32impl Serialize for ParagraphStyle {
33	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
34	where
35		S: Serializer,
36	{
37		serializer.serialize_str(&self.val)
38	}
39}