docx_reader/documents/elements/
table_cell_property.rsuse serde::Serialize;
use super::*;
use crate::types::*;
#[derive(Serialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct TableCellProperty {
width: Option<TableCellWidth>,
borders: Option<TableCellBorders>,
grid_span: Option<GridSpan>,
vertical_merge: Option<VMerge>,
vertical_align: Option<VAlign>,
text_direction: Option<TextDirection>,
shading: Option<Shading>,
}
impl TableCellProperty {
pub fn new() -> TableCellProperty {
Default::default()
}
pub fn width(mut self, v: usize, t: WidthType) -> TableCellProperty {
self.width = Some(TableCellWidth::new(v, t));
self
}
pub fn vertical_merge(mut self, t: VMergeType) -> TableCellProperty {
self.vertical_merge = Some(VMerge::new(t));
self
}
pub fn vertical_align(mut self, t: VAlignType) -> TableCellProperty {
self.vertical_align = Some(VAlign::new(t));
self
}
pub fn text_direction(mut self, t: TextDirectionType) -> Self {
self.text_direction = Some(TextDirection::new(t));
self
}
pub fn grid_span(mut self, v: usize) -> TableCellProperty {
self.grid_span = Some(GridSpan::new(v));
self
}
pub fn shading(mut self, s: Shading) -> Self {
self.shading = Some(s);
self
}
pub fn set_borders(mut self, borders: TableCellBorders) -> Self {
self.borders = Some(borders);
self
}
pub fn set_border(mut self, border: TableCellBorder) -> Self {
self.borders = Some(self.borders.unwrap_or_default().set(border));
self
}
pub fn clear_border(mut self, position: TableCellBorderPosition) -> Self {
self.borders = Some(self.borders.unwrap_or_default().clear(position));
self
}
pub fn clear_all_border(mut self) -> Self {
self.borders = Some(self.borders.unwrap_or_default().clear_all());
self
}
}
impl Default for TableCellProperty {
fn default() -> Self {
TableCellProperty {
width: None,
borders: None,
grid_span: None,
vertical_merge: None,
vertical_align: None,
text_direction: None,
shading: None,
}
}
}