public void TestComments() { int numComments = 0; foreach (XWPFParagraph p in comments.Paragraphs) { XWPFCommentsDecorator d = new XWPFCommentsDecorator(p, null); if (d.GetCommentText().Length > 0) { numComments++; Assert.AreEqual("\tComment by", d.GetCommentText().Substring(0, 11)); } } Assert.AreEqual(3, numComments); }
public void AppendParagraphText(StringBuilder text, XWPFParagraph paragraph) { try { CT_SectPr ctSectPr = null; if (paragraph.GetCTP().pPr != null) { ctSectPr = paragraph.GetCTP().pPr.sectPr; } XWPFHeaderFooterPolicy headerFooterPolicy = null; if (ctSectPr != null) { headerFooterPolicy = new XWPFHeaderFooterPolicy(document, ctSectPr); extractHeaders(text, headerFooterPolicy); } foreach (IRunElement run in paragraph.Runs) { text.Append(run.ToString()); if (run is XWPFHyperlinkRun && fetchHyperlinks) { XWPFHyperlink link = ((XWPFHyperlinkRun)run).GetHyperlink(document); if (link != null) text.Append(" <" + link.URL + ">"); } } // Add comments XWPFCommentsDecorator decorator = new XWPFCommentsDecorator(paragraph, null); String commentText = decorator.GetCommentText(); if (commentText.Length > 0) { text.Append(commentText).Append('\n'); } // Do endnotes and footnotes String footnameText = paragraph.FootnoteText; if (footnameText != null && footnameText.Length > 0) { text.Append(footnameText + '\n'); } if (ctSectPr != null) { extractFooters(text, headerFooterPolicy); } } catch (IOException e) { throw new POIXMLException(e); } catch (XmlException e) { throw new POIXMLException(e); } }