/** * Create a new end note and add it to the document. * * @return New XWPFEndnote * @since 4.0.0 */ public XWPFEndnote createEndnote() { CTFtnEdn newNote = CTFtnEdn.Factory.newInstance(); newNote.setType(STFtnEdn.NORMAL); XWPFEndnote footnote = addEndnote(newNote); footnote.getCTFtnEdn().setId(getIdManager().nextId()); return footnote; }
/** * Create a new end note and add it to the document. * * @return New {@link XWPFEndnote}. * @since 4.0.0 */ public XWPFEndnote createEndnote() { XWPFEndnotes endnotes = this.createEndnotes(); XWPFEndnote endnote = endnotes.createEndnote(); return endnote; }
/** * Gets the list of end notes for the document. * * @return List, possibly empty, of {@link XWPFEndnote}s. */ public List<XWPFEndnote> getEndnotes() { if (endnotes == null) { return Collections.emptyList(); } return endnotes.getEndnotesList(); }
public XWPFEndnotes createEndnotes() { if (endnotes == null) { EndnotesDocument endnotesDoc = EndnotesDocument.Factory.newInstance(); XWPFRelation relation = XWPFRelation.ENDNOTE; int i = getRelationIndex(relation); XWPFEndnotes wrapper = (XWPFEndnotes) createRelationship(relation, XWPFFactory.getInstance(), i); wrapper.setEndnotes(endnotesDoc.addNewEndnotes()); wrapper.setIdManager(footnoteIdManager); endnotes = wrapper; } return endnotes; }
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); } } }
@Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTEndnotes.type.getName().getNamespaceURI(), "endnotes")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctEndnotes.save(out, xmlOptions); out.close(); }
/** * Add a CTFtnEdn endnote to the document. * * @param note CTFtnEnd to be added. * @return New {@link XWPFEndnote} */ @Internal public XWPFEndnote addEndnote(CTFtnEdn note) { XWPFEndnote endnote = new XWPFEndnote(this, note); endnotes.addEndnote(note); return endnote; }
public XWPFEndnote getEndnoteByID(int id) { if (endnotes == null) { return null; } return endnotes.getFootnoteById(id); }
/** * Remove the specified end note if present. * * @param pos Array position of the end note to be removed. * @return True if the end note was removed. * @since 4.0.0 */ public boolean removeEndnote(int pos) { if (null != endnotes) { return endnotes.removeEndnote(pos); } else { return false; } }
public XWPFEndnotes createEndnotes() { if (endnotes == null) { EndnotesDocument endnotesDoc = EndnotesDocument.Factory.newInstance(); XWPFRelation relation = XWPFRelation.ENDNOTE; int i = getRelationIndex(relation); XWPFEndnotes wrapper = (XWPFEndnotes) createRelationship(relation, XWPFFactory.getInstance(), i); wrapper.setEndnotes(endnotesDoc.addNewEndnotes()); wrapper.setIdManager(footnoteIdManager); endnotes = wrapper; } return endnotes; }
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); } } }
/** * Read document */ @Override protected void onDocumentRead() throws IOException { EndnotesDocument notesDoc; InputStream is = null; try { is = getPackagePart().getInputStream(); notesDoc = EndnotesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS); ctEndnotes = notesDoc.getEndnotes(); } catch (XmlException e) { throw new POIXMLException(); } finally { if (is != null) { is.close(); } } for (CTFtnEdn note : ctEndnotes.getEndnoteList()) { listFootnote.add(new XWPFEndnote(note, this)); } }
/** * Add a CTFtnEdn endnote to the document. * * @param note CTFtnEnd to be added. * @return New {@link XWPFEndnote} */ @Internal public XWPFEndnote addEndnote(CTFtnEdn note) { XWPFEndnote endnote = new XWPFEndnote(this, note); endnotes.addEndnote(note); return endnote; }
public XWPFEndnote getEndnoteByID(int id) { if (endnotes == null) { return null; } return endnotes.getFootnoteById(id); }
/** * Remove the specified end note if present. * * @param pos Array position of the end note to be removed. * @return True if the end note was removed. * @since 4.0.0 */ public boolean removeEndnote(int pos) { if (null != endnotes) { return endnotes.removeEndnote(pos); } else { return false; } }
/** * Create a new end note and add it to the document. * * @return New XWPFEndnote * @since 4.0.0 */ public XWPFEndnote createEndnote() { CTFtnEdn newNote = CTFtnEdn.Factory.newInstance(); newNote.setType(STFtnEdn.NORMAL); XWPFEndnote footnote = addEndnote(newNote); footnote.getCTFtnEdn().setId(getIdManager().nextId()); return footnote; }
@Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTEndnotes.type.getName().getNamespaceURI(), "endnotes")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctEndnotes.save(out, xmlOptions); out.close(); }
/** * Gets the list of end notes for the document. * * @return List, possibly empty, of {@link XWPFEndnote}s. */ public List<XWPFEndnote> getEndnotes() { if (endnotes == null) { return Collections.emptyList(); } return endnotes.getEndnotesList(); }
/** * Create a new end note and add it to the document. * * @return New {@link XWPFEndnote}. * @since 4.0.0 */ public XWPFEndnote createEndnote() { XWPFEndnotes endnotes = this.createEndnotes(); XWPFEndnote endnote = endnotes.createEndnote(); return endnote; }
/** * Read document */ @Override protected void onDocumentRead() throws IOException { EndnotesDocument notesDoc; InputStream is = null; try { is = getPackagePart().getInputStream(); notesDoc = EndnotesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS); ctEndnotes = notesDoc.getEndnotes(); } catch (XmlException e) { throw new POIXMLException(); } finally { if (is != null) { is.close(); } } for (CTFtnEdn note : ctEndnotes.getEndnoteList()) { listFootnote.add(new XWPFEndnote(note, this)); } }