diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java index 282fca6d1..d6bc531bf 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java @@ -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.CTEmpty; 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.CTOnOff; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPTab; @@ -817,6 +818,12 @@ public class XWPFRun { 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(); 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 46188f5ed..34d20aae7 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java @@ -166,8 +166,9 @@ public class TestXWPFWordExtractor extends TestCase { public void testFootnotes() throws IOException { XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("footnotes.docx"); XWPFWordExtractor extractor = new XWPFWordExtractor(doc); - - assertTrue(extractor.getText().contains("snoska")); + String text = extractor.getText(); + 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 { XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("endnotes.docx"); XWPFWordExtractor extractor = new XWPFWordExtractor(doc); - - assertTrue(extractor.getText().contains("XXX")); + String text = extractor.getText(); + assertTrue(text.contains("XXX")); + assertTrue(text.contains("tilaka [endnoteRef:2]or 'tika'")); } public void testInsertedDeletedText() throws IOException {