fix to read comment inside Delete in Insert (#755)
parent
93eb2e1bc1
commit
19b174da7c
|
@ -868,6 +868,18 @@ impl Docx {
|
|||
let comment = comment.clone();
|
||||
c.as_mut().comment(comment);
|
||||
}
|
||||
} else if let InsertChild::Delete(ref mut d) = child {
|
||||
for child in &mut d.children {
|
||||
if let DeleteChild::CommentStart(ref mut c) = child {
|
||||
let comment_id = c.get_id();
|
||||
if let Some(comment) =
|
||||
comments.iter().find(|c| c.id() == comment_id)
|
||||
{
|
||||
let comment = comment.clone();
|
||||
c.as_mut().comment(comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -260,6 +260,23 @@ pub fn read_extended_comment() {
|
|||
file.flush().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn read_comment_in_delete_in_insert() {
|
||||
let mut file =
|
||||
File::open("../fixtures/comment_in_delete_in_insert/comment_in_delete_in_insert.docx")
|
||||
.unwrap();
|
||||
let mut buf = vec![];
|
||||
file.read_to_end(&mut buf).unwrap();
|
||||
let json = read_docx(&buf).unwrap().json();
|
||||
|
||||
assert_json_snapshot!("read_comment_in_delete_in_insert", &json);
|
||||
|
||||
let path = std::path::Path::new("./tests/output/comment_in_delete_in_insert.json");
|
||||
let mut file = std::fs::File::create(path).unwrap();
|
||||
file.write_all(json.as_bytes()).unwrap();
|
||||
file.flush().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn read_line_spacing() {
|
||||
let mut file = File::open("../fixtures/line_spacing/line_spacing.docx").unwrap();
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in New Issue