aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2018-07-24 09:46:44 +0000
committerPJ Fanning <fanningpj@apache.org>2018-07-24 09:46:44 +0000
commit4adebdbe1cd9cb1decbba84ec1f04211ffffdab4 (patch)
treea0bb232f3240de0c4c04a0ef918e724330ec003f /src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
parent93427725762663da8f2865706abbf21ecbbfaf68 (diff)
downloadpoi-4adebdbe1cd9cb1decbba84ec1f04211ffffdab4.tar.gz
poi-4adebdbe1cd9cb1decbba84ec1f04211ffffdab4.zip
[github-115] implement endnote. This closes #115
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1836538 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java')
-rw-r--r--src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java30
1 files changed, 19 insertions, 11 deletions
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 661e1c1abe..5fbc7a5225 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
@@ -76,21 +76,24 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
if (o instanceof CTFtnEdnRef) {
CTFtnEdnRef ftn = (CTFtnEdnRef) o;
footnoteText.append(" [").append(ftn.getId()).append(": ");
- XWPFFootnote footnote =
+ AbstractXWPFFootnoteEndnote footnote =
ftn.getDomNode().getLocalName().equals("footnoteReference") ?
document.getFootnoteByID(ftn.getId().intValue()) :
document.getEndnoteByID(ftn.getId().intValue());
-
- boolean first = true;
- for (XWPFParagraph p : footnote.getParagraphs()) {
- if (!first) {
- footnoteText.append("\n");
+ if (null != footnote) {
+ boolean first = true;
+ for (XWPFParagraph p : footnote.getParagraphs()) {
+ if (!first) {
+ footnoteText.append("\n");
+ }
+ first = false;
+ footnoteText.append(p.getText());
}
- first = false;
- footnoteText.append(p.getText());
+ } else {
+ footnoteText.append("!!! End note with ID \"" + ftn.getId() + "\" not found in document.");
}
-
footnoteText.append("] ");
+
}
}
c.dispose();
@@ -1674,11 +1677,16 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
* The footnote reference run will have the style name "FootnoteReference".
*
* @param footnote Footnote to which to add a reference.
+ * @since 4.0.0
*/
- public void addFootnoteReference(XWPFFootnote footnote) {
+ public void addFootnoteReference(AbstractXWPFFootnoteEndnote footnote) {
XWPFRun run = createRun();
CTR ctRun = run.getCTR();
ctRun.addNewRPr().addNewRStyle().setVal("FootnoteReference");
- ctRun.addNewFootnoteReference().setId(footnote.getId());
+ if (footnote instanceof XWPFEndnote) {
+ ctRun.addNewEndnoteReference().setId(footnote.getId());
+ } else {
+ ctRun.addNewFootnoteReference().setId(footnote.getId());
+ }
}
}