2019-12-11 07:12:22 +02:00
|
|
|
use super::*;
|
2021-04-14 07:47:46 +03:00
|
|
|
use docx_rs::WidthType;
|
2019-12-11 07:12:22 +02:00
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
#[derive(Debug)]
|
2020-01-24 12:44:43 +02:00
|
|
|
pub struct Table(docx_rs::Table);
|
2019-12-11 07:12:22 +02:00
|
|
|
|
|
|
|
#[wasm_bindgen(js_name = createTable)]
|
|
|
|
pub fn create_table() -> Table {
|
2020-01-24 12:44:43 +02:00
|
|
|
Table(docx_rs::Table::new(vec![]))
|
2019-12-11 07:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Table {
|
2020-01-24 12:44:43 +02:00
|
|
|
pub fn take(self) -> docx_rs::Table {
|
2019-12-11 07:12:22 +02:00
|
|
|
self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
impl Table {
|
|
|
|
pub fn add_row(mut self, row: TableRow) -> Table {
|
2022-01-24 15:48:01 +02:00
|
|
|
self.0.rows.push(docx_rs::TableChild::TableRow(row.take()));
|
2019-12-11 07:12:22 +02:00
|
|
|
self
|
|
|
|
}
|
2019-12-12 11:10:57 +02:00
|
|
|
|
|
|
|
pub fn set_grid(mut self, grid: Vec<usize>) -> Table {
|
|
|
|
self.0.grid = grid;
|
|
|
|
self
|
|
|
|
}
|
2019-12-13 05:02:49 +02:00
|
|
|
|
2022-09-09 05:10:05 +03:00
|
|
|
pub fn style(mut self, style_id: &str) -> Table {
|
|
|
|
self.0.property = self.0.property.style(style_id);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-03-10 05:02:51 +02:00
|
|
|
pub fn indent(mut self, v: i32) -> Table {
|
2019-12-13 05:02:49 +02:00
|
|
|
self.0 = self.0.indent(v);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2020-01-24 12:44:43 +02:00
|
|
|
pub fn align(mut self, v: docx_rs::TableAlignmentType) -> Table {
|
2019-12-13 05:02:49 +02:00
|
|
|
self.0 = self.0.align(v);
|
|
|
|
self
|
|
|
|
}
|
2019-12-14 17:39:01 +02:00
|
|
|
|
|
|
|
pub fn width(mut self, w: usize) -> Table {
|
2022-03-25 06:20:09 +02:00
|
|
|
self.0 = self.0.width(w, docx_rs::WidthType::Dxa);
|
2019-12-14 17:39:01 +02:00
|
|
|
self
|
|
|
|
}
|
2020-09-24 06:18:04 +03:00
|
|
|
|
2021-03-23 05:01:09 +02:00
|
|
|
pub fn layout(mut self, t: docx_rs::TableLayoutType) -> Table {
|
|
|
|
self.0 = self.0.layout(t);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_cell_margins(
|
|
|
|
mut self,
|
|
|
|
top: usize,
|
|
|
|
right: usize,
|
|
|
|
bottom: usize,
|
|
|
|
left: usize,
|
|
|
|
) -> Table {
|
2020-09-24 06:18:04 +03:00
|
|
|
let m = docx_rs::TableCellMargins::new().margin(top, right, bottom, left);
|
|
|
|
self.0.property = self.0.property.set_margins(m);
|
|
|
|
self
|
|
|
|
}
|
2021-04-14 07:47:46 +03:00
|
|
|
|
|
|
|
pub fn cell_margin_top(mut self, v: usize, t: WidthType) -> Table {
|
|
|
|
self.0.property = self.0.property.cell_margin_top(v, t);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cell_margin_right(mut self, v: usize, t: WidthType) -> Table {
|
|
|
|
self.0.property = self.0.property.cell_margin_right(v, t);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cell_margin_bottom(mut self, v: usize, t: WidthType) -> Table {
|
|
|
|
self.0.property = self.0.property.cell_margin_bottom(v, t);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cell_margin_left(mut self, v: usize, t: WidthType) -> Table {
|
|
|
|
self.0.property = self.0.property.cell_margin_left(v, t);
|
|
|
|
self
|
|
|
|
}
|
2019-12-11 07:12:22 +02:00
|
|
|
}
|