@Override protected Dimension processSlides() throws IOException{ SlideShow ppt = new SlideShow(inStream); Dimension dimension = ppt.getPageSize(); slides = ppt.getSlides(); return dimension; }
/** * Adds a picture to this presentation and returns the associated index. * * @param pict * the file containing the image to add * @param format * the format of the picture. One of constans defined in the * <code>Picture</code> class. * @return the index to this picture (1 based). */ public int addPicture(File pict, int format) throws IOException { int length = (int) pict.length(); byte[] data = new byte[length]; try { FileInputStream is = new FileInputStream(pict); is.read(data); is.close(); } catch (IOException e) { throw new HSLFException(e); } return addPicture(data, format); }
/** * Constructs a Powerpoint document from the underlying * HSLFSlideShow object. Finds the model stuff from this * * @param hslfSlideShow the HSLFSlideShow to base on */ public SlideShow(HSLFSlideShow hslfSlideShow) { // Get useful things from our base slideshow _hslfSlideShow = hslfSlideShow; _records = _hslfSlideShow.getRecords(); // Handle Parent-aware Records for (Record record : _records) { if(record instanceof RecordContainer){ RecordContainer.handleParentAwareRecords((RecordContainer)record); } } // Find the versions of the core records we'll want to use findMostRecentCoreRecords(); // Build up the model level Slides and Notes buildSlidesAndNotes(); }
return; SlideShow ppt = new SlideShow(new HSLFSlideShow(args[0])); PictureData[] pdata = ppt.getPictureData(); for (int i = 0; i < pdata.length; i++) { PictureData pict = pdata[i];
SlideShow ss = new SlideShow(hss); Record[] latestRecords = ss.getMostRecentCoreRecords();
/** * 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; }
wrappingWidth = _shape.getSheet().getSlideShow().getPageSize().width; PPFont bulletFont = _shape.getSheet().getSlideShow().getFont(fontIdx); bat.addAttribute(TextAttribute.FAMILY, bulletFont.getFontName());
public void draw(Graphics2D graphics) { Fill f = getFill(); Dimension pg = getSheet().getSlideShow().getPageSize(); Rectangle anchor = new Rectangle(0, 0, pg.width, pg.height); switch (f.getFillType()) {
/** * <code>PictureData</code> object used in a texture, pattern of picture fill. */ public PictureData getPictureData(){ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID); EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE); if (p == null) return null; SlideShow ppt = shape.getSheet().getSlideShow(); PictureData[] pict = ppt.getPictureData(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); java.util.List<EscherRecord> lst = bstore.getChildRecords(); int idx = p.getPropertyValue(); if (idx == 0){ logger.log(POILogger.WARN, "no reference to picture data found "); } else { EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1); for ( int i = 0; i < pict.length; i++ ) { if (pict[i].getOffset() == bse.getOffset()){ return pict[i]; } } } return null; }
/** * For a given SlideAtomsSet, return the core record, based on the refID * from the SlidePersistAtom */ private Record getCoreRecordForSAS(SlideAtomsSet sas) { SlidePersistAtom spa = sas.getSlidePersistAtom(); int refID = spa.getRefID(); return getCoreRecordForRefID(refID); }
Record r = getCoreRecordForSAS(masterSets[i]); SlideAtomsSet sas = masterSets[i]; int sheetNo = sas.getSlidePersistAtom().getSlideIdentifier(); for (int i = 0; i < notesSets.length; i++) { Record r = getCoreRecordForSAS(notesSets[i]); for (int i = 0; i < slidesSets.length; i++) { Record r = getCoreRecordForSAS(slidesSets[i]);
protected String extractPPTContent(InputStream in) throws Exception{ SlideShow ppt = new SlideShow(in); Slide[] slide = ppt.getSlides(); StringBuffer content = new StringBuffer(); for(int i=0;i<slide.length;i++){ TextRun[] tr = slide[i].getTextRuns(); for(int j = 0; j<tr.length; j++){ content.append(" "); content.append(slide[i].getTextRuns()[j].getText()); } } return content.toString(); } }
/** * get the number of fonts in the presentation * * @return number of fonts */ public int getNumberOfFonts() { return getDocumentRecord().getEnvironment().getFontCollection().getNumberOfFonts(); }
/** * Attach this HeadersFootersContainer to the parent Document record */ private void attach(){ Document doc = _ppt.getDocumentRecord(); Record[] ch = doc.getChildRecords(); Record lst = null; for (int i=0; i < ch.length; i++){ if(ch[i].getRecordType() == RecordTypes.List.typeID){ lst = ch[i]; break; } } doc.addChildAfter(_container, lst); _newRecord = false; }
/** * 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; }
protected EscherBSERecord getEscherBSERecord(int idx){ Sheet sheet = shape.getSheet(); if(sheet == null) { logger.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet"); return null; } SlideShow ppt = sheet.getSlideShow(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); if(bstore == null) { logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found "); return null; } List lst = bstore.getChildRecords(); return (EscherBSERecord)lst.get(idx-1); }
/** * Get a font by index * * @param idx * 0-based index of the font * @return of an instance of <code>PPFont</code> or <code>null</code> if not * found */ public PPFont getFont(int idx) { PPFont font = null; FontCollection fonts = getDocumentRecord().getEnvironment().getFontCollection(); Record[] ch = fonts.getChildRecords(); for (int i = 0; i < ch.length; i++) { if (ch[i] instanceof FontEntityAtom) { FontEntityAtom atom = (FontEntityAtom) ch[i]; if (atom.getFontIndex() == idx) { font = new PPFont(atom); break; } } } return font; }
protected EscherBSERecord getEscherBSERecord(){ SlideShow ppt = getSheet().getSlideShow(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); if(bstore == null) { logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found "); return null; } List lst = bstore.getChildRecords(); int idx = getPictureIndex(); if (idx == 0){ logger.log(POILogger.DEBUG, "picture index was not found, returning "); return null; } return (EscherBSERecord)lst.get(idx-1); }
/** * Assign SlideShow for this slide master. * (Used interanlly) */ public void setSlideShow(SlideShow ss) { super.setSlideShow(ss); //after the slide show is assigned collect all available style records if (_txmaster == null) { _txmaster = new TxMasterStyleAtom[9]; TxMasterStyleAtom txdoc = getSlideShow().getDocumentRecord().getEnvironment().getTxMasterStyleAtom(); _txmaster[txdoc.getTextType()] = txdoc; TxMasterStyleAtom[] txrec = ((MainMaster)getSheetContainer()).getTxMasterStyleAtoms(); for (int i = 0; i < txrec.length; i++) { int txType = txrec[i].getTextType(); if(_txmaster[txType] == null) _txmaster[txType] = txrec[i]; } } }