/** * Adds a new paragraph at the end of the header or footer * * @return new {@link XWPFParagraph} object */ public XWPFParagraph createParagraph() { XWPFParagraph paragraph = new XWPFParagraph(headerFooter.addNewP(), this); paragraphs.add(paragraph); bodyElements.add(paragraph); return paragraph; }
/** * Appends a new paragraph to this document * * @return a new paragraph */ public XWPFParagraph createParagraph() { XWPFParagraph p = new XWPFParagraph(ctDocument.getBody().addNewP(), this); bodyElements.add(p); paragraphs.add(p); return p; }
/** * 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; }
/** * Add a Paragraph to this Table Cell * * @return The paragraph which was added */ public XWPFParagraph addParagraph() { XWPFParagraph p = new XWPFParagraph(ctTc.addNewP(), this); addParagraph(p); return p; }
/** * 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 XWPFComment(CTComment comment, XWPFDocument document) { text = new StringBuilder(64); id = comment.getId().toString(); author = comment.getAuthor(); for (CTP ctp : comment.getPArray()) { XWPFParagraph p = new XWPFParagraph(ctp, document); text.append(p.getText()); } }
public void readHdrFtr() { bodyElements = new ArrayList<>(); paragraphs = new ArrayList<>(); tables = new ArrayList<>(); // parse the document with cursor and add // the XmlObject to its lists XmlCursor cursor = headerFooter.newCursor(); cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject(); if (o instanceof CTP) { XWPFParagraph p = new XWPFParagraph((CTP) o, this); paragraphs.add(p); bodyElements.add(p); } if (o instanceof CTTbl) { XWPFTable t = new XWPFTable((CTTbl) o, this); tables.add(t); bodyElements.add(t); } } cursor.dispose(); }
public XWPFTable(CTTbl table, IBody part) { this.part = part; this.ctTbl = table; // is an empty table: I add one row and one column as default if (table.sizeOfTrArray() == 0) { createEmptyTable(table); } for (CTRow row : table.getTrList()) { StringBuilder rowText = new StringBuilder(); XWPFTableRow tabRow = new XWPFTableRow(row, this); tableRows.add(tabRow); for (CTTc cell : row.getTcList()) { for (CTP ctp : cell.getPList()) { XWPFParagraph p = new XWPFParagraph(ctp, part); if (rowText.length() > 0) { rowText.append('\t'); } rowText.append(p.getText()); } } if (rowText.length() > 0) { this.text.append(rowText); this.text.append('\n'); } } }
public XWPFFooter(XWPFDocument doc, CTHdrFtr hdrFtr) throws IOException { super(doc, hdrFtr); XmlCursor cursor = headerFooter.newCursor(); cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject(); if (o instanceof CTP) { XWPFParagraph p = new XWPFParagraph((CTP) o, this); paragraphs.add(p); bodyElements.add(p); } if (o instanceof CTTbl) { XWPFTable t = new XWPFTable((CTTbl) o, this); tables.add(t); bodyElements.add(t); } } cursor.dispose(); }
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(); }
public XWPFHeader(XWPFDocument doc, CTHdrFtr hdrFtr) { super(doc, hdrFtr); XmlCursor cursor = headerFooter.newCursor(); cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject(); if (o instanceof CTP) { XWPFParagraph p = new XWPFParagraph((CTP) o, this); paragraphs.add(p); } if (o instanceof CTTbl) { XWPFTable t = new XWPFTable((CTTbl) o, this); tables.add(t); } } cursor.dispose(); }
public void setText(String text) { CTP ctP = (ctTc.sizeOfPArray() == 0) ? ctTc.addNewP() : ctTc.getPArray(0); XWPFParagraph par = new XWPFParagraph(ctP, this); par.createRun().setText(text); }
public XWPFSDTContent(CTSdtContentBlock block, IBody part, IRunBody parent) { if (block == null) { return; } XmlCursor cursor = block.newCursor(); cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject(); if (o instanceof CTP) { XWPFParagraph p = new XWPFParagraph((CTP) o, part); bodyElements.add(p); // paragraphs.add(p); } else if (o instanceof CTTbl) { XWPFTable t = new XWPFTable((CTTbl) o, part); bodyElements.add(t); // tables.add(t); } else if (o instanceof CTSdtBlock) { XWPFSDT c = new XWPFSDT(((CTSdtBlock) o), part); bodyElements.add(c); // contentControls.add(c); } else if (o instanceof CTR) { XWPFRun run = new XWPFRun((CTR) o, parent); // runs.add(run); bodyElements.add(run); } } cursor.dispose(); }
XmlObject o = cursor.getObject(); if (o instanceof CTP) { XWPFParagraph p = new XWPFParagraph((CTP) o, this); paragraphs.add(p); bodyElements.add(p);
XmlObject o = cursor.getObject(); if (o instanceof CTP) { XWPFParagraph p = new XWPFParagraph((CTP) o, this); paragraphs.add(p); bodyElements.add(p);
XmlObject o = cursor.getObject(); if (o instanceof CTP) { XWPFParagraph p = new XWPFParagraph((CTP) o, this); paragraphs.add(p); bodyElements.add(p);
cursor.toParent(); CTP p = (CTP) cursor.getObject(); XWPFParagraph newP = new XWPFParagraph(p, this); XmlObject o = null; while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
cursor.toParent(); CTP p = (CTP) cursor.getObject(); XWPFParagraph newP = new XWPFParagraph(p, this); XmlObject o = null; while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
cursor.toParent(); CTP p = (CTP) cursor.getObject(); XWPFParagraph newP = new XWPFParagraph(p, this); XmlObject o = null; while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
pict.set(group); return new XWPFParagraph(p, doc);