Skip to content

Commit

Permalink
[github-114] Extend docx footnote support. Thanks to Eliot Kimber. This
Browse files Browse the repository at this point in the history
closes apache#114

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1836415 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
fanningpj committed Jul 21, 2018
1 parent 31533a7 commit abc7c87
Show file tree
Hide file tree
Showing 6 changed files with 451 additions and 41 deletions.
32 changes: 32 additions & 0 deletions src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Licensed to the Apache Software Foundation (ASF) under one or more
import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.ooxml.POIXMLProperties;
import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.ooxml.util.IdentifierManager;
import org.apache.poi.ooxml.util.PackageHelper;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.OPCPackage;
Expand Down Expand Up @@ -84,6 +86,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;

/**
* <p>High(ish) level class for working with .docx files.</p>
Expand Down Expand Up @@ -1653,4 +1656,33 @@ public XWPFChart createChart(int width, int height) throws InvalidFormatExceptio
charts.add(xwpfChart);
return xwpfChart;
}

/**
* Create a new footnote and add it to the document.
* <p>The new note will have one paragraph with the style "FootnoteText"
* and one run containing the required footnote reference with the
* style "FootnoteReference".
*
* @return New XWPFFootnote.
*/
public XWPFFootnote createFootnote() {
XWPFFootnotes footnotes = this.createFootnotes();

XWPFFootnote footnote = footnotes.createFootnote();
return footnote;
}

/**
* Remove the specified footnote if present.
*
* @param pos
* @return True if the footnote was removed.
*/
public boolean removeFootnote(int pos) {
if (null != footnotes) {
return footnotes.removeFootnote(pos);
} else {
return false;
}
}
}
Loading

0 comments on commit abc7c87

Please sign in to comment.