/** * Add a new {@link XWPFParagraph} to the end of the footnote. * * @param paragraph CTP paragraph from which to construct the {@link XWPFParagraph} * @return The added {@link XWPFParagraph} */ public XWPFParagraph addNewParagraph(CTP paragraph) { CTP newPara = ctFtnEdn.addNewP(); newPara.set(paragraph); XWPFParagraph xPara = new XWPFParagraph(newPara, this); paragraphs.add(xPara); return xPara; }
/** * Appends a new {@link XWPFTable} to this footnote * @param rows Number of rows to initialize the table with * @param cols Number of columns to initialize the table with * @return the new {@link XWPFTable} with the specified number of rows and columns * @since 4.0.0 */ public XWPFTable createTable(int rows, int cols) { XWPFTable table = new XWPFTable(ctFtnEdn.addNewTbl(), this, rows, cols); bodyElements.add(table); tables.add(table); return table; }
/** * Get the ID of the footnote. * <p>Footnote IDs are unique across all bottom-of-the-page and * end note footnotes.</p> * * @return Footnote ID * @since 4.0.0 */ public BigInteger getId() { return this.ctFtnEdn.getId(); }
/** * 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; }
CTFtnEdn ctfInstance = CTFtnEdn.Factory.newInstance(); BigInteger id = new BigInteger("1"); ctfInstance.setId(id); CTP ctp = ctfInstance.addNewP(); ctp.addNewPPr().addNewPStyle().setVal("FootnoteText"); CTR ctr = ctp.addNewR(); ctr.addNewRPr().addNewRStyle().setVal("FootnoteReference"); ctr.addNewFootnoteRef(); CTText cttext = ctp.addNewR().addNewT(); cttext.setStringValue("This is the text in the footnote"); cttext.setSpace(SpaceAttribute.Space.PRESERVE);
/** * add an {@link XWPFEndnote} to the document * * @param endnote * @throws IOException */ public void addEndnote(XWPFEndnote endnote) { listFootnote.add(endnote); ctEndnotes.addNewEndnote().set(endnote.getCTFtnEdn()); }
/** * inserts an existing XWPFTable to the arrays bodyElements and tables * @param pos * @param table * @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int pos, XWPFTable table) */ public void insertTable(int pos, XWPFTable table) { bodyElements.add(pos, table); int i; for (i = 0; i < ctFtnEdn.getTblList().size(); i++) { CTTbl tbl = ctFtnEdn.getTblArray(i); if(tbl == table.getCTTbl()){ break; } } tables.add(i, table); }
/** * Inserts an existing {@link XWPFTable) into the arrays bodyElements and tables. * * @param pos Position, in the bodyElements array, to insert the table * @param table {@link XWPFTable) to be inserted * @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int pos, XWPFTable table) */ public void insertTable(int pos, XWPFTable table) { bodyElements.add(pos, table); int i = 0; for (CTTbl tbl : ctFtnEdn.getTblList()) { if (tbl == table.getCTTbl()) { break; } i++; } tables.add(i, table); }
protected void init() { XmlCursor cursor = ctFtnEdn.newCursor(); //copied from XWPFDocument...should centralize this code //to avoid duplication cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject(); if (o instanceof CTP) { XWPFParagraph p = new XWPFParagraph((CTP) o, this); bodyElements.add(p); paragraphs.add(p); } else if (o instanceof CTTbl) { XWPFTable t = new XWPFTable((CTTbl) o, this); bodyElements.add(t); tables.add(t); } else if (o instanceof CTSdtBlock) { XWPFSDT c = new XWPFSDT((CTSdtBlock) o, this); bodyElements.add(c); } } cursor.dispose(); }
/** * 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; }
/** * Add an {@link XWPFFootnote} to the document * * @param footnote Footnote to add * @throws IOException */ public void addFootnote(XWPFFootnote footnote) { listFootnote.add(footnote); ctFootnotes.addNewFootnote().set(footnote.getCTFtnEdn()); }
/** * Inserts an existing {@link XWPFTable) into the arrays bodyElements and tables. * * @param pos Position, in the bodyElements array, to insert the table * @param table {@link XWPFTable) to be inserted * @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int pos, XWPFTable table) */ public void insertTable(int pos, XWPFTable table) { bodyElements.add(pos, table); int i = 0; for (CTTbl tbl : ctFtnEdn.getTblList()) { if (tbl == table.getCTTbl()) { break; } i++; } tables.add(i, table); }
protected void init() { XmlCursor cursor = ctFtnEdn.newCursor(); //copied from XWPFDocument...should centralize this code //to avoid duplication cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject(); if (o instanceof CTP) { XWPFParagraph p = new XWPFParagraph((CTP) o, this); bodyElements.add(p); paragraphs.add(p); } else if (o instanceof CTTbl) { XWPFTable t = new XWPFTable((CTTbl) o, this); bodyElements.add(t); tables.add(t); } else if (o instanceof CTSdtBlock) { XWPFSDT c = new XWPFSDT((CTSdtBlock) o, this); bodyElements.add(c); } } cursor.dispose(); }
/** * 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; }
/** * Add a CT footnote to the document * * @param note CTFtnEdn to add. * @throws IOException */ @Internal public XWPFFootnote addFootnote(CTFtnEdn note) { CTFtnEdn newNote = ctFootnotes.addNewFootnote(); newNote.set(note); XWPFFootnote xNote = new XWPFFootnote(newNote, this); listFootnote.add(xNote); return xNote; }
/** * Appends a new {@link XWPFParagraph} to this footnote. * * @return The new {@link XWPFParagraph} * @since 4.0.0 */ public XWPFParagraph createParagraph() { XWPFParagraph p = new XWPFParagraph(this.ctFtnEdn.addNewP(), this); paragraphs.add(p); bodyElements.add(p); // If the paragraph is the first paragraph in the footnote, // ensure that it has a footnote reference run. if (p.equals(getParagraphs().get(0))) { ensureFootnoteRef(p); } return p; }
public XWPFAbstractFootnoteEndnote getFootnoteById(int id) { for (XWPFAbstractFootnoteEndnote note : listFootnote) { if (note.getCTFtnEdn().getId().intValue() == id) return note; } return null; }
/** * Add a new {@link XWPFTable} to the end of the footnote. * * @param table CTTbl object from which to construct the {@link XWPFTable} * @return The added {@link XWPFTable} */ public XWPFTable addNewTbl(CTTbl table) { CTTbl newTable = ctFtnEdn.addNewTbl(); newTable.set(table); XWPFTable xTable = new XWPFTable(newTable, this); tables.add(xTable); return xTable; }
/** * 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; }