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(); }
/** * @return the phonetic (ruby) string associated with this run or an empty String if none exists */ public String getPhonetic() { StringBuilder text = new StringBuilder(64); // Grab the text and tabs of the text run // Do so in a way that preserves the ordering XmlCursor c = run.newCursor(); c.selectPath("./*"); while (c.toNextSelection()) { XmlObject o = c.getObject(); if (o instanceof CTRuby) { handleRuby(o, text, true); } } // Any picture text? if (pictureText != null && pictureText.length() > 0) { text.append("\n").append(pictureText).append("\n"); } c.dispose(); return text.toString(); }
private boolean hasOleLink(XmlObject shape) { QName uriName = new QName(null, "uri"); String xquery = "declare namespace a='" + XSSFRelation.NS_DRAWINGML + "' .//a:extLst/a:ext"; XmlCursor cur = shape.newCursor(); cur.selectPath(xquery); try { while (cur.toNextSelection()) { String uri = cur.getAttributeText(uriName); if ("{63B3BB69-23CF-44E3-9099-C40C66FF867C}".equals(uri)) { return true; } } } finally { cur.dispose(); } return false; }
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 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(); }
/** * Returns the string version of the text, with tabs and * carriage returns in place of their xml equivalents. */ @Override public String text() { StringBuilder text = new StringBuilder(64); // Grab the text and tabs of the text run // Do so in a way that preserves the ordering XmlCursor c = run.newCursor(); c.selectPath("./*"); while (c.toNextSelection()) { XmlObject o = c.getObject(); if (o instanceof CTRuby) { handleRuby(o, text, false); continue; } _getText(o, text); } c.dispose(); return text.toString(); }
cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject();
/*package*/ XSLFObjectShape(CTGraphicalObjectFrame shape, XSLFSheet sheet){ super(shape, sheet); CTGraphicalObjectData god = shape.getGraphic().getGraphicData(); XmlCursor xc = god.newCursor(); // select oleObj potentially under AlternateContent // usually the mc:Choice element will be selected first xc.selectPath("declare namespace p='"+PML_NS+"' .//p:oleObj"); try { if (!xc.toNextSelection()) { throw new IllegalStateException("p:oleObj element was not found in\n " + god); } XmlObject xo = xc.getObject(); // Pesky XmlBeans bug - see Bugzilla #49934 // it never happens when using the full ooxml-schemas jar but may happen with the abridged poi-ooxml-schemas if (xo instanceof XmlAnyTypeImpl){ String errStr = "Schemas (*.xsb) for CTOleObject can't be loaded - usually this happens when OSGI " + "loading is used and the thread context classloader has no reference to " + "the xmlbeans classes - use POIXMLTypeLoader.setClassLoader() to set the loader, " + "e.g. with CTOleObject.class.getClassLoader()" ; throw new IllegalStateException(errStr); } _oleObject = (CTOleObject)xo; } finally { xc.dispose(); } }
c.selectPath("child::*"); while (c.toNextSelection()) { XmlObject o = c.getObject();
/** * create and return a list of all XWPFTableCell * who belongs to this row * * @return a list of {@link XWPFTableCell} */ public List<ICell> getTableICells() { List<ICell> cells = new ArrayList<>(); //Can't use ctRow.getTcList because that only gets table cells //Can't use ctRow.getSdtList because that only gets sdts that are at cell level XmlCursor cursor = ctRow.newCursor(); cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject(); if (o instanceof CTTc) { cells.add(new XWPFTableCell((CTTc) o, this, table.getBody())); } else if (o instanceof CTSdtCell) { cells.add(new XWPFSDTCell((CTSdtCell) o, this, table.getBody())); } } cursor.dispose(); return cells; }
c.selectPath(".//*"); boolean inRT = false; boolean inBase = false;
private void buildRunsInOrderFromXml(XmlObject object) { XmlCursor c = object.newCursor(); c.selectPath("child::*"); while (c.toNextSelection()) { XmlObject o = c.getObject();
cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject();
cursor.selectPath("./*"); while (cursor.toNextSelection()) { XmlObject o = cursor.getObject();
cur.selectPath(xquery); while (cur.toNextSelection()) { XmlObject obj = cur.getObject();
CTR ctRun = rArray[runPos]; XmlCursor c = ctRun.newCursor(); c.selectPath("./*"); try { while (c.toNextSelection()) {
docCursor.selectPath("./*"); while (docCursor.toNextSelection()) { XmlObject o = docCursor.getObject(); if (o instanceof CTBody) { XmlCursor bodyCursor = o.newCursor(); bodyCursor.selectPath("./*"); while (bodyCursor.toNextSelection()) { XmlObject bodyObj = bodyCursor.getObject();
XmlCursor cur = getCTWorksheet().getOleObjects().newCursor(); try { cur.selectPath(xquery); CTOleObject coo = null; while (cur.toNextSelection()) {