Search in sources :

Example 1 with CTFtnEdn

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn in project poi by apache.

the class TestXWPFFootnotes method testAddFootnotesToDocument.

public void testAddFootnotesToDocument() throws IOException {
    XWPFDocument docOut = new XWPFDocument();
    BigInteger noteId = BigInteger.valueOf(1);
    XWPFFootnotes footnotes = docOut.createFootnotes();
    CTFtnEdn ctNote = CTFtnEdn.Factory.newInstance();
    ctNote.setId(noteId);
    ctNote.setType(STFtnEdn.NORMAL);
    footnotes.addFootnote(ctNote);
    XWPFDocument docIn = XWPFTestDataSamples.writeOutAndReadBack(docOut);
    XWPFFootnote note = docIn.getFootnoteByID(noteId.intValue());
    assertEquals(note.getCTFtnEdn().getType(), STFtnEdn.NORMAL);
}
Also used : CTFtnEdn(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn) BigInteger(java.math.BigInteger)

Example 2 with CTFtnEdn

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn in project poi by apache.

the class XWPFFootnotes method onDocumentRead.

/**
     * 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();
        }
    }
    // Find our footnotes
    for (CTFtnEdn note : ctFootnotes.getFootnoteArray()) {
        listFootnote.add(new XWPFFootnote(note, this));
    }
}
Also used : CTFtnEdn(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn) InputStream(java.io.InputStream) XmlException(org.apache.xmlbeans.XmlException) FootnotesDocument(org.openxmlformats.schemas.wordprocessingml.x2006.main.FootnotesDocument) POIXMLException(org.apache.poi.POIXMLException)

Example 3 with CTFtnEdn

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn in project poi by apache.

the class XWPFFootnotes method addFootnote.

/**
     * add a footnote to the document
     *
     * @param note
     * @throws IOException
     */
public XWPFFootnote addFootnote(CTFtnEdn note) {
    CTFtnEdn newNote = ctFootnotes.addNewFootnote();
    newNote.set(note);
    XWPFFootnote xNote = new XWPFFootnote(newNote, this);
    listFootnote.add(xNote);
    return xNote;
}
Also used : CTFtnEdn(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn)

Aggregations

CTFtnEdn (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn)3 InputStream (java.io.InputStream)1 BigInteger (java.math.BigInteger)1 POIXMLException (org.apache.poi.POIXMLException)1 XmlException (org.apache.xmlbeans.XmlException)1 FootnotesDocument (org.openxmlformats.schemas.wordprocessingml.x2006.main.FootnotesDocument)1