parent
6e69f3f37c
commit
f06f780e3c
|
@ -1,7 +1,7 @@
|
||||||
use serde::ser::{SerializeStruct, Serializer};
|
use serde::ser::{SerializeStruct, Serializer};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use super::{TableCell, TableRowProperty};
|
use super::{TableCell, TableRowProperty, Delete};
|
||||||
use crate::xml_builder::*;
|
use crate::xml_builder::*;
|
||||||
use crate::{documents::BuildXML, HeightRule};
|
use crate::{documents::BuildXML, HeightRule};
|
||||||
|
|
||||||
|
@ -67,6 +67,11 @@ impl TableRow {
|
||||||
self.property = self.property.height_rule(r);
|
self.property = self.property.height_rule(r);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn delete(mut self, d: Delete) -> TableRow {
|
||||||
|
self.property = self.property.delete(d);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BuildXML for TableRow {
|
impl BuildXML for TableRow {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
use crate::xml_builder::*;
|
use crate::xml_builder::*;
|
||||||
use crate::{documents::BuildXML, HeightRule};
|
use crate::{documents::BuildXML, HeightRule};
|
||||||
|
|
||||||
|
@ -12,6 +13,8 @@ pub struct TableRowProperty {
|
||||||
width_before: Option<f32>,
|
width_before: Option<f32>,
|
||||||
row_height: Option<f32>,
|
row_height: Option<f32>,
|
||||||
height_rule: Option<HeightRule>,
|
height_rule: Option<HeightRule>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub del: Option<Delete>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableRowProperty {
|
impl TableRowProperty {
|
||||||
|
@ -48,6 +51,11 @@ impl TableRowProperty {
|
||||||
self.height_rule = Some(r);
|
self.height_rule = Some(r);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn delete(mut self, d: Delete) -> Self {
|
||||||
|
self.del = Some(d);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TableRowProperty {
|
impl Default for TableRowProperty {
|
||||||
|
@ -59,13 +67,16 @@ impl Default for TableRowProperty {
|
||||||
width_before: None,
|
width_before: None,
|
||||||
row_height: None,
|
row_height: None,
|
||||||
height_rule: None,
|
height_rule: None,
|
||||||
|
del: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BuildXML for TableRowProperty {
|
impl BuildXML for TableRowProperty {
|
||||||
fn build(&self) -> Vec<u8> {
|
fn build(&self) -> Vec<u8> {
|
||||||
let mut b = XMLBuilder::new().open_table_row_property();
|
let mut b = XMLBuilder::new()
|
||||||
|
.open_table_row_property()
|
||||||
|
.add_optional_child(&self.del);
|
||||||
if let Some(h) = self.row_height {
|
if let Some(h) = self.row_height {
|
||||||
b = b.table_row_height(
|
b = b.table_row_height(
|
||||||
&format!("{}", h),
|
&format!("{}", h),
|
||||||
|
|
|
@ -17,6 +17,7 @@ impl ElementReader for TableRow {
|
||||||
let mut grid_before = None;
|
let mut grid_before = None;
|
||||||
let mut width_before = None;
|
let mut width_before = None;
|
||||||
let mut row_height = None;
|
let mut row_height = None;
|
||||||
|
let mut del = None;
|
||||||
let mut height_rule = Some(HeightRule::AtLeast);
|
let mut height_rule = Some(HeightRule::AtLeast);
|
||||||
loop {
|
loop {
|
||||||
let e = r.next();
|
let e = r.next();
|
||||||
|
@ -68,6 +69,11 @@ impl ElementReader for TableRow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
XMLElement::Delete => {
|
||||||
|
if let Ok(d) = Delete::read(r, &attributes) {
|
||||||
|
del = Some(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,6 +105,10 @@ impl ElementReader for TableRow {
|
||||||
row = row.height_rule(height_rule);
|
row = row.height_rule(height_rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(del) = del {
|
||||||
|
row = row.delete(del);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(row);
|
return Ok(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -654,6 +654,10 @@ export class Docx {
|
||||||
row = row.row_height(r.height);
|
row = row.row_height(r.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r.del) {
|
||||||
|
row = row.delete(r.del.author, r.del.date);
|
||||||
|
}
|
||||||
|
|
||||||
if (r.hRule) {
|
if (r.hRule) {
|
||||||
switch (r.hRule) {
|
switch (r.hRule) {
|
||||||
case "auto": {
|
case "auto": {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { HeightRule } from "../table-row";
|
||||||
import { TextDirectionType } from "../table-cell";
|
import { TextDirectionType } from "../table-cell";
|
||||||
import { ShadingJSON } from "./shading";
|
import { ShadingJSON } from "./shading";
|
||||||
import { TableLayoutType } from "../table";
|
import { TableLayoutType } from "../table";
|
||||||
|
import { DeleteJSON } from "..";
|
||||||
|
|
||||||
export type TableCellChildJSON = ParagraphJSON;
|
export type TableCellChildJSON = ParagraphJSON;
|
||||||
|
|
||||||
|
@ -33,6 +34,7 @@ export type TableRowPropertyJSON = {
|
||||||
heightRule: HeightRule | null;
|
heightRule: HeightRule | null;
|
||||||
widthAfter: number | null;
|
widthAfter: number | null;
|
||||||
widthBefore: number | null;
|
widthBefore: number | null;
|
||||||
|
del?: DeleteJSON["data"];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TableCellJSON = {
|
export type TableCellJSON = {
|
||||||
|
|
|
@ -7,6 +7,7 @@ export class TableRow {
|
||||||
hasNumberings = false;
|
hasNumberings = false;
|
||||||
height: number | null = null;
|
height: number | null = null;
|
||||||
hRule: HeightRule = "atLeast";
|
hRule: HeightRule = "atLeast";
|
||||||
|
del: { author: string; date: string } | null = null;
|
||||||
|
|
||||||
addCell(cell: TableCell) {
|
addCell(cell: TableCell) {
|
||||||
if (cell.hasNumberings) {
|
if (cell.hasNumberings) {
|
||||||
|
@ -25,4 +26,9 @@ export class TableRow {
|
||||||
this.hRule = r;
|
this.hRule = r;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete(author: string, date: string) {
|
||||||
|
this.del = { author, date };
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,9 @@ impl TableRow {
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
impl TableRow {
|
impl TableRow {
|
||||||
pub fn add_cell(mut self, cell: TableCell) -> TableRow {
|
pub fn add_cell(mut self, cell: TableCell) -> TableRow {
|
||||||
self.0.cells.push(docx_rs::TableRowChild::TableCell(cell.take()));
|
self.0
|
||||||
|
.cells
|
||||||
|
.push(docx_rs::TableRowChild::TableCell(cell.take()));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,4 +34,11 @@ impl TableRow {
|
||||||
self.0 = self.0.height_rule(r);
|
self.0 = self.0.height_rule(r);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn delete(mut self, author: &str, date: &str) -> Self {
|
||||||
|
self.0 = self
|
||||||
|
.0
|
||||||
|
.delete(docx_rs::Delete::new().author(author).date(date));
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue