View | Details | Raw Unified | Return to bug 47571
Collapse All | Expand All

(-)a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java (-9 / +11 lines)
Lines 18-23 package org.apache.poi.xwpf.usermodel; Link Here
18
18
19
import java.math.BigInteger;
19
import java.math.BigInteger;
20
import java.util.ArrayList;
20
import java.util.ArrayList;
21
import java.util.Arrays;
21
22
22
import org.apache.xmlbeans.XmlCursor;
23
import org.apache.xmlbeans.XmlCursor;
23
import org.apache.xmlbeans.XmlObject;
24
import org.apache.xmlbeans.XmlObject;
Lines 56-78 public class XWPFParagraph { Link Here
56
            // TODO - replace this with some sort of XPath expression
57
            // TODO - replace this with some sort of XPath expression
57
            // to directly find all the CTRs, in the right order
58
            // to directly find all the CTRs, in the right order
58
            ArrayList<CTR> rs = new ArrayList<CTR>();
59
            ArrayList<CTR> rs = new ArrayList<CTR>();
59
            CTR[] tmp;
60
60
61
            // Get the main text runs
61
            // Get the main text runs
62
            tmp = paragraph.getRArray();
62
            rs.addAll(Arrays.asList(paragraph.getRArray()));
63
            for (int i = 0; i < tmp.length; i++) {
64
                rs.add(tmp[i]);
65
            }
66
63
67
            // Not sure quite what these are, but they hold
64
            // Not sure quite what these are, but they hold
68
            // more text runs
65
            // more text runs
69
            CTSdtRun[] sdts = paragraph.getSdtArray();
66
            CTSdtRun[] sdts = paragraph.getSdtArray();
70
            for (int i = 0; i < sdts.length; i++) {
67
            for (int i = 0; i < sdts.length; i++) {
71
                CTSdtContentRun run = sdts[i].getSdtContent();
68
                CTSdtContentRun run = sdts[i].getSdtContent();
72
                tmp = run.getRArray();
69
                rs.addAll(Arrays.asList(run.getRArray()));
73
                for (int j = 0; j < tmp.length; j++) {
70
            }
74
                    rs.add(tmp[j]);
71
75
                }
72
            for (CTRunTrackChange c : paragraph.getDelArray()) {
73
                rs.addAll(Arrays.asList(c.getRArray()));
74
            }
75
76
            for (CTRunTrackChange c : paragraph.getInsArray()) {
77
                rs.addAll(Arrays.asList(c.getRArray()));
76
            }
78
            }
77
79
78
            // Get text of the paragraph
80
            // Get text of the paragraph
(-)a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java (+7 lines)
Lines 191-196 public class TestXWPFWordExtractor extends TestCase { Link Here
191
        assertTrue(extractor.getText().contains("XXX"));
191
        assertTrue(extractor.getText().contains("XXX"));
192
    }
192
    }
193
193
194
    public void testInsertedDeletedText() throws Exception {
195
        XWPFDocument doc = open("delins.docx");
196
        XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
197
198
        assertTrue(extractor.getText().contains("pendant worn"));
199
        assertTrue(extractor.getText().contains("extremely well"));
200
    }
194
201
195
    //TODO use the same logic for opening test files as in HSSFTestDataSamples
202
    //TODO use the same logic for opening test files as in HSSFTestDataSamples
196
    private XWPFDocument open(String sampleFileName) throws IOException {
203
    private XWPFDocument open(String sampleFileName) throws IOException {

Return to bug 47571