/** * if there is a corresponding {@link XWPFParagraph} of the parameter p in the paragraphList of this header or footer * the method will return that paragraph, otherwise the method will return null. * * @param p The CTP paragraph to find the corresponding {@link XWPFParagraph} for. * @return The {@link XWPFParagraph} that corresponds to the CTP paragraph in the paragraph * list of this footnote or null if no paragraph is found. * @see org.apache.poi.xwpf.usermodel.IBody#getParagraph(CTP p) */ public XWPFParagraph getParagraph(CTP p) { for (XWPFParagraph paragraph : paragraphs) { if (paragraph.getCTP().equals(p)) return paragraph; } return null; }
/** * if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this header or footer * the method will return this paragraph * if there is no corresponding {@link XWPFParagraph} the method will return null * * @param p is instance of CTP and is searching for an XWPFParagraph * @return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this header or footer * XWPFParagraph with the correspondig CTP p */ public XWPFParagraph getParagraph(CTP p) { for (XWPFParagraph paragraph : paragraphs) { if (paragraph.getCTP().equals(p)) return paragraph; } return null; }
/** * if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this table * the method will return this paragraph * if there is no corresponding {@link XWPFParagraph} the method will return null * * @param p is instance of CTP and is searching for an XWPFParagraph * @return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this table * XWPFParagraph with the correspondig CTP p */ public XWPFParagraph getParagraph(CTP p) { for (XWPFParagraph paragraph : paragraphs) { if (p.equals(paragraph.getCTP())) { return paragraph; } } return null; }
/** * copies content of a paragraph to a existing paragraph in the list paragraphs at position pos * * @param paragraph * @param pos */ public void setParagraph(XWPFParagraph paragraph, int pos) { paragraphs.set(pos, paragraph); ctDocument.getBody().setPArray(pos, paragraph.getCTP()); /* TODO update body element, update xwpf element, verify that * incoming paragraph belongs to this document or if not, XML was * copied properly (namespace-abbreviations, etc.) */ }
getCTP().removeR(rPos); return true;
/** * Removes a specific paragraph from this header / footer * * @param paragraph - {@link XWPFParagraph} object to remove */ public void removeParagraph(XWPFParagraph paragraph) { if (paragraphs.contains(paragraph)) { CTP ctP = paragraph.getCTP(); XmlCursor c = ctP.newCursor(); c.removeXml(); c.dispose(); paragraphs.remove(paragraph); bodyElements.remove(paragraph); } }
/** * get the paragraph with the CTP class p * * @param p * @return the paragraph with the CTP class p */ @Override public XWPFParagraph getParagraph(CTP p) { for (int i = 0; i < getParagraphs().size(); i++) { if (getParagraphs().get(i).getCTP() == p) { return getParagraphs().get(i); } } return null; }
public XWPFCommentsDecorator(XWPFParagraph paragraph, XWPFParagraphDecorator nextDecorator) { super(paragraph, nextDecorator); XWPFComment comment; commentText = new StringBuilder(64); for (CTMarkupRange anchor : paragraph.getCTP().getCommentRangeStartArray()) { if ((comment = paragraph.getDocument().getCommentByID(anchor.getId().toString())) != null) { commentText.append("\tComment by ") .append(comment.getAuthor()) .append(": ") .append(comment.getText()); } } }
public void setParagraph(XWPFParagraph p) { if (ctTc.sizeOfPArray() == 0) { ctTc.addNewP(); } ctTc.setPArray(0, p.getCTP()); }
for (int i = 0; i < paragraphs.length; i++) { ftr.setPArray(i, paragraphs[i].getCTP());
CTP ctp = paragraph.getCTP();
PackageRelationship relationship = paragraph.getDocument().getPackagePart() .addExternalRelationship(link, XWPFRelation.HYPERLINK.getRelation()); CTHyperlink hyperlink = paragraph.getCTP().insertNewHyperlink(pos); hyperlink.setId(relationship.getId()); CTR ctr = hyperlink.addNewR();
public XWPFHyperlinkRun createHyperLinkRun(String link) { PackageRelationship relationship = paragraph.getDocument().getPackagePart() .addExternalRelationship(link, XWPFRelation.HYPERLINK.getRelation()); CTHyperlink hyperlink = paragraph.getCTP().addNewHyperlink(); hyperlink.setId(relationship.getId()); CTR ctr = hyperlink.addNewR(); XWPFHyperlinkRun xwpfRun = new XWPFHyperlinkRun(hyperlink, ctr, (IRunBody) paragraph); getRuns().add(xwpfRun); getIRuns().add(xwpfRun); return xwpfRun; }
@Override public void render(ElementTemplate eleTemplate, Object data, XWPFTemplate template) { NiceXWPFDocument doc = template.getXWPFDocument(); RunTemplate runTemplate = (RunTemplate) eleTemplate; XWPFRun run = runTemplate.getRun(); run.setText("", 0); try { // w:tbl-w:tr-w:tc-w:p-w:tr XmlCursor newCursor = ((XWPFParagraph) run.getParent()).getCTP().newCursor(); newCursor.toParent(); newCursor.toParent(); newCursor.toParent(); XmlObject object = newCursor.getObject(); XWPFTable table = doc.getAllTable((CTTbl) object); render(table, data); } catch (Exception e) { logger.error("dynamic table error:" + e.getMessage(), e); } }
XmlCursor cursor = ((XWPFParagraph)run.getParent()).getCTP().newCursor();
public static void styleTableParagraph(XWPFParagraph par, TableStyle style) { if (null != par && null != style && null != style.getAlign()) { CTP ctp = par.getCTP(); CTPPr CTPpr = ctp.isSetPPr() ? ctp.getPPr() : ctp.addNewPPr(); CTJc jc = CTPpr.isSetJc() ? CTPpr.getJc() : CTPpr.addNewJc(); jc.setVal(style.getAlign()); } }
XmlCursor cursor = ((XWPFParagraph)run.getParent()).getCTP().newCursor(); if (isCursorInBody(cursor)) { String uri = CTP.type.getName().getNamespaceURI();
if (paragraph.getCTP().getPPr() != null) { CTSectPr ctSectPr = paragraph.getCTP().getPPr().getSectPr(); if (ctSectPr != null && config.getIncludeHeadersAndFooters()) { headerFooterPolicy = // (In future, we might put them in the right place, for now for (int i = 0; i < paragraph.getCTP().sizeOfBookmarkStartArray(); i++) { CTBookmark bookmark = paragraph.getCTP().getBookmarkStartArray(i); xhtml.startElement("a", "name", bookmark.getName()); xhtml.endElement("a"); //not just the immediate children of txbxContent -- TIKA-2807 if (config.getIncludeShapeBasedContent()) { for (XmlObject embeddedParagraph : paragraph.getCTP().selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' declare namespace wps='http://schemas.microsoft.com/office/word/2010/wordprocessingShape' .//*/wps:txbx/w:txbxContent//w:p")) { extractParagraph(new XWPFParagraph(CTP.Factory.parse(embeddedParagraph.xmlText()), paragraph.getBody()), listManager, xhtml);
paragraph = doc.insertNewParagraph(run); paragraph.setNumID(numID); CTP ctp = paragraph.getCTP(); CTPPr pPr = ctp.isSetPPr() ? ctp.getPPr() : ctp.addNewPPr(); CTParaRPr pr = pPr.isSetRPr() ? pPr.getRPr() : pPr.addNewRPr();