poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1819405 - in /poi/trunk: src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java test-data/document/61787.docx
Date Thu, 28 Dec 2017 08:45:51 GMT
Author: centic
Date: Thu Dec 28 08:45:51 2017
New Revision: 1819405

URL: http://svn.apache.org/viewvc?rev=1819405&view=rev
Log:
Fix bug 61787, which was introduced by bug 58067: Change how deleted content is detected to
not incorrectly see too much text as deleted.

Added:
    poi/trunk/test-data/document/61787.docx
Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java?rev=1819405&r1=1819404&r2=1819405&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java Thu Dec 28 08:45:51
2017
@@ -148,6 +148,12 @@ public class XWPFParagraph implements IB
                 // This implementation does not preserve the tagging information
                 buildRunsInOrderFromXml(o);
             }
+            if (o instanceof CTRunTrackChange) {
+                // add all the insertions as text
+                for (CTRunTrackChange change : ((CTRunTrackChange) o).getInsArray()) {
+                    buildRunsInOrderFromXml(change);
+                }
+            }
         }
         c.dispose();
     }
@@ -189,7 +195,7 @@ public class XWPFParagraph implements IB
             if (run instanceof XWPFRun) {
                 XWPFRun xRun = (XWPFRun) run;
                 // don't include the text if reviewing is enabled and this is a deleted run
-                if (!xRun.getCTR().isSetRsidDel()) {
+                if (xRun.getCTR().getDelTextArray().length == 0) {
                     out.append(xRun);
                 }
             } else if (run instanceof XWPFSDT) {

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java?rev=1819405&r1=1819404&r2=1819405&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java Thu
Dec 28 08:45:51 2017
@@ -414,7 +414,9 @@ public final class TestXWPFParagraph {
         //CTMoveBookmarkImpl into ooxml-lite.
         XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Tika-792.docx");
         XWPFParagraph paragraph = doc.getParagraphs().get(0);
-        assertEquals("s", paragraph.getText());
+        assertEquals("", paragraph.getText());
+        paragraph = doc.getParagraphs().get(1);
+        assertEquals("b", paragraph.getText());
         doc.close();
     }
 
@@ -612,7 +614,19 @@ public final class TestXWPFParagraph {
         }
         assertEquals("This is a test.\n\n\n\n3\n4\n5\n\n\n\nThis is a whole paragraph where
one word is deleted.\n", str.toString());
     }
-    
+
+    @Test
+    public void test61787() throws IOException {
+        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("61787.docx");
+
+        StringBuilder str = new StringBuilder();
+        for(XWPFParagraph par : doc.getParagraphs()) {
+            str.append(par.getText()).append("\n");
+        }
+        String s = str.toString();
+        assertTrue("Having text: \n" + s + "\nTrimmed lenght: " + s.trim().length(), s.trim().length()
> 0);
+    }
+
     /**
      * Tests for numbered lists
      * 

Added: poi/trunk/test-data/document/61787.docx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/61787.docx?rev=1819405&view=auto
==============================================================================
Binary files poi/trunk/test-data/document/61787.docx (added) and poi/trunk/test-data/document/61787.docx
Thu Dec 28 08:45:51 2017 differ



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message