Fix table row height (#558)

* fix: row height behavior

* rc30
main
bokuweb 2022-11-01 14:57:27 +09:00 committed by GitHub
parent 5f5bb0302f
commit 698939d728
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 21 additions and 62 deletions

View File

@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## docx-wasm@0.0.276-rc29, rc28 (31. Oct, 2022)
## docx-wasm@0.0.276-rc30 (1. Nov, 2022)
- Use `None` if heightRule not found instead of `auto`
## docx-wasm@0.0.276-rc29 (31. Oct, 2022)
- escape hyperlink url(export)

View File

@ -4,7 +4,7 @@ use std::fs::File;
use std::io::{Read, Write};
pub fn main() {
let mut file = File::open("./hello.docx").unwrap();
let mut file = File::open("./rh.docx").unwrap();
let mut buf = vec![];
file.read_to_end(&mut buf).unwrap();

View File

@ -127,7 +127,7 @@ mod tests {
let r = TableRow::new(vec![TableCell::new()]);
assert_eq!(
serde_json::to_string(&r).unwrap(),
r#"{"cells":[{"type":"tableCell","data":{"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}}"#
r#"{"cells":[{"type":"tableCell","data":{"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}}"#
);
}
}

View File

@ -4,14 +4,16 @@ use super::*;
use crate::xml_builder::*;
use crate::{documents::BuildXML, HeightRule};
#[derive(Debug, Clone, PartialEq, Serialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct TableRowProperty {
grid_after: Option<u32>,
width_after: Option<f32>,
grid_before: Option<u32>,
width_before: Option<f32>,
#[serde(skip_serializing_if = "Option::is_none")]
row_height: Option<f32>,
#[serde(skip_serializing_if = "Option::is_none")]
height_rule: Option<HeightRule>,
#[serde(skip_serializing_if = "Option::is_none")]
pub del: Option<Delete>,
@ -65,20 +67,6 @@ impl TableRowProperty {
}
}
impl Default for TableRowProperty {
fn default() -> Self {
TableRowProperty {
grid_after: None,
width_after: None,
grid_before: None,
width_before: None,
row_height: None,
height_rule: None,
del: None,
ins: None,
}
}
}
impl BuildXML for TableRowProperty {
fn build(&self) -> Vec<u8> {

View File

@ -19,7 +19,7 @@ impl ElementReader for TableRow {
let mut row_height = None;
let mut del = None;
let mut ins = None;
let mut height_rule = Some(HeightRule::Auto);
let mut height_rule = None;
loop {
let e = r.next();
match e {

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

View File

@ -6,7 +6,7 @@ export class TableRow {
cells: TableCell[] = [];
hasNumberings = false;
height: number | null = null;
hRule: HeightRule = "atLeast";
hRule: HeightRule | null = null;
del: { author: string; date: string } | null = null;
ins: { author: string; date: string } | null = null;

View File

@ -1,6 +1,6 @@
{
"name": "docx-wasm",
"version": "0.0.276-rc29",
"version": "0.0.276-rc30",
"main": "dist/node/index.js",
"browser": "dist/web/index.js",
"author": "bokuweb <bokuweb12@gmail.com>",

View File

@ -8414,7 +8414,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": 970,
"widthAfter": null,
"widthBefore": null,
@ -8766,7 +8765,6 @@ Object {
"property": Object {
"gridAfter": 1,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": 675,
"widthAfter": 1065,
"widthBefore": null,
@ -20024,8 +20022,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -20104,8 +20100,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -20182,8 +20176,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -20262,8 +20254,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -88680,8 +88670,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -88962,8 +88950,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -89228,8 +89214,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -89494,8 +89478,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -89754,8 +89736,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -90020,8 +90000,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -90286,8 +90264,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -106957,8 +106933,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -107101,8 +107075,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -107245,8 +107217,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},
@ -116547,7 +116517,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": 730,
"widthAfter": null,
"widthBefore": null,
@ -116695,8 +116664,6 @@ Object {
"property": Object {
"gridAfter": null,
"gridBefore": null,
"heightRule": "auto",
"rowHeight": null,
"widthAfter": null,
"widthBefore": null,
},