You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by sa...@apache.org on 2021/05/20 08:52:30 UTC
svn commit: r1890040 - in /poi/trunk:
poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java
poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFComments.java
test-data/document/testComment.docx
Author: sayi
Date: Thu May 20 08:52:30 2021
New Revision: 1890040
URL: http://svn.apache.org/viewvc?rev=1890040&view=rev
Log:
fixed unable to read comments with pictures
Added:
poi/trunk/test-data/document/testComment.docx (with props)
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFComments.java
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java?rev=1890040&r1=1890039&r2=1890040&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java Thu May 20 08:52:30 2021
@@ -56,8 +56,13 @@ public class XWPFComments extends POIXML
*
* @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();
+ }
}
/**
Modified: poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFComments.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFComments.java?rev=1890040&r1=1890039&r2=1890040&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFComments.java (original)
+++ poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFComments.java Thu May 20 08:52:30 2021
@@ -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());
+ }
+ }
+
}
Added: poi/trunk/test-data/document/testComment.docx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/testComment.docx?rev=1890040&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/document/testComment.docx
------------------------------------------------------------------------------
--- svn:mime-type (added)
+++ svn:mime-type Thu May 20 08:52:30 2021
@@ -0,0 +1 @@
+application/vnd.openxmlformats-officedocument.wordprocessingml.document
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org