]> source.dussan.org Git - poi.git/commitdiff
insert the content of fldSimple fields into the XWPFWordTextExtractor output, see...
authorYegor Kozlov <yegor@apache.org>
Tue, 27 Jul 2010 05:19:15 +0000 (05:19 +0000)
committerYegor Kozlov <yegor@apache.org>
Tue, 27 Jul 2010 05:19:15 +0000 (05:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@979538 13f79535-47bb-0310-9956-ffa450edef68

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/FldSimple.docx [new file with mode: 0755]

index 043a23cd07513c76e12a0021f70dc3e7a612dbd4..e2a5d1dae95aa004b8cc7399398364f13a422f08 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.7-beta2" date="2010-??-??">
+           <action dev="POI-DEVELOPERS" type="add">49455 - Insert the content of fldSimple fields into the XWPFWordTextExtractor output</action>
            <action dev="POI-DEVELOPERS" type="add">49640 - Fixed parsing formulas containing defined names beginning with an underscore</action>
            <action dev="POI-DEVELOPERS" type="add">49538 - Added implementation for POISSON()</action>
            <action dev="POI-DEVELOPERS" type="add">49524 - Support for setting cell text to be vertically rotated, via style.setRotation(0xff)</action>
index fed5b097d8889f8b81cd341f90dd08c91810a1c0..57e1a6467c7f13e3ff1cb9dde6a6b119995ee3f2 100644 (file)
@@ -20,6 +20,7 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Arrays;
 
 import org.apache.poi.util.Internal;
 import org.apache.xmlbeans.XmlCursor;
@@ -41,6 +42,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRunTrackChange;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentRun;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRun;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSimpleField;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSpacing;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
@@ -119,6 +121,9 @@ public class XWPFParagraph implements IBodyElement{
       for (CTRunTrackChange c : paragraph.getInsList()) {
           rs.addAll( c.getRList() );
       }
+      for (CTSimpleField f : paragraph.getFldSimpleList()) {
+         rs.addAll( f.getRList() );
+      }
 
       // Get text of the paragraph
       for (int j = 0; j < rs.size(); j++) {
index 2277ecec9d8cd4a797f8a1365f8251eb3bcbfbf3..5b47b6d0b15cae8874ea5750bf7258f04ebd76b5 100644 (file)
@@ -250,4 +250,16 @@ public class TestXWPFWordExtractor extends TestCase {
         assertFalse(text.contains("AUTHOR"));
         assertFalse(text.contains("CREATEDATE"));
     }
+    
+    /**
+     * The output should contain the values of simple fields, those specified
+     * with the fldSimple element (spec sec. 17.16.19)
+     */
+    public void testFldSimpleContent() {
+        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("FldSimple.docx");
+        XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
+        String text = extractor.getText();
+        assertTrue(text.length() > 0);
+        assertTrue(text.contains("FldSimple.docx"));
+    }
 }
diff --git a/test-data/document/FldSimple.docx b/test-data/document/FldSimple.docx
new file mode 100755 (executable)
index 0000000..029016c
Binary files /dev/null and b/test-data/document/FldSimple.docx differ