docx_reader/documents/
settings.rsuse super::*;
use crate::types::CharacterSpacingValues;
use serde::Serialize;
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Settings {
default_tab_stop: DefaultTabStop,
zoom: Zoom,
doc_id: Option<DocId>,
doc_vars: Vec<DocVar>,
even_and_odd_headers: bool,
adjust_line_height_in_table: bool,
#[serde(skip_serializing_if = "Option::is_none")]
character_spacing_control: Option<CharacterSpacingValues>,
}
impl Settings {
pub fn new() -> Settings {
Default::default()
}
pub fn doc_id(mut self, id: impl Into<String>) -> Self {
self.doc_id = Some(DocId::new(id.into()));
self
}
pub fn default_tab_stop(mut self, tab_stop: usize) -> Self {
self.default_tab_stop = DefaultTabStop::new(tab_stop);
self
}
pub fn add_doc_var(mut self, name: impl Into<String>, val: impl Into<String>) -> Self {
self.doc_vars.push(DocVar::new(name, val));
self
}
pub fn even_and_odd_headers(mut self) -> Self {
self.even_and_odd_headers = true;
self
}
pub fn adjust_line_height_in_table(mut self) -> Self {
self.adjust_line_height_in_table = true;
self
}
pub fn character_spacing_control(mut self, val: CharacterSpacingValues) -> Self {
self.character_spacing_control = Some(val);
self
}
}
impl Default for Settings {
fn default() -> Self {
Self {
default_tab_stop: DefaultTabStop::new(840),
zoom: Zoom::new(100),
doc_id: None,
doc_vars: vec![],
even_and_odd_headers: false,
adjust_line_height_in_table: false,
character_spacing_control: None,
}
}
}