fn update_comments(&mut self) {
        let mut comments: Vec<Comment> = vec![];
        let mut comments_extended: Vec<CommentExtended> = vec![];

        let mut comment_map: HashMap<usize, String> = HashMap::new();
        for child in &self.document.children {
            match child {
                DocumentChild::Paragraph(paragraph) => {
                    for child in &paragraph.children {
                        if let ParagraphChild::CommentStart(c) = child {
                            self.insert_comment_to_map(&mut comment_map, c);
                        }
                        if let ParagraphChild::Hyperlink(h) = child {
                            for child in &h.children {
                                if let ParagraphChild::CommentStart(c) = child {
                                    self.insert_comment_to_map(&mut comment_map, c);
                                }
                            }
                        }
                    }
                }
                DocumentChild::Table(table) => {
                    for TableChild::TableRow(row) in &table.rows {
                        for TableRowChild::TableCell(cell) in &row.cells {
                            for content in &cell.children {
                                match content {
                                    TableCellContent::Paragraph(paragraph) => {
                                        for child in &paragraph.children {
                                            if let ParagraphChild::CommentStart(c) = child {
                                                self.insert_comment_to_map(&mut comment_map, c);
                                            }
                                            if let ParagraphChild::Hyperlink(h) = child {
                                                for child in &h.children {
                                                    if let ParagraphChild::CommentStart(c) = child {
                                                        self.insert_comment_to_map(
                                                            &mut comment_map,
                                                            c,
                                                        );
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    TableCellContent::Table(_) => {
                                        // TODO: correct comment
                                    }
                                }
                            }
                        }
                    }
                }
                _ => {}
            }
        }

        for child in &self.document.children {
            match child {
                DocumentChild::Paragraph(paragraph) => {
                    for child in &paragraph.children {
                        if let ParagraphChild::CommentStart(c) = child {
                            self.push_comment_and_comment_extended(
                                &mut comments,
                                &mut comments_extended,
                                &comment_map,
                                c,
                            );
                        }
                        if let ParagraphChild::Hyperlink(h) = child {
                            for child in &h.children {
                                if let ParagraphChild::CommentStart(c) = child {
                                    self.push_comment_and_comment_extended(
                                        &mut comments,
                                        &mut comments_extended,
                                        &comment_map,
                                        c,
                                    );
                                }
                            }
                        }
                    }
                }
                DocumentChild::Table(table) => {
                    for TableChild::TableRow(row) in &table.rows {
                        for TableRowChild::TableCell(cell) in &row.cells {
                            for content in &cell.children {
                                match content {
                                    TableCellContent::Paragraph(paragraph) => {
                                        for child in &paragraph.children {
                                            if let ParagraphChild::CommentStart(c) = child {
                                                self.push_comment_and_comment_extended(
                                                    &mut comments,
                                                    &mut comments_extended,
                                                    &comment_map,
                                                    c,
                                                );
                                            }
                                            if let ParagraphChild::Hyperlink(h) = child {
                                                for child in &h.children {
                                                    if let ParagraphChild::CommentStart(c) = child {
                                                        self.push_comment_and_comment_extended(
                                                            &mut comments,
                                                            &mut comments_extended,
                                                            &comment_map,
                                                            c,
                                                        );
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    TableCellContent::Table(_) => {
                                        // TODO: correct comment
                                    }
                                }
                            }
                        }
                    }
                }
                _ => {}
            }
        }
        // If this document has comments, set comments.xml to document_rels.
        // This is because comments.xml without comment cause an error on word online.
        if !comments.is_empty() {
            self.document_rels.has_comments = true;
        }

        self.comments_extended
            .add_comments_extended(comments_extended);

        self.comments.add_comments(comments);
    }
// Traverse and clone comments from document and add to comments node.
Traverse and clone comments from document and add to comments node.
Traverse and clone comments from document and add to comments node .
fn update_comments(&mut self) {
        let mut comments: Vec<Comment> = vec![];
        let mut comments_extended: Vec<CommentExtended> = vec![];
        let mut comment_map: HashMap<usize, String> = HashMap::new();
        for child in &self.document.children {
            match child {
                DocumentChild::Paragraph(paragraph) => {
                    for child in &paragraph.children {
                        if let ParagraphChild::CommentStart(c) = child {
                            self.insert_comment_to_map(&mut comment_map, c);
                        }
                        if let ParagraphChild::Hyperlink(h) = child {
                            for child in &h.children {
                                if let ParagraphChild::CommentStart(c) = child {
                                    self.insert_comment_to_map(&mut comment_map, c);
                                }
                            }
                        }
                    }
                }
                DocumentChild::Table(table) => {
                    for TableChild::TableRow(row) in &table.rows {
                        for TableRowChild::TableCell(cell) in &row.cells {
                            for content in &cell.children {
                                match content {
                                    TableCellContent::Paragraph(paragraph) => {
                                        for child in &paragraph.children {
                                            if let ParagraphChild::CommentStart(c) = child {
                                                self.insert_comment_to_map(&mut comment_map, c);
                                            }
                                            if let ParagraphChild::Hyperlink(h) = child {
                                                for child in &h.children {
                                                    if let ParagraphChild::CommentStart(c) = child {
                                                        self.insert_comment_to_map(
                                                            &mut comment_map,
                                                            c,
                                                        );
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    TableCellContent::Table(_) => {
                                        // TODO: correct comment
                                    }
                                }
                            }
                        }
                    }
                }
                _ => {}
            }
        }
        for child in &self.document.children {
            match child {
                DocumentChild::Paragraph(paragraph) => {
                    for child in &paragraph.children {
                        if let ParagraphChild::CommentStart(c) = child {
                            self.push_comment_and_comment_extended(
                                &mut comments,
                                &mut comments_extended,
                                &comment_map,
                                c,
                            );
                        }
                        if let ParagraphChild::Hyperlink(h) = child {
                            for child in &h.children {
                                if let ParagraphChild::CommentStart(c) = child {
                                    self.push_comment_and_comment_extended(
                                        &mut comments,
                                        &mut comments_extended,
                                        &comment_map,
                                        c,
                                    );
                                }
                            }
                        }
                    }
                }
                DocumentChild::Table(table) => {
                    for TableChild::TableRow(row) in &table.rows {
                        for TableRowChild::TableCell(cell) in &row.cells {
                            for content in &cell.children {
                                match content {
                                    TableCellContent::Paragraph(paragraph) => {
                                        for child in &paragraph.children {
                                            if let ParagraphChild::CommentStart(c) = child {
                                                self.push_comment_and_comment_extended(
                                                    &mut comments,
                                                    &mut comments_extended,
                                                    &comment_map,
                                                    c,
                                                );
                                            }
                                            if let ParagraphChild::Hyperlink(h) = child {
                                                for child in &h.children {
                                                    if let ParagraphChild::CommentStart(c) = child {
                                                        self.push_comment_and_comment_extended(
                                                            &mut comments,
                                                            &mut comments_extended,
                                                            &comment_map,
                                                            c,
                                                        );
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    TableCellContent::Table(_) => {
                                        // TODO: correct comment
                                    }
                                }
                            }
                        }
                    }
                }
                _ => {}
            }
        }
        // If this document has comments, set comments.xml to document_rels.
        // This is because comments.xml without comment cause an error on word online.
        if !comments.is_empty() {
            self.document_rels.has_comments = true;
        }
        self.comments_extended
            .add_comments_extended(comments_extended);
        self.comments.add_comments(comments);
    }
fn update_comments ( & mut self ) { let mut comments : Vec < Comment > = vec ! [ ] ; let mut comments_extended : Vec < CommentExtended > = vec ! [ ] ; let mut comment_map : HashMap < usize , String > = HashMap :: new ( ) ; for child in & self . document . children { match child { DocumentChild :: Paragraph ( paragraph ) => { for child in & paragraph . children { if let ParagraphChild :: CommentStart ( c ) = child { self . insert_comment_to_map ( & mut comment_map , c ) ; } if let ParagraphChild :: Hyperlink ( h ) = child { for child in & h . children { if let ParagraphChild :: CommentStart ( c ) = child { self . insert_comment_to_map ( & mut comment_map , c ) ; } } } } } DocumentChild :: Table ( table ) => { for TableChild :: TableRow ( row ) in & table . rows { for TableRowChild :: TableCell ( cell ) in & row . cells { for content in & cell . children { match content { TableCellContent :: Paragraph ( paragraph ) => { for child in & paragraph . children { if let ParagraphChild :: CommentStart ( c ) = child { self . insert_comment_to_map ( & mut comment_map , c ) ; } if let ParagraphChild :: Hyperlink ( h ) = child { for child in & h . children { if let ParagraphChild :: CommentStart ( c ) = child { self . insert_comment_to_map ( & mut comment_map , c , ) ; } } } } } TableCellContent :: Table ( _ ) => { // TODO: correct comment } } } } } } _ => { } } } for child in & self . document . children { match child { DocumentChild :: Paragraph ( paragraph ) => { for child in & paragraph . children { if let ParagraphChild :: CommentStart ( c ) = child { self . push_comment_and_comment_extended ( & mut comments , & mut comments_extended , & comment_map , c , ) ; } if let ParagraphChild :: Hyperlink ( h ) = child { for child in & h . children { if let ParagraphChild :: CommentStart ( c ) = child { self . push_comment_and_comment_extended ( & mut comments , & mut comments_extended , & comment_map , c , ) ; } } } } } DocumentChild :: Table ( table ) => { for TableChild :: TableRow ( row ) in & table . rows { for TableRowChild :: TableCell ( cell ) in & row . cells { for content in & cell . children { match content { TableCellContent :: Paragraph ( paragraph ) => { for child in & paragraph . children { if let ParagraphChild :: CommentStart ( c ) = child { self . push_comment_and_comment_extended ( & mut comments , & mut comments_extended , & comment_map , c , ) ; } if let ParagraphChild :: Hyperlink ( h ) = child { for child in & h . children { if let ParagraphChild :: CommentStart ( c ) = child { self . push_comment_and_comment_extended ( & mut comments , & mut comments_extended , & comment_map , c , ) ; } } } } } TableCellContent :: Table ( _ ) => { // TODO: correct comment } } } } } } _ => { } } } // If this document has comments, set comments.xml to document_rels. // This is because comments.xml without comment cause an error on word online. if ! comments . is_empty ( ) { self . document_rels . has_comments = true ; } self . comments_extended . add_comments_extended ( comments_extended ) ; self . comments . add_comments ( comments ) ; }
Traverse and clone comments from document and add to comments node.
Traverse and clone comments from document and add to comments node .
&mut self