You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2019/10/26 05:26:36 UTC
svn commit: r1868978 - in /poi/trunk:
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFComment.java
test-data/document/comment.docx
Author: centic
Date: Sat Oct 26 05:26:36 2019
New Revision: 1868978
URL: http://svn.apache.org/viewvc?rev=1868978&view=rev
Log:
XWPF: Insert newlines between multiple paragraphs in comments.
Closes PR #161 on GitHub
Added:
poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFComment.java
- copied, changed from r1868977, poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java
poi/trunk/test-data/document/comment.docx
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java?rev=1868978&r1=1868977&r2=1868978&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java Sat Oct 26 05:26:36 2019
@@ -35,6 +35,10 @@ public class XWPFComment {
author = comment.getAuthor();
for (CTP ctp : comment.getPArray()) {
+ if(text.length() > 0) {
+ text.append("\n");
+ }
+
XWPFParagraph p = new XWPFParagraph(ctp, document);
text.append(p.getText());
}
Copied: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFComment.java (from r1868977, poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFComment.java?p2=poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFComment.java&p1=poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java&r1=1868977&r2=1868978&rev=1868978&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFComment.java Sat Oct 26 05:26:36 2019
@@ -16,39 +16,22 @@
==================================================================== */
package org.apache.poi.xwpf.usermodel;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTComment;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
+import org.apache.poi.xwpf.XWPFTestDataSamples;
+import org.junit.Test;
-/**
- * Sketch of XWPF comment class
- *
- * @author Yury Batrakov (batrakov at gmail.com)
- */
-public class XWPFComment {
- protected String id;
- protected String author;
- protected StringBuilder text;
+import java.io.IOException;
- public XWPFComment(CTComment comment, XWPFDocument document) {
- text = new StringBuilder(64);
- id = comment.getId().toString();
- author = comment.getAuthor();
+import static org.junit.Assert.assertEquals;
- for (CTP ctp : comment.getPArray()) {
- XWPFParagraph p = new XWPFParagraph(ctp, document);
- text.append(p.getText());
+public class TestXWPFComment {
+ @Test
+ public void testText() throws IOException {
+ try (XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("comment.docx")) {
+ assertEquals(1, doc.getComments().length);
+ XWPFComment comment = doc.getComments()[0];
+ assertEquals("Unbekannter Autor", comment.getAuthor());
+ assertEquals("0", comment.getId());
+ assertEquals("This is the first line\n\nThis is the second line", comment.getText());
}
}
-
- public String getId() {
- return id;
- }
-
- public String getAuthor() {
- return author;
- }
-
- public String getText() {
- return text.toString();
- }
}
Added: poi/trunk/test-data/document/comment.docx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/comment.docx?rev=1868978&view=auto
==============================================================================
Binary files poi/trunk/test-data/document/comment.docx (added) and poi/trunk/test-data/document/comment.docx Sat Oct 26 05:26:36 2019 differ
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org