docx_reader/documents/elements/
level.rsuse crate::documents::*;
use crate::types::*;
use serde::Serialize;
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Level {
pub level: usize,
pub start: Start,
pub format: NumberFormat,
pub text: LevelText,
pub jc: LevelJc,
pub paragraph_property: ParagraphProperty,
pub run_property: RunProperty,
pub suffix: LevelSuffixType,
pub pstyle: Option<String>,
pub level_restart: Option<LevelRestart>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_lgl: Option<IsLgl>,
}
impl Level {
pub fn new(
level: usize,
start: Start,
format: NumberFormat,
text: LevelText,
jc: LevelJc,
) -> Level {
Self {
level,
start,
format,
text,
jc,
paragraph_property: ParagraphProperty::new(),
run_property: RunProperty::new(),
suffix: LevelSuffixType::Tab,
pstyle: None,
level_restart: None,
is_lgl: None,
}
}
pub fn indent(
mut self,
left: Option<i32>,
special_indent: Option<SpecialIndentType>,
end: Option<i32>,
start_chars: Option<i32>,
) -> Self {
self.paragraph_property =
self.paragraph_property
.indent(left, special_indent, end, start_chars);
self
}
pub fn paragraph_style(mut self, style_id: impl Into<String>) -> Self {
self.pstyle = Some(style_id.into());
self
}
pub fn suffix(mut self, s: LevelSuffixType) -> Self {
self.suffix = s;
self
}
pub fn size(mut self, size: usize) -> Self {
self.run_property = self.run_property.size(size);
self
}
pub fn spacing(mut self, v: i32) -> Self {
self.run_property = self.run_property.spacing(v);
self
}
pub fn color(mut self, color: impl Into<String>) -> Self {
self.run_property = self.run_property.color(color);
self
}
pub fn highlight(mut self, color: impl Into<String>) -> Self {
self.run_property = self.run_property.highlight(color);
self
}
pub fn bold(mut self) -> Self {
self.run_property = self.run_property.bold();
self
}
pub fn italic(mut self) -> Self {
self.run_property = self.run_property.italic();
self
}
pub fn underline(mut self, line_type: impl Into<String>) -> Self {
self.run_property = self.run_property.underline(line_type);
self
}
pub fn vanish(mut self) -> Self {
self.run_property = self.run_property.vanish();
self
}
pub fn fonts(mut self, f: RunFonts) -> Self {
self.run_property = self.run_property.fonts(f);
self
}
pub fn level_restart(mut self, v: u32) -> Self {
self.level_restart = Some(LevelRestart::new(v));
self
}
pub fn is_lgl(mut self) -> Self {
self.is_lgl = Some(IsLgl::new());
self
}
}