/** * Create a new footnote and add it to the document. * * @return New {@link XWPFFootnote} * @since 4.0.0 */ public XWPFFootnote createFootnote() { CTFtnEdn newNote = CTFtnEdn.Factory.newInstance(); newNote.setType(STFtnEdn.NORMAL); XWPFFootnote footnote = addFootnote(newNote); footnote.getCTFtnEdn().setId(getIdManager().nextId()); return footnote; }
public XWPFFootnote getFootnoteByID(int id) { if (footnotes == null) { return null; } return (XWPFFootnote)footnotes.getFootnoteById(id); }
public List<XWPFFootnote> getFootnotes() { if (footnotes == null) { return Collections.emptyList(); } return footnotes.getFootnotesList(); }
private void initFootnotes() throws XmlException, IOException { for (RelationPart rp : getRelationParts()) { POIXMLDocumentPart p = rp.getDocumentPart(); String relation = rp.getRelationship().getRelationshipType(); if (relation.equals(XWPFRelation.FOOTNOTE.getRelation())) { this.footnotes = (XWPFFootnotes) p; this.footnotes.onDocumentRead(); this.footnotes.setIdManager(footnoteIdManager); } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())) { this.endnotes = (XWPFEndnotes) p; this.endnotes.onDocumentRead(); this.endnotes.setIdManager(footnoteIdManager); } } }
/** * Creates an empty footnotes element for the document if one does not already exist * * @return footnotes */ public XWPFFootnotes createFootnotes() { if (footnotes == null) { FootnotesDocument footnotesDoc = FootnotesDocument.Factory.newInstance(); XWPFRelation relation = XWPFRelation.FOOTNOTE; int i = getRelationIndex(relation); XWPFFootnotes wrapper = (XWPFFootnotes) createRelationship(relation, XWPFFactory.getInstance(), i); wrapper.setFootnotes(footnotesDoc.addNewFootnotes()); wrapper.setIdManager(this.footnoteIdManager); footnotes = wrapper; } return footnotes; }
private void initFootnotes() throws XmlException, IOException { for(POIXMLDocumentPart p : getRelations()){ String relation = p.getPackageRelationship().getRelationshipType(); if (relation.equals(XWPFRelation.FOOTNOTE.getRelation())) { FootnotesDocument footnotesDocument = FootnotesDocument.Factory.parse(p.getPackagePart().getInputStream()); this.footnotes = (XWPFFootnotes)p; this.footnotes.onDocumentRead(); for(CTFtnEdn ctFtnEdn : footnotesDocument.getFootnotes().getFootnoteList()) { footnotes.addFootnote(ctFtnEdn); } } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())){ EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream()); for(CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteList()) { endnotes.put(ctFtnEdn.getId().intValue(), new XWPFFootnote(this, ctFtnEdn)); } } } }
@Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTFootnotes.type.getName().getNamespaceURI(), "footnotes")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctFootnotes.save(out, xmlOptions); out.close(); }
/** * Add a CTFtnEdn footnote to the document. * * @param note CTFtnEnd to be added. * @return New {@link XWPFFootnote} */ @Internal public XWPFFootnote addFootnote(CTFtnEdn note) { return footnotes.addFootnote(note); }
/** * Creates an empty footnotes element for the document if one does not already exist * @return footnotes */ public XWPFFootnotes createFootnotes() { if(footnotes == null) { FootnotesDocument footnotesDoc = FootnotesDocument.Factory.newInstance(); XWPFRelation relation = XWPFRelation.FOOTNOTE; int i = getRelationIndex(relation); XWPFFootnotes wrapper = (XWPFFootnotes)createRelationship(relation, XWPFFactory.getInstance(), i); wrapper.setFootnotes(footnotesDoc.addNewFootnotes()); footnotes = wrapper; } return footnotes; }
/** * Create a new footnote and add it to the document. * * @return New XWPFFootnote. * @since 4.0.0 */ public XWPFFootnote createFootnote() { XWPFFootnotes footnotes = this.createFootnotes(); XWPFFootnote footnote = footnotes.createFootnote(); return footnote; }
/** * Remove the specified footnote if present. * * @param pos Array position of the footnote to be removed. * @return True if the footnote was removed. * @since 4.0.0 */ public boolean removeFootnote(int pos) { if (null != footnotes) { return footnotes.removeFootnote(pos); } else { return false; } }
/** * Read document */ @Override protected void onDocumentRead() throws IOException { FootnotesDocument notesDoc; InputStream is = null; try { is = getPackagePart().getInputStream(); notesDoc = FootnotesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS); ctFootnotes = notesDoc.getFootnotes(); } catch (XmlException e) { throw new POIXMLException(); } finally { if (is != null) { is.close(); } } for (CTFtnEdn note : ctFootnotes.getFootnoteList()) { listFootnote.add(new XWPFFootnote(note, this)); } }
private void initFootnotes() throws XmlException, IOException { for (RelationPart rp : getRelationParts()) { POIXMLDocumentPart p = rp.getDocumentPart(); String relation = rp.getRelationship().getRelationshipType(); if (relation.equals(XWPFRelation.FOOTNOTE.getRelation())) { this.footnotes = (XWPFFootnotes) p; this.footnotes.onDocumentRead(); this.footnotes.setIdManager(footnoteIdManager); } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())) { this.endnotes = (XWPFEndnotes) p; this.endnotes.onDocumentRead(); this.endnotes.setIdManager(footnoteIdManager); } } }
/** * Creates an empty footnotes element for the document if one does not already exist * * @return footnotes */ public XWPFFootnotes createFootnotes() { if (footnotes == null) { FootnotesDocument footnotesDoc = FootnotesDocument.Factory.newInstance(); XWPFRelation relation = XWPFRelation.FOOTNOTE; int i = getRelationIndex(relation); XWPFFootnotes wrapper = (XWPFFootnotes) createRelationship(relation, XWPFFactory.getInstance(), i); wrapper.setFootnotes(footnotesDoc.addNewFootnotes()); wrapper.setIdManager(this.footnoteIdManager); footnotes = wrapper; } return footnotes; }
public XWPFFootnote addFootnote(CTFtnEdn note) { return footnotes.addFootnote(note); }
/** * Create a new footnote and add it to the document. * * @return New XWPFFootnote. * @since 4.0.0 */ public XWPFFootnote createFootnote() { XWPFFootnotes footnotes = this.createFootnotes(); XWPFFootnote footnote = footnotes.createFootnote(); return footnote; }
/** * Remove the specified footnote if present. * * @param pos Array position of the footnote to be removed. * @return True if the footnote was removed. * @since 4.0.0 */ public boolean removeFootnote(int pos) { if (null != footnotes) { return footnotes.removeFootnote(pos); } else { return false; } }
@Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTFootnotes.type.getName().getNamespaceURI(), "footnotes")); Map<String,String> map = new HashMap<String,String>(); map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r"); map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w"); xmlOptions.setSaveSuggestedPrefixes(map); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctFootnotes.save(out, xmlOptions); out.close(); }
/** * Create a new footnote and add it to the document. * * @return New {@link XWPFFootnote} * @since 4.0.0 */ public XWPFFootnote createFootnote() { CTFtnEdn newNote = CTFtnEdn.Factory.newInstance(); newNote.setType(STFtnEdn.NORMAL); XWPFFootnote footnote = addFootnote(newNote); footnote.getCTFtnEdn().setId(getIdManager().nextId()); return footnote; }
public XWPFFootnote getFootnoteByID(int id) { if (footnotes == null) { return null; } return (XWPFFootnote)footnotes.getFootnoteById(id); }