insert the content of fldSimple fields into the XWPFWordTextExtractor output, see bug #49455

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@979538 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2010-07-27 05:19:15 +00:00
parent de13c1193c
commit 84811da73d
4 changed files with 18 additions and 0 deletions

View 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>

View 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++) {

View 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"));
}
}

BIN
test-data/document/FldSimple.docx Executable file

Binary file not shown.