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 0000000..1fb384e Binary files /dev/null and b/fixtures/insert_table/insert_table.docx differ