*
* @param part the package part holding the data of the footnotes,
*/
- public XWPFComments(PackagePart part) {
- super(part);
+ public XWPFComments(POIXMLDocumentPart parent, PackagePart part) {
+ super(parent, part);
+ this.document = (XWPFDocument) getParent();
+
+ if (this.document == null) {
+ throw new NullPointerException();
+ }
}
/**
import java.io.IOException;
import java.math.BigInteger;
+import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
}
}
+ @Test
+ void testReadComments() throws IOException {
+ try (XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("testComment.docx")) {
+ XWPFComments docComments = doc.getDocComments();
+ assertNotNull(docComments);
+ XWPFComment[] comments = doc.getComments();
+ assertEquals(1, comments.length);
+
+ List<XWPFPictureData> allPictures = docComments.getAllPictures();
+ assertEquals(1, allPictures.size());
+ }
+ }
+
}