diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 043a23cd07..e2a5d1dae9 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 49455 - Insert the content of fldSimple fields into the XWPFWordTextExtractor output 49640 - Fixed parsing formulas containing defined names beginning with an underscore 49538 - Added implementation for POISSON() 49524 - Support for setting cell text to be vertically rotated, via style.setRotation(0xff) diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java index fed5b097d8..57e1a6467c 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java @@ -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++) { diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java index 2277ecec9d..5b47b6d0b1 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java @@ -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 index 0000000000..029016ce07 Binary files /dev/null and b/test-data/document/FldSimple.docx differ