parent
1492cb8444
commit
b7b1a8a846
|
@ -17,8 +17,8 @@ impl TableRow {
|
||||||
let property = TableRowProperty::new();
|
let property = TableRowProperty::new();
|
||||||
let has_numbering = cells.iter().any(|c| c.has_numbering);
|
let has_numbering = cells.iter().any(|c| c.has_numbering);
|
||||||
Self {
|
Self {
|
||||||
property,
|
|
||||||
cells,
|
cells,
|
||||||
|
property,
|
||||||
has_numbering,
|
has_numbering,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,16 @@ impl TableRow {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn grid_before(mut self, grid_before: u32) -> TableRow {
|
||||||
|
self.property = self.property.grid_before(grid_before);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn width_before(mut self, w: f32) -> TableRow {
|
||||||
|
self.property = self.property.width_before(w);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn row_height(mut self, h: f32) -> TableRow {
|
pub fn row_height(mut self, h: f32) -> TableRow {
|
||||||
self.property = self.property.row_height(h);
|
self.property = self.property.row_height(h);
|
||||||
self
|
self
|
||||||
|
@ -76,7 +86,7 @@ mod tests {
|
||||||
let r = TableRow::new(vec![TableCell::new()]);
|
let r = TableRow::new(vec![TableCell::new()]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
serde_json::to_string(&r).unwrap(),
|
serde_json::to_string(&r).unwrap(),
|
||||||
r#"{"cells":[{"children":[],"property":{"width":null,"borders":null,"gridSpan":null,"verticalMerge":null,"verticalAlign":null,"textDirection":null,"shading":null},"hasNumbering":false}],"hasNumbering":false,"property":{"gridAfter":null,"widthAfter":null,"rowHeight":null,"heightRule":null}}"#
|
r#"{"cells":[{"children":[],"property":{"width":null,"borders":null,"gridSpan":null,"verticalMerge":null,"verticalAlign":null,"textDirection":null,"shading":null},"hasNumbering":false}],"hasNumbering":false,"property":{"gridAfter":null,"widthAfter":null,"gridBefore":null,"widthBefore":null,"rowHeight":null,"heightRule":null}}"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ use crate::{documents::BuildXML, HeightRule};
|
||||||
pub struct TableRowProperty {
|
pub struct TableRowProperty {
|
||||||
grid_after: Option<u32>,
|
grid_after: Option<u32>,
|
||||||
width_after: Option<f32>,
|
width_after: Option<f32>,
|
||||||
|
grid_before: Option<u32>,
|
||||||
|
width_before: Option<f32>,
|
||||||
row_height: Option<f32>,
|
row_height: Option<f32>,
|
||||||
height_rule: Option<HeightRule>,
|
height_rule: Option<HeightRule>,
|
||||||
}
|
}
|
||||||
|
@ -27,6 +29,16 @@ impl TableRowProperty {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn grid_before(mut self, before: u32) -> Self {
|
||||||
|
self.grid_before = Some(before);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn width_before(mut self, w: f32) -> Self {
|
||||||
|
self.width_before = Some(w);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn row_height(mut self, h: f32) -> Self {
|
pub fn row_height(mut self, h: f32) -> Self {
|
||||||
self.row_height = Some(h);
|
self.row_height = Some(h);
|
||||||
self
|
self
|
||||||
|
@ -43,6 +55,8 @@ impl Default for TableRowProperty {
|
||||||
TableRowProperty {
|
TableRowProperty {
|
||||||
grid_after: None,
|
grid_after: None,
|
||||||
width_after: None,
|
width_after: None,
|
||||||
|
grid_before: None,
|
||||||
|
width_before: None,
|
||||||
row_height: None,
|
row_height: None,
|
||||||
height_rule: None,
|
height_rule: None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ impl ElementReader for TableRow {
|
||||||
let mut cells = vec![];
|
let mut cells = vec![];
|
||||||
let mut grid_after = None;
|
let mut grid_after = None;
|
||||||
let mut width_after = None;
|
let mut width_after = None;
|
||||||
|
let mut grid_before = None;
|
||||||
|
let mut width_before = None;
|
||||||
let mut row_height = None;
|
let mut row_height = None;
|
||||||
let mut height_rule = Some(HeightRule::AtLeast);
|
let mut height_rule = Some(HeightRule::AtLeast);
|
||||||
loop {
|
loop {
|
||||||
|
@ -41,6 +43,16 @@ impl ElementReader for TableRow {
|
||||||
width_after = Some(v.0 as f32);
|
width_after = Some(v.0 as f32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
XMLElement::GridBefore => {
|
||||||
|
if let Some(v) = read_val(&attributes) {
|
||||||
|
grid_before = Some(u32::from_str(&v)?);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XMLElement::WidthBefore => {
|
||||||
|
if let Ok(v) = read_width(&attributes) {
|
||||||
|
width_before = Some(v.0 as f32);
|
||||||
|
}
|
||||||
|
}
|
||||||
XMLElement::HeightRule => {
|
XMLElement::HeightRule => {
|
||||||
if let Some(v) = read_val(&attributes) {
|
if let Some(v) = read_val(&attributes) {
|
||||||
if let Ok(r) = HeightRule::from_str(&v) {
|
if let Ok(r) = HeightRule::from_str(&v) {
|
||||||
|
@ -67,6 +79,10 @@ impl ElementReader for TableRow {
|
||||||
row = row.grid_after(grid_after);
|
row = row.grid_after(grid_after);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(grid_before) = grid_before {
|
||||||
|
row = row.grid_before(grid_before);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(row_height) = row_height {
|
if let Some(row_height) = row_height {
|
||||||
row = row.row_height(row_height);
|
row = row.row_height(row_height);
|
||||||
}
|
}
|
||||||
|
@ -75,6 +91,10 @@ impl ElementReader for TableRow {
|
||||||
row = row.width_after(width_after);
|
row = row.width_after(width_after);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(width_before) = width_before {
|
||||||
|
row = row.width_before(width_before);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(height_rule) = height_rule {
|
if let Some(height_rule) = height_rule {
|
||||||
row = row.height_rule(height_rule);
|
row = row.height_rule(height_rule);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,8 @@ pub enum XMLElement {
|
||||||
GridCol,
|
GridCol,
|
||||||
GridAfter,
|
GridAfter,
|
||||||
WidthAfter,
|
WidthAfter,
|
||||||
|
GridBefore,
|
||||||
|
WidthBefore,
|
||||||
Style,
|
Style,
|
||||||
Next,
|
Next,
|
||||||
VertAlign,
|
VertAlign,
|
||||||
|
@ -247,6 +249,8 @@ impl FromStr for XMLElement {
|
||||||
"gridSpan" => Ok(XMLElement::TableGridSpan),
|
"gridSpan" => Ok(XMLElement::TableGridSpan),
|
||||||
"gridAfter" => Ok(XMLElement::GridAfter),
|
"gridAfter" => Ok(XMLElement::GridAfter),
|
||||||
"wAfter" => Ok(XMLElement::WidthAfter),
|
"wAfter" => Ok(XMLElement::WidthAfter),
|
||||||
|
"gridBefore" => Ok(XMLElement::GridBefore),
|
||||||
|
"wBefore" => Ok(XMLElement::WidthBefore),
|
||||||
"textDirection" => Ok(XMLElement::TextDirection),
|
"textDirection" => Ok(XMLElement::TextDirection),
|
||||||
"tblW" => Ok(XMLElement::TableWidth),
|
"tblW" => Ok(XMLElement::TableWidth),
|
||||||
"tblInd" => Ok(XMLElement::TableIndent),
|
"tblInd" => Ok(XMLElement::TableIndent),
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -28,9 +28,11 @@ export type TableCellPropertyJSON = {
|
||||||
|
|
||||||
export type TableRowPropertyJSON = {
|
export type TableRowPropertyJSON = {
|
||||||
gridAfter: number | null;
|
gridAfter: number | null;
|
||||||
|
gridBefore: number | null;
|
||||||
rowHeight: number | null;
|
rowHeight: number | null;
|
||||||
heightRule: HeightRule | null;
|
heightRule: HeightRule | null;
|
||||||
widthAfter: number | null;
|
widthAfter: number | null;
|
||||||
|
widthBefore: number | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TableCellJSON = {
|
export type TableCellJSON = {
|
||||||
|
|
|
@ -2205,9 +2205,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": null,
|
"gridAfter": null,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": 970,
|
"rowHeight": 970,
|
||||||
"widthAfter": null,
|
"widthAfter": null,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
@ -2394,9 +2396,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": 1,
|
"gridAfter": 1,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": 55,
|
"rowHeight": 55,
|
||||||
"widthAfter": 1065,
|
"widthAfter": 1065,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
@ -2583,9 +2587,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": 1,
|
"gridAfter": 1,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": 675,
|
"rowHeight": 675,
|
||||||
"widthAfter": 1065,
|
"widthAfter": 1065,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
@ -2772,9 +2778,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": 2,
|
"gridAfter": 2,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": 397,
|
"rowHeight": 397,
|
||||||
"widthAfter": 3717,
|
"widthAfter": 3717,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
@ -2961,9 +2969,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": 2,
|
"gridAfter": 2,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": 397,
|
"rowHeight": 397,
|
||||||
"widthAfter": 3717,
|
"widthAfter": 3717,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
@ -3239,9 +3249,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": 2,
|
"gridAfter": 2,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": 397,
|
"rowHeight": 397,
|
||||||
"widthAfter": 3717,
|
"widthAfter": 3717,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
@ -3517,9 +3529,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": 2,
|
"gridAfter": 2,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": 397,
|
"rowHeight": 397,
|
||||||
"widthAfter": 3717,
|
"widthAfter": 3717,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
@ -3783,9 +3797,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": 2,
|
"gridAfter": 2,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": 397,
|
"rowHeight": 397,
|
||||||
"widthAfter": 3717,
|
"widthAfter": 3717,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
@ -4061,9 +4077,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": 2,
|
"gridAfter": 2,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": 397,
|
"rowHeight": 397,
|
||||||
"widthAfter": 3717,
|
"widthAfter": 3717,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -12096,9 +12114,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": null,
|
"gridAfter": null,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": null,
|
"rowHeight": null,
|
||||||
"widthAfter": null,
|
"widthAfter": null,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
@ -12315,9 +12335,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": null,
|
"gridAfter": null,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": null,
|
"rowHeight": null,
|
||||||
"widthAfter": null,
|
"widthAfter": null,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
@ -12534,9 +12556,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": null,
|
"gridAfter": null,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": null,
|
"rowHeight": null,
|
||||||
"widthAfter": null,
|
"widthAfter": null,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -13530,9 +13554,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": null,
|
"gridAfter": null,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": 730,
|
"rowHeight": 730,
|
||||||
"widthAfter": null,
|
"widthAfter": null,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
|
@ -13733,9 +13759,11 @@ Object {
|
||||||
"hasNumbering": false,
|
"hasNumbering": false,
|
||||||
"property": Object {
|
"property": Object {
|
||||||
"gridAfter": null,
|
"gridAfter": null,
|
||||||
|
"gridBefore": null,
|
||||||
"heightRule": "atLeast",
|
"heightRule": "atLeast",
|
||||||
"rowHeight": null,
|
"rowHeight": null,
|
||||||
"widthAfter": null,
|
"widthAfter": null,
|
||||||
|
"widthBefore": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue