2019-12-11 07:12:22 +02:00
|
|
|
use super::*;
|
|
|
|
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 {
|
|
|
|
self.0.rows.push(row.take());
|
|
|
|
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
|
|
|
|
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 {
|
2020-02-11 10:01:39 +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
|
|
|
|
|
|
|
pub fn set_cell_margins(mut self, top: usize, right: usize, bottom: usize, left: usize) -> Table {
|
|
|
|
let m = docx_rs::TableCellMargins::new().margin(top, right, bottom, left);
|
|
|
|
self.0.property = self.0.property.set_margins(m);
|
|
|
|
self
|
|
|
|
}
|
2019-12-11 07:12:22 +02:00
|
|
|
}
|