poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
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 GMT
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 @@
 
     <changes>
         <release version="3.7-beta2" date="2010-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">49446 - Don't consider 17.16.23
field codes as properly part of the paragraph's text</action>
            <action dev="POI-DEVELOPERS" type="fix">XSLFSlideShow shouldn't break on
.thmx (theme) files. Support for them is still very limited though</action>
         </release>
         <release version="3.7-beta1" date="2010-06-20">

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


Mime
View raw message