Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BE740200D68 for ; Thu, 28 Dec 2017 09:45:53 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id BCE84160C1F; Thu, 28 Dec 2017 08:45:53 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 104E7160C16 for ; Thu, 28 Dec 2017 09:45:52 +0100 (CET) Received: (qmail 93009 invoked by uid 500); 28 Dec 2017 08:45:52 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 93000 invoked by uid 99); 28 Dec 2017 08:45:52 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Dec 2017 08:45:52 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 900FA3A0184 for ; Thu, 28 Dec 2017 08:45:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@poi.apache.org From: centic@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20171228084551.900FA3A0184@svn01-us-west.apache.org> archived-at: Thu, 28 Dec 2017 08:45:53 -0000 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