Return-Path: Delivered-To: apmail-poi-commits-archive@minotaur.apache.org Received: (qmail 78386 invoked from network); 29 Jun 2010 13:39:22 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Jun 2010 13:39:22 -0000 Received: (qmail 42503 invoked by uid 500); 29 Jun 2010 13:39:22 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 42467 invoked by uid 500); 29 Jun 2010 13:39:21 -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 42460 invoked by uid 99); 29 Jun 2010 13:39:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jun 2010 13:39:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jun 2010 13:39:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4338C23888D2; Tue, 29 Jun 2010 13:38:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r958965 - in /poi/trunk: src/documentation/content/xdocs/status.xml src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java test-data/document/FieldCodes.docx Date: Tue, 29 Jun 2010 13:38:25 -0000 To: commits@poi.apache.org From: nick@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100629133825.4338C23888D2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: nick Date: Tue Jun 29 13:38:24 2010 New Revision: 958965 URL: http://svn.apache.org/viewvc?rev=958965&view=rev Log: Fix bug #49446 - Don't consider 17.16.23 field codes as properly part of the paragraph's text Added: poi/trunk/test-data/document/FieldCodes.docx (with props) Modified: poi/trunk/src/documentation/content/xdocs/status.xml poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java Modified: poi/trunk/src/documentation/content/xdocs/status.xml URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=958965&r1=958964&r2=958965&view=diff ============================================================================== --- poi/trunk/src/documentation/content/xdocs/status.xml (original) +++ poi/trunk/src/documentation/content/xdocs/status.xml Tue Jun 29 13:38:24 2010 @@ -34,6 +34,7 @@ + 49446 - Don't consider 17.16.23 field codes as properly part of the paragraph's text XSLFSlideShow shouldn't break on .thmx (theme) files. Support for them is still very limited though 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=958965&r1=958964&r2=958965&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 Tue Jun 29 13:38:24 2010 @@ -133,7 +133,13 @@ public class XWPFParagraph implements IB while (c.toNextSelection()) { XmlObject o = c.getObject(); if (o instanceof CTText) { - text.append(((CTText) o).getStringValue()); + String tagName = o.getDomNode().getNodeName(); + // Field Codes (w:instrText, defined in spec sec. 17.16.23) + // come up as instances of CTText, but we don't want them + // in the normal text output + if (!"w:instrText".equals(tagName)) { + text.append(((CTText) o).getStringValue()); + } } if (o instanceof CTPTab) { text.append("\t"); Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java?rev=958965&r1=958964&r2=958965&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java Tue Jun 29 13:38:24 2010 @@ -237,4 +237,17 @@ public class TestXWPFWordExtractor exten // Now check the first paragraph in total assertTrue(extractor.getText().contains("a\tb\n")); } + + /** + * The output should not contain field codes, e.g. those specified in the + * w:instrText tag (spec sec. 17.16.23) + */ + public void testNoFieldCodes() { + XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("FieldCodes.docx"); + XWPFWordExtractor extractor = new XWPFWordExtractor(doc); + String text = extractor.getText(); + assertTrue(text.length() > 0); + assertFalse(text.contains("AUTHOR")); + assertFalse(text.contains("CREATEDATE")); + } } Added: poi/trunk/test-data/document/FieldCodes.docx URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/FieldCodes.docx?rev=958965&view=auto ============================================================================== Binary file - no diff available. Propchange: poi/trunk/test-data/document/FieldCodes.docx ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org