fixed unable to read comments with pictures

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1890040 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sayi 2021-05-20 08:52:30 +00:00
parent a6c3e6a4fd
commit 974da9f981
3 changed files with 21 additions and 2 deletions

View File

@ -56,8 +56,13 @@ public class XWPFComments extends POIXMLDocumentPart {
*
* @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();
}
}
/**

View File

@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.math.BigInteger;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
@ -59,4 +60,17 @@ class TestXWPFComments {
}
}
@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());
}
}
}

Binary file not shown.