From 4378de2ecc58e19b113d17e50253585ca96a17d0 Mon Sep 17 00:00:00 2001 From: bokuweb Date: Fri, 28 Feb 2020 19:52:41 +0900 Subject: [PATCH] Fix read error (#49) * fix: use i32 instead of usize for indent * update * fix:insert json type * fix: insert and delete child * update --- docx-core/examples/reader.rs | 2 +- docx-core/src/documents/elements/indent.rs | 12 +++------ docx-core/src/documents/elements/level.rs | 16 ++++++------ docx-core/src/documents/elements/paragraph.rs | 4 +-- .../documents/elements/paragraph_property.rs | 4 +-- docx-core/src/documents/elements/style.rs | 4 +-- docx-core/src/reader/attributes/indent.rs | 12 ++++----- docx-core/src/reader/delete.rs | 24 ++++++++---------- docx-core/src/reader/insert.rs | 24 ++++++++---------- docx-core/src/types/special_indent_type.rs | 4 +-- docx-core/src/xml_builder/elements.rs | 4 +-- docx-core/tests/reader.rs | 15 +++++++++++ .../lib__reader__read_insert_table.snap | 5 ++++ .../snapshots/reader__read_insert_table.snap | 5 ++++ docx-wasm/js/json/paragraph.ts | 12 ++++++--- docx-wasm/package.json | 2 +- docx-wasm/src/adaptors/special_indent.rs | 6 +++-- docx-wasm/src/level.rs | 4 +-- docx-wasm/src/paragraph.rs | 4 +-- fixtures/insert_table/insert_table.docx | Bin 0 -> 4834 bytes 20 files changed, 92 insertions(+), 71 deletions(-) create mode 100644 docx-core/tests/snapshots/lib__reader__read_insert_table.snap create mode 100644 docx-core/tests/snapshots/reader__read_insert_table.snap create mode 100644 fixtures/insert_table/insert_table.docx diff --git a/docx-core/examples/reader.rs b/docx-core/examples/reader.rs index 083934b..af3ec9c 100644 --- a/docx-core/examples/reader.rs +++ b/docx-core/examples/reader.rs @@ -3,7 +3,7 @@ use std::fs::*; use std::io::Read; pub fn main() { - let mut file = File::open("./2.docx").unwrap(); + let mut file = File::open("./insert.docx").unwrap(); let mut buf = vec![]; file.read_to_end(&mut buf).unwrap(); dbg!(read_docx(&buf).unwrap().json()); diff --git a/docx-core/src/documents/elements/indent.rs b/docx-core/src/documents/elements/indent.rs index 8936b44..e7b6b45 100644 --- a/docx-core/src/documents/elements/indent.rs +++ b/docx-core/src/documents/elements/indent.rs @@ -7,17 +7,13 @@ use crate::xml_builder::*; #[derive(Debug, Clone, PartialEq)] pub struct Indent { - start: usize, - end: Option, + start: i32, + end: Option, special_indent: Option, } impl Indent { - pub fn new( - start: usize, - special_indent: Option, - end: Option, - ) -> Indent { + pub fn new(start: i32, special_indent: Option, end: Option) -> Indent { Indent { start, end, @@ -25,7 +21,7 @@ impl Indent { } } - pub fn end(mut self, end: usize) -> Self { + pub fn end(mut self, end: i32) -> Self { self.end = Some(end); self } diff --git a/docx-core/src/documents/elements/level.rs b/docx-core/src/documents/elements/level.rs index 7e728b2..cb3c116 100644 --- a/docx-core/src/documents/elements/level.rs +++ b/docx-core/src/documents/elements/level.rs @@ -37,9 +37,9 @@ impl Level { pub fn indent( mut self, - left: usize, + left: i32, special_indent: Option, - end: Option, + end: Option, ) -> Self { self.paragraph_property = self.paragraph_property.indent(left, special_indent, end); self @@ -84,9 +84,9 @@ mod tests { ) .build(); assert_eq!( - str::from_utf8(&b).unwrap(), - r#""# - ); + str::from_utf8(&b).unwrap(), + r#""# + ); } #[test] @@ -101,8 +101,8 @@ mod tests { .indent(320, Some(SpecialIndentType::Hanging(200)), None) .build(); assert_eq!( - str::from_utf8(&b).unwrap(), - r#""# - ); + str::from_utf8(&b).unwrap(), + r#""# + ); } } diff --git a/docx-core/src/documents/elements/paragraph.rs b/docx-core/src/documents/elements/paragraph.rs index 25f7c69..4f8e7b9 100644 --- a/docx-core/src/documents/elements/paragraph.rs +++ b/docx-core/src/documents/elements/paragraph.rs @@ -163,9 +163,9 @@ impl Paragraph { pub fn indent( mut self, - left: usize, + left: i32, special_indent: Option, - end: Option, + end: Option, ) -> Paragraph { self.property = self.property.indent(left, special_indent, end); self diff --git a/docx-core/src/documents/elements/paragraph_property.rs b/docx-core/src/documents/elements/paragraph_property.rs index 2fb4eac..51f82a1 100644 --- a/docx-core/src/documents/elements/paragraph_property.rs +++ b/docx-core/src/documents/elements/paragraph_property.rs @@ -50,9 +50,9 @@ impl ParagraphProperty { pub fn indent( mut self, - left: usize, + left: i32, special_indent: Option, - end: Option, + end: Option, ) -> Self { self.indent = Some(Indent::new(left, special_indent, end)); self diff --git a/docx-core/src/documents/elements/style.rs b/docx-core/src/documents/elements/style.rs index 3211c2c..dd00cb3 100644 --- a/docx-core/src/documents/elements/style.rs +++ b/docx-core/src/documents/elements/style.rs @@ -89,9 +89,9 @@ impl Style { pub fn indent( mut self, - left: usize, + left: i32, special_indent: Option, - end: Option, + end: Option, ) -> Self { self.paragraph_property = self.paragraph_property.indent(left, special_indent, end); self diff --git a/docx-core/src/reader/attributes/indent.rs b/docx-core/src/reader/attributes/indent.rs index 06f5438..df00bbe 100644 --- a/docx-core/src/reader/attributes/indent.rs +++ b/docx-core/src/reader/attributes/indent.rs @@ -8,21 +8,21 @@ use super::super::errors::*; pub fn read_indent( attrs: &[OwnedAttribute], -) -> Result<(usize, Option, Option), ReaderError> { +) -> Result<(i32, Option, Option), ReaderError> { let mut start = 0; - let mut end: Option = None; + let mut end: Option = None; let mut special: Option = None; for a in attrs { let local_name = &a.name.local_name; if local_name == "left" || local_name == "start" { - start = usize::from_str(&a.value)?; + start = i32::from_str(&a.value)?; } else if local_name == "end" || local_name == "right" { - end = Some(usize::from_str(&a.value)?); + end = Some(i32::from_str(&a.value)?); } else if local_name == "hanging" { - special = Some(SpecialIndentType::Hanging(usize::from_str(&a.value)?)) + special = Some(SpecialIndentType::Hanging(i32::from_str(&a.value)?)) } else if local_name == "firstLine" { - special = Some(SpecialIndentType::FirstLine(usize::from_str(&a.value)?)) + special = Some(SpecialIndentType::FirstLine(i32::from_str(&a.value)?)) } } diff --git a/docx-core/src/reader/delete.rs b/docx-core/src/reader/delete.rs index 9e7f3c2..126133c 100644 --- a/docx-core/src/reader/delete.rs +++ b/docx-core/src/reader/delete.rs @@ -11,7 +11,7 @@ impl ElementReader for Delete { r: &mut EventReader, attrs: &[OwnedAttribute], ) -> Result { - let mut run: Option = None; + let mut run = Run::new(); loop { let e = r.next(); match e { @@ -19,26 +19,22 @@ impl ElementReader for Delete { let e = XMLElement::from_str(&name.local_name) .expect("should convert to XMLElement"); if let XMLElement::Run = e { - run = Some(Run::read(r, attrs)?); + run = Run::read(r, attrs)?; } } Ok(XmlEvent::EndElement { name, .. }) => { let e = XMLElement::from_str(&name.local_name).unwrap(); if e == XMLElement::Delete { - if let Some(run) = run { - let mut del = Delete::new(run); - for attr in attrs { - let local_name = &attr.name.local_name; - if local_name == "author" { - del = del.author(&attr.value); - } else if local_name == "date" { - del = del.date(&attr.value); - } + let mut del = Delete::new(run); + for attr in attrs { + let local_name = &attr.name.local_name; + if local_name == "author" { + del = del.author(&attr.value); + } else if local_name == "date" { + del = del.date(&attr.value); } - return Ok(del); - } else { - return Err(ReaderError::XMLReadError); } + return Ok(del); } } Err(_) => return Err(ReaderError::XMLReadError), diff --git a/docx-core/src/reader/insert.rs b/docx-core/src/reader/insert.rs index 089128d..7060492 100644 --- a/docx-core/src/reader/insert.rs +++ b/docx-core/src/reader/insert.rs @@ -11,33 +11,29 @@ impl ElementReader for Insert { r: &mut EventReader, attrs: &[OwnedAttribute], ) -> Result { - let mut run: Option = None; + let mut run = Run::new(); loop { let e = r.next(); match e { Ok(XmlEvent::StartElement { name, .. }) => { let e = XMLElement::from_str(&name.local_name).unwrap(); if let XMLElement::Run = e { - run = Some(Run::read(r, attrs)?); + run = Run::read(r, attrs)?; } } Ok(XmlEvent::EndElement { name, .. }) => { let e = XMLElement::from_str(&name.local_name).unwrap(); if e == XMLElement::Insert { - if let Some(run) = run { - let mut ins = Insert::new(run); - for attr in attrs { - let local_name = &attr.name.local_name; - if local_name == "author" { - ins = ins.author(&attr.value); - } else if local_name == "date" { - ins = ins.date(&attr.value); - } + let mut ins = Insert::new(run); + for attr in attrs { + let local_name = &attr.name.local_name; + if local_name == "author" { + ins = ins.author(&attr.value); + } else if local_name == "date" { + ins = ins.date(&attr.value); } - return Ok(ins); - } else { - return Err(ReaderError::XMLReadError); } + return Ok(ins); } } Err(_) => return Err(ReaderError::XMLReadError), diff --git a/docx-core/src/types/special_indent_type.rs b/docx-core/src/types/special_indent_type.rs index 7db9cd2..f7a4c0e 100644 --- a/docx-core/src/types/special_indent_type.rs +++ b/docx-core/src/types/special_indent_type.rs @@ -7,8 +7,8 @@ use serde::Serialize; // Please convert typescript type to following type. #[derive(Copy, Clone, Debug, PartialEq)] pub enum SpecialIndentType { - FirstLine(usize), - Hanging(usize), + FirstLine(i32), + Hanging(i32), } #[wasm_bindgen] diff --git a/docx-core/src/xml_builder/elements.rs b/docx-core/src/xml_builder/elements.rs index ba7a27d..8964a26 100644 --- a/docx-core/src/xml_builder/elements.rs +++ b/docx-core/src/xml_builder/elements.rs @@ -89,9 +89,9 @@ impl XMLBuilder { // i.e. pub(crate) fn indent( mut self, - start: usize, + start: i32, special_indent: Option, - end: usize, + end: i32, ) -> Self { let start = &format!("{}", start); let end = &format!("{}", end); diff --git a/docx-core/tests/reader.rs b/docx-core/tests/reader.rs index e4e1df6..a42ad52 100644 --- a/docx-core/tests/reader.rs +++ b/docx-core/tests/reader.rs @@ -169,3 +169,18 @@ pub fn read_bookmark() { file.write_all(json.as_bytes()).unwrap(); file.flush().unwrap(); } + +#[test] +pub fn read_insert_table() { + let mut file = File::open("../fixtures/insert_table/insert_table.docx").unwrap(); + let mut buf = vec![]; + file.read_to_end(&mut buf).unwrap(); + let json = read_docx(&buf).unwrap().json(); + + assert_debug_snapshot!(&json); + + let path = std::path::Path::new("./tests/output/insert_table.json"); + let mut file = std::fs::File::create(&path).unwrap(); + file.write_all(json.as_bytes()).unwrap(); + file.flush().unwrap(); +} diff --git a/docx-core/tests/snapshots/lib__reader__read_insert_table.snap b/docx-core/tests/snapshots/lib__reader__read_insert_table.snap new file mode 100644 index 0000000..ba91f1b --- /dev/null +++ b/docx-core/tests/snapshots/lib__reader__read_insert_table.snap @@ -0,0 +1,5 @@ +--- +source: docx-core/tests/reader.rs +expression: "&json" +--- +"{\n \"contentType\": {\n \"types\": {\n \"/_rels/.rels\": \"application/vnd.openxmlformats-package.relationships+xml\",\n \"/docProps/app.xml\": \"application/vnd.openxmlformats-officedocument.extended-properties+xml\",\n \"/docProps/core.xml\": \"application/vnd.openxmlformats-package.core-properties+xml\",\n \"/word/_rels/document.xml.rels\": \"application/vnd.openxmlformats-package.relationships+xml\",\n \"/word/comments.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml\",\n \"/word/document.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\",\n \"/word/fontTable.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\",\n \"/word/numbering.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml\",\n \"/word/settings.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\",\n \"/word/styles.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"\n }\n },\n \"rels\": {\n \"rels\": [\n [\n \"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\",\n \"rId1\",\n \"docProps/core.xml\"\n ],\n [\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\",\n \"rId2\",\n \"docProps/app.xml\"\n ],\n [\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\",\n \"rId3\",\n \"word/document.xml\"\n ]\n ]\n },\n \"documentRels\": {\n \"hasComments\": false,\n \"hasNumberings\": false\n },\n \"docProps\": {\n \"app\": {},\n \"core\": {\n \"config\": {\n \"created\": null,\n \"creator\": null,\n \"description\": null,\n \"language\": null,\n \"lastModifiedBy\": null,\n \"modified\": null,\n \"revision\": null,\n \"subject\": null,\n \"title\": null\n }\n }\n },\n \"styles\": {\n \"docDefaults\": {\n \"runPropertyDefault\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n }\n }\n },\n \"styles\": [\n {\n \"styleId\": \"Normal\",\n \"name\": \"Normal\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": \"auto\",\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style14\",\n \"name\": \"見出し\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": 28,\n \"szCs\": 28,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style15\",\n \"name\": \"Body Text\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style16\",\n \"name\": \"List\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style17\",\n \"name\": \"Caption\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": true,\n \"italicCs\": true,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style18\",\n \"name\": \"索引\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style19\",\n \"name\": \"表の内容\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n }\n ]\n },\n \"document\": {\n \"children\": [\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"run\",\n \"data\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": [\n {\n \"type\": \"text\",\n \"data\": {\n \"preserveSpace\": true,\n \"text\": \"Hello\"\n }\n }\n ]\n }\n },\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": [\n {\n \"type\": \"text\",\n \"data\": {\n \"preserveSpace\": true,\n \"text\": \" World\"\n }\n }\n ]\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T18:36:03Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n },\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n },\n {\n \"type\": \"table\",\n \"data\": {\n \"rows\": [\n {\n \"cells\": [\n {\n \"children\": [\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n },\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": \"000000\",\n \"highlight\": null,\n \"underline\": \"none\",\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": [\n {\n \"type\": \"text\",\n \"data\": {\n \"preserveSpace\": true,\n \"text\": \"Hi\"\n }\n }\n ]\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Style19\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n }\n ],\n \"property\": {\n \"width\": {\n \"width\": 4819,\n \"widthType\": \"DXA\"\n },\n \"borders\": null,\n \"gridSpan\": null,\n \"verticalMerge\": null\n },\n \"hasNumbering\": false\n },\n {\n \"children\": [\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n },\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": \"000000\",\n \"highlight\": null,\n \"underline\": \"none\",\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Style19\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n }\n ],\n \"property\": {\n \"width\": {\n \"width\": 4819,\n \"widthType\": \"DXA\"\n },\n \"borders\": null,\n \"gridSpan\": null,\n \"verticalMerge\": null\n },\n \"hasNumbering\": false\n }\n ],\n \"hasNumbering\": false,\n \"property\": {}\n },\n {\n \"cells\": [\n {\n \"children\": [\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n },\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": \"000000\",\n \"highlight\": null,\n \"underline\": \"none\",\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Style19\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n }\n ],\n \"property\": {\n \"width\": {\n \"width\": 4819,\n \"widthType\": \"DXA\"\n },\n \"borders\": null,\n \"gridSpan\": null,\n \"verticalMerge\": null\n },\n \"hasNumbering\": false\n },\n {\n \"children\": [\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n },\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": \"000000\",\n \"highlight\": null,\n \"underline\": \"none\",\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Style19\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n }\n ],\n \"property\": {\n \"width\": {\n \"width\": 4819,\n \"widthType\": \"DXA\"\n },\n \"borders\": null,\n \"gridSpan\": null,\n \"verticalMerge\": null\n },\n \"hasNumbering\": false\n }\n ],\n \"hasNumbering\": false,\n \"property\": {}\n }\n ],\n \"grid\": [\n 4819,\n 4819\n ],\n \"hasNumbering\": false,\n \"property\": {\n \"width\": {\n \"width\": 9638,\n \"widthType\": \"DXA\"\n },\n \"justification\": \"left\",\n \"borders\": {\n \"top\": {\n \"position\": \"top\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n },\n \"left\": {\n \"position\": \"left\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n },\n \"bottom\": {\n \"position\": \"bottom\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n },\n \"right\": {\n \"position\": \"right\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n },\n \"insideH\": {\n \"position\": \"insideH\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n },\n \"insideV\": {\n \"position\": \"insideV\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n }\n },\n \"margins\": {\n \"top\": 55,\n \"left\": 54,\n \"bottom\": 55,\n \"right\": 55\n },\n \"indent\": {\n \"width\": 0,\n \"widthType\": \"DXA\"\n }\n }\n }\n },\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"run\",\n \"data\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n }\n ],\n \"sectionProperty\": {\n \"pageSize\": {\n \"w\": 11906,\n \"h\": 16838\n },\n \"pageMargin\": {\n \"top\": 1985,\n \"left\": 1701,\n \"bottom\": 1701,\n \"right\": 1701,\n \"header\": 851,\n \"footer\": 992,\n \"gutter\": 0\n },\n \"columns\": 425,\n \"documentGrid\": 360\n },\n \"hasNumbering\": false\n },\n \"comments\": {\n \"comments\": []\n },\n \"numberings\": {\n \"abstractNums\": [],\n \"numberings\": []\n },\n \"settings\": {\n \"defaultTabStop\": 709,\n \"zoom\": 100\n },\n \"fontTable\": {}\n}" diff --git a/docx-core/tests/snapshots/reader__read_insert_table.snap b/docx-core/tests/snapshots/reader__read_insert_table.snap new file mode 100644 index 0000000..ba91f1b --- /dev/null +++ b/docx-core/tests/snapshots/reader__read_insert_table.snap @@ -0,0 +1,5 @@ +--- +source: docx-core/tests/reader.rs +expression: "&json" +--- +"{\n \"contentType\": {\n \"types\": {\n \"/_rels/.rels\": \"application/vnd.openxmlformats-package.relationships+xml\",\n \"/docProps/app.xml\": \"application/vnd.openxmlformats-officedocument.extended-properties+xml\",\n \"/docProps/core.xml\": \"application/vnd.openxmlformats-package.core-properties+xml\",\n \"/word/_rels/document.xml.rels\": \"application/vnd.openxmlformats-package.relationships+xml\",\n \"/word/comments.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml\",\n \"/word/document.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\",\n \"/word/fontTable.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\",\n \"/word/numbering.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml\",\n \"/word/settings.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\",\n \"/word/styles.xml\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"\n }\n },\n \"rels\": {\n \"rels\": [\n [\n \"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\",\n \"rId1\",\n \"docProps/core.xml\"\n ],\n [\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\",\n \"rId2\",\n \"docProps/app.xml\"\n ],\n [\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\",\n \"rId3\",\n \"word/document.xml\"\n ]\n ]\n },\n \"documentRels\": {\n \"hasComments\": false,\n \"hasNumberings\": false\n },\n \"docProps\": {\n \"app\": {},\n \"core\": {\n \"config\": {\n \"created\": null,\n \"creator\": null,\n \"description\": null,\n \"language\": null,\n \"lastModifiedBy\": null,\n \"modified\": null,\n \"revision\": null,\n \"subject\": null,\n \"title\": null\n }\n }\n },\n \"styles\": {\n \"docDefaults\": {\n \"runPropertyDefault\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n }\n }\n },\n \"styles\": [\n {\n \"styleId\": \"Normal\",\n \"name\": \"Normal\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": \"auto\",\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style14\",\n \"name\": \"見出し\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": 28,\n \"szCs\": 28,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style15\",\n \"name\": \"Body Text\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style16\",\n \"name\": \"List\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style17\",\n \"name\": \"Caption\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": true,\n \"italicCs\": true,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style18\",\n \"name\": \"索引\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n },\n {\n \"styleId\": \"Style19\",\n \"name\": \"表の内容\",\n \"styleType\": \"paragraph\",\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"paragraphProperty\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": null,\n \"indent\": null\n }\n }\n ]\n },\n \"document\": {\n \"children\": [\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"run\",\n \"data\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": [\n {\n \"type\": \"text\",\n \"data\": {\n \"preserveSpace\": true,\n \"text\": \"Hello\"\n }\n }\n ]\n }\n },\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": [\n {\n \"type\": \"text\",\n \"data\": {\n \"preserveSpace\": true,\n \"text\": \" World\"\n }\n }\n ]\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T18:36:03Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n },\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n },\n {\n \"type\": \"table\",\n \"data\": {\n \"rows\": [\n {\n \"cells\": [\n {\n \"children\": [\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n },\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": \"000000\",\n \"highlight\": null,\n \"underline\": \"none\",\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": [\n {\n \"type\": \"text\",\n \"data\": {\n \"preserveSpace\": true,\n \"text\": \"Hi\"\n }\n }\n ]\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Style19\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n }\n ],\n \"property\": {\n \"width\": {\n \"width\": 4819,\n \"widthType\": \"DXA\"\n },\n \"borders\": null,\n \"gridSpan\": null,\n \"verticalMerge\": null\n },\n \"hasNumbering\": false\n },\n {\n \"children\": [\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n },\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": \"000000\",\n \"highlight\": null,\n \"underline\": \"none\",\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Style19\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n }\n ],\n \"property\": {\n \"width\": {\n \"width\": 4819,\n \"widthType\": \"DXA\"\n },\n \"borders\": null,\n \"gridSpan\": null,\n \"verticalMerge\": null\n },\n \"hasNumbering\": false\n }\n ],\n \"hasNumbering\": false,\n \"property\": {}\n },\n {\n \"cells\": [\n {\n \"children\": [\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n },\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": \"000000\",\n \"highlight\": null,\n \"underline\": \"none\",\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Style19\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n }\n ],\n \"property\": {\n \"width\": {\n \"width\": 4819,\n \"widthType\": \"DXA\"\n },\n \"borders\": null,\n \"gridSpan\": null,\n \"verticalMerge\": null\n },\n \"hasNumbering\": false\n },\n {\n \"children\": [\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n },\n {\n \"type\": \"insert\",\n \"data\": {\n \"run\": {\n \"runProperty\": {\n \"sz\": 24,\n \"szCs\": 24,\n \"color\": \"000000\",\n \"highlight\": null,\n \"underline\": \"none\",\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n },\n \"author\": \"不明な作成者\",\n \"date\": \"2020-02-28T19:05:33Z\"\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Style19\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n }\n ],\n \"property\": {\n \"width\": {\n \"width\": 4819,\n \"widthType\": \"DXA\"\n },\n \"borders\": null,\n \"gridSpan\": null,\n \"verticalMerge\": null\n },\n \"hasNumbering\": false\n }\n ],\n \"hasNumbering\": false,\n \"property\": {}\n }\n ],\n \"grid\": [\n 4819,\n 4819\n ],\n \"hasNumbering\": false,\n \"property\": {\n \"width\": {\n \"width\": 9638,\n \"widthType\": \"DXA\"\n },\n \"justification\": \"left\",\n \"borders\": {\n \"top\": {\n \"position\": \"top\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n },\n \"left\": {\n \"position\": \"left\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n },\n \"bottom\": {\n \"position\": \"bottom\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n },\n \"right\": {\n \"position\": \"right\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n },\n \"insideH\": {\n \"position\": \"insideH\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n },\n \"insideV\": {\n \"position\": \"insideV\",\n \"borderType\": \"single\",\n \"size\": 2,\n \"space\": 0,\n \"color\": \"000000\"\n }\n },\n \"margins\": {\n \"top\": 55,\n \"left\": 54,\n \"bottom\": 55,\n \"right\": 55\n },\n \"indent\": {\n \"width\": 0,\n \"widthType\": \"DXA\"\n }\n }\n }\n },\n {\n \"type\": \"paragraph\",\n \"data\": {\n \"children\": [\n {\n \"type\": \"run\",\n \"data\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"children\": []\n }\n }\n ],\n \"property\": {\n \"runProperty\": {\n \"sz\": null,\n \"szCs\": null,\n \"color\": null,\n \"highlight\": null,\n \"underline\": null,\n \"bold\": null,\n \"boldCs\": null,\n \"italic\": null,\n \"italicCs\": null,\n \"vanish\": null\n },\n \"style\": \"Normal\",\n \"numberingProperty\": null,\n \"alignment\": \"left\",\n \"indent\": null\n },\n \"hasNumbering\": false,\n \"attrs\": []\n }\n }\n ],\n \"sectionProperty\": {\n \"pageSize\": {\n \"w\": 11906,\n \"h\": 16838\n },\n \"pageMargin\": {\n \"top\": 1985,\n \"left\": 1701,\n \"bottom\": 1701,\n \"right\": 1701,\n \"header\": 851,\n \"footer\": 992,\n \"gutter\": 0\n },\n \"columns\": 425,\n \"documentGrid\": 360\n },\n \"hasNumbering\": false\n },\n \"comments\": {\n \"comments\": []\n },\n \"numberings\": {\n \"abstractNums\": [],\n \"numberings\": []\n },\n \"settings\": {\n \"defaultTabStop\": 709,\n \"zoom\": 100\n },\n \"fontTable\": {}\n}" diff --git a/docx-wasm/js/json/paragraph.ts b/docx-wasm/js/json/paragraph.ts index f73c761..904c9fa 100644 --- a/docx-wasm/js/json/paragraph.ts +++ b/docx-wasm/js/json/paragraph.ts @@ -1,4 +1,4 @@ -import { RunJSON, RunChildJSON } from "./run"; +import { RunJSON, RunChildJSON, RunPropertyJSON } from "./run"; import { IndentJSON } from "./indent"; export type ParagraphChildJSON = @@ -32,7 +32,10 @@ export type ParagraphJSON = { export type InsertJSON = { type: "insert"; data: { - run: RunJSON; + run: { + runProperty: RunPropertyJSON; + children: RunChildJSON[]; + }; author: string; data: string; }; @@ -41,7 +44,10 @@ export type InsertJSON = { export type DeleteJSON = { type: "delete"; data: { - run: RunJSON; + run: { + runProperty: RunPropertyJSON; + children: RunChildJSON[]; + }; author: string; data: string; }; diff --git a/docx-wasm/package.json b/docx-wasm/package.json index e34a782..6b5df5f 100644 --- a/docx-wasm/package.json +++ b/docx-wasm/package.json @@ -1,6 +1,6 @@ { "name": "docx-wasm", - "version": "0.0.44", + "version": "0.0.47", "main": "dist/node/index.js", "browser": "dist/web/index.js", "author": "bokuweb ", diff --git a/docx-wasm/src/adaptors/special_indent.rs b/docx-wasm/src/adaptors/special_indent.rs index 2ab79bf..66672a5 100644 --- a/docx-wasm/src/adaptors/special_indent.rs +++ b/docx-wasm/src/adaptors/special_indent.rs @@ -2,12 +2,14 @@ use docx_rs; pub fn create_special_indent( special_indent_kind: Option, - special_indent_size: Option, + special_indent_size: Option, ) -> Option { if let Some(kind) = special_indent_kind { let size = special_indent_size.unwrap_or_else(|| 0); match kind { - docx_rs::SpecialIndentKind::FirstLine => Some(docx_rs::SpecialIndentType::FirstLine(size)), + docx_rs::SpecialIndentKind::FirstLine => { + Some(docx_rs::SpecialIndentType::FirstLine(size)) + } docx_rs::SpecialIndentKind::Hanging => Some(docx_rs::SpecialIndentType::Hanging(size)), } } else { diff --git a/docx-wasm/src/level.rs b/docx-wasm/src/level.rs index a82bc46..ea15f60 100644 --- a/docx-wasm/src/level.rs +++ b/docx-wasm/src/level.rs @@ -25,9 +25,9 @@ impl Level { impl Level { pub fn indent( mut self, - left: usize, + left: i32, special_indent_kind: Option, - special_indent_size: Option, + special_indent_size: Option, ) -> Self { let special_indent = create_special_indent(special_indent_kind, special_indent_size); self.0.paragraph_property = self.0.paragraph_property.indent(left, special_indent, None); diff --git a/docx-wasm/src/paragraph.rs b/docx-wasm/src/paragraph.rs index ad0ccc1..6bddec4 100644 --- a/docx-wasm/src/paragraph.rs +++ b/docx-wasm/src/paragraph.rs @@ -74,9 +74,9 @@ impl Paragraph { pub fn indent( mut self, - left: usize, + left: i32, special_indent_kind: Option, - special_indent_size: Option, + special_indent_size: Option, ) -> Paragraph { let special_indent = create_special_indent(special_indent_kind, special_indent_size); self.0.property = self.0.property.indent(left, special_indent, None); diff --git a/fixtures/insert_table/insert_table.docx b/fixtures/insert_table/insert_table.docx new file mode 100644 index 0000000000000000000000000000000000000000..1fb384e34310a308d3497aab997d8b2f25e9f581 GIT binary patch literal 4834 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