/** * Find hyperlinks in a text run * * @param run <code>TextRun</code> to lookup hyperlinks in * @return found hyperlinks or <code>null</code> if not found */ protected static Hyperlink[] find(TextRun run){ ArrayList lst = new ArrayList(); SlideShow ppt = run.getSheet().getSlideShow(); //document-level container which stores info about all links in a presentation ExObjList exobj = ppt.getDocumentRecord().getExObjList(); if (exobj == null) { return null; } Record[] records = run._records; if(records != null) find(records, exobj, lst); Hyperlink[] links = null; if (lst.size() > 0){ links = new Hyperlink[lst.size()]; lst.toArray(links); } return links; }
/** * Find hyperlinks in a text paragraph * * @param paragraphs List of <code>TextParagraph</code> to lookup hyperlinks * @return found hyperlinks */ @SuppressWarnings("resource") protected static List<HSLFHyperlink> find(List<HSLFTextParagraph> paragraphs){ List<HSLFHyperlink> lst = new ArrayList<>(); if (paragraphs == null || paragraphs.isEmpty()) return lst; HSLFTextParagraph firstPara = paragraphs.get(0); HSLFSlideShow ppt = firstPara.getSheet().getSlideShow(); //document-level container which stores info about all links in a presentation ExObjList exobj = ppt.getDocumentRecord().getExObjList(false); if (exobj != null) { Record[] records = firstPara.getRecords(); find(Arrays.asList(records), exobj, lst); } return lst; }
/** * Find hyperlink assigned to the supplied shape * * @param shape <code>Shape</code> to lookup hyperlink in * @return found hyperlink or <code>null</code> */ @SuppressWarnings("resource") protected static HSLFHyperlink find(HSLFShape shape){ HSLFSlideShow ppt = shape.getSheet().getSlideShow(); //document-level container which stores info about all links in a presentation ExObjList exobj = ppt.getDocumentRecord().getExObjList(false); HSLFEscherClientDataRecord cldata = shape.getClientData(false); if (exobj != null && cldata != null) { List<HSLFHyperlink> lst = new ArrayList<>(); find(cldata.getHSLFChildRecords(), exobj, lst); return lst.isEmpty() ? null : lst.get(0); } return null; }
int addToObjListAtom(RecordContainer exObj) { ExObjList lst = getDocumentRecord().getExObjList(true); ExObjListAtom objAtom = lst.getExObjListAtom(); // increment the object ID seed int objectId = (int) objAtom.getObjectIDSeed() + 1; objAtom.setObjectIDSeed(objectId); lst.addChildAfter(exObj, objAtom); return objectId; }
/** * Find hyperlink assigned to the supplied shape * * @param shape <code>Shape</code> to lookup hyperlink in * @return found hyperlink or <code>null</code> */ protected static Hyperlink find(Shape shape){ ArrayList lst = new ArrayList(); SlideShow ppt = shape.getSheet().getSlideShow(); //document-level container which stores info about all links in a presentation ExObjList exobj = ppt.getDocumentRecord().getExObjList(); if (exobj == null) { return null; } EscherContainerRecord spContainer = shape.getSpContainer(); for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext(); ) { EscherRecord obj = it.next(); if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID){ byte[] data = obj.serialize(); Record[] records = Record.findChildRecords(data, 8, data.length-8); if(records != null) find(records, exobj, lst); } } return lst.size() == 1 ? (Hyperlink)lst.get(0) : null; }
ExObjList lst = _documentRecord.getExObjList(); if (lst == null) { lst = new ExObjList();
SlideShow ppt = getSheet().getSlideShow(); ExObjList lst = ppt.getDocumentRecord().getExObjList(); if(lst == null){ logger.log(POILogger.WARN, "ExObjList not found");
private ExEmbed getExEmbed(boolean create) { if (_exEmbed == null) { HSLFSlideShow ppt = getSheet().getSlideShow(); ExObjList lst = ppt.getDocumentRecord().getExObjList(create); if(lst == null){ LOG.log(POILogger.WARN, "ExObjList not found"); return null; } int id = getObjectID(); for (Record ch : lst.getChildRecords()) { if(ch instanceof ExEmbed){ ExEmbed embd = (ExEmbed)ch; if( embd.getExOleObjAtom().getObjID() == id) { _exEmbed = embd; } } } if (_exEmbed == null && create) { _exEmbed = new ExEmbed(); _exEmbed.getExOleObjAtom().setObjID(id); lst.appendChildRecord(_exEmbed); } } return _exEmbed; }