Patch from akhikhl from github pull #3 - Extract references from XWPF footnotes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1492308 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b80a40bc13
commit
8185178ad3
@ -52,6 +52,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor;
|
|||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTEmpty;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTEmpty;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts;
|
||||||
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdnRef;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHpsMeasure;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHpsMeasure;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPTab;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPTab;
|
||||||
@ -817,6 +818,12 @@ public class XWPFRun {
|
|||||||
text.append("\n");
|
text.append("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (o instanceof CTFtnEdnRef) {
|
||||||
|
CTFtnEdnRef ftn = (CTFtnEdnRef)o;
|
||||||
|
String footnoteRef = ftn.getDomNode().getLocalName().equals("footnoteReference") ?
|
||||||
|
"[footnoteRef:" + ftn.getId().intValue() + "]" : "[endnoteRef:" + ftn.getId().intValue() + "]";
|
||||||
|
text.append(footnoteRef);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.dispose();
|
c.dispose();
|
||||||
|
@ -166,8 +166,9 @@ public class TestXWPFWordExtractor extends TestCase {
|
|||||||
public void testFootnotes() throws IOException {
|
public void testFootnotes() throws IOException {
|
||||||
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("footnotes.docx");
|
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("footnotes.docx");
|
||||||
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
|
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
|
||||||
|
String text = extractor.getText();
|
||||||
assertTrue(extractor.getText().contains("snoska"));
|
assertTrue(text.contains("snoska"));
|
||||||
|
assertTrue(text.contains("Eto ochen prostoy[footnoteRef:1] text so snoskoy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -190,8 +191,9 @@ public class TestXWPFWordExtractor extends TestCase {
|
|||||||
public void testEndnotes() throws IOException {
|
public void testEndnotes() throws IOException {
|
||||||
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("endnotes.docx");
|
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("endnotes.docx");
|
||||||
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
|
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
|
||||||
|
String text = extractor.getText();
|
||||||
assertTrue(extractor.getText().contains("XXX"));
|
assertTrue(text.contains("XXX"));
|
||||||
|
assertTrue(text.contains("tilaka [endnoteRef:2]or 'tika'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInsertedDeletedText() throws IOException {
|
public void testInsertedDeletedText() throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user