/** * Constructs a Powerpoint document from an POIFSFileSystem. */ @SuppressWarnings("resource") public HSLFSlideShow(POIFSFileSystem npoifs) throws IOException { this(new HSLFSlideShowImpl(npoifs)); }
/** * Writes out the slideshow to the currently open file. * <p> * <p>This will fail (with an {@link IllegalStateException} if the * slideshow was opened read-only, opened from an {@link InputStream} * instead of a File, or if this is not the root document. For those cases, * you must use {@link #write(OutputStream)} or {@link #write(File)} to * write to a brand new document. * * @throws IOException thrown on errors writing to the file * @throws IllegalStateException if this isn't from a writable File * @since POI 3.15 beta 3 */ @Override public void write() throws IOException { validateInPlaceWritePossible(); // Write the PowerPoint streams to the current FileSystem // No need to do anything to other streams, already there! write(getDirectory().getFileSystem(), false); // Sync with the File on disk getDirectory().getFileSystem().writeFilesystem(); }
/** * Constructs a Powerpoint document from a specific point in a * POIFS Filesystem. Parses the document and places all the * important stuff into data structures. * * @param dir the POIFS directory to read from * @throws IOException if there is a problem while parsing the document. */ public HSLFSlideShowImpl(DirectoryNode dir) throws IOException { super(handleDualStorage(dir)); // First up, grab the "Current User" stream // We need this before we can detect Encrypted Documents readCurrentUserStream(); // Next up, grab the data that makes up the // PowerPoint stream readPowerPointStream(); // Now, build records based on the PowerPoint stream buildRecords(); // Look for any other streams readOtherStreams(); }
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); System.out.println(""); Record[] records = ss.getRecords(); for(int i=0; i<records.length; i++) { Record r = records[i]; ss.close();
HSLFSlideShowImpl slideShow1 = new HSLFSlideShowImpl(leftIs); HSLFSlideShowImpl slideShow2 = new HSLFSlideShowImpl(new FileInputStream(newFile)); String lastEditUsername1 = slideShow1.getCurrentUserAtom().getLastEditUsername(); String lastEditUsername2 = slideShow2.getCurrentUserAtom().getLastEditUsername(); try slideShow1.write(os); try slideShow2.write(os2);
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); fileContents = ss.getUnderlyingBytes(); System.out.println(""); for(Record r : ss.getRecords()) { if(r.getRecordType() == 6001l) { for(Record r : ss.getRecords()) { if(r instanceof UserEditAtom) { UserEditAtom uea = (UserEditAtom)r; CurrentUserAtom cua = ss.getCurrentUserAtom(); System.out.println("Checking Current User Atom"); System.out.println(" Thinks the CurrentEditOffset is " + cua.getCurrentEditOffset()); ss.close();
private void write(POIFSFileSystem outFS, boolean copyAllOtherNodes) throws IOException { readPictures(); getDocumentSummaryInformation(); HSLFSlideShowEncrypted encryptedSS = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom()); _records = encryptedSS.updateEncryptionRecord(_records); writeProperties(outFS, writtenEntries); updateAndWriteDependantRecords(baos, null); EntryUtils.copyNodes(getDirectory().getFileSystem(), outFS, writtenEntries);
public static PowerpointMetadata instance( InputStream stream ) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(stream); HSLFSlideShow rawSlideShow = new HSLFSlideShow(fs); List<SlideMetadata> slidesMetadata = rawSlideShow.getSlides() .stream() .map(slide -> processSlide(rawSlideShow, slide)) .collect(Collectors.toList()); PowerpointMetadata deck = new PowerpointMetadata(); deck.setSlides(slidesMetadata); deck.setMetadata(new HSLFSlideShowImpl(fs).getSummaryInformation()); return deck; }
HSLFSlideShowImpl hss = new HSLFSlideShowImpl(args[0]); HSLFSlideShow ss = new HSLFSlideShow(hss); fileContents = hss.getUnderlyingBytes(); Record[] records = hss.getRecords(); Record[] latestRecords = ss.getMostRecentCoreRecords();
/** * Writes out the slideshow file the is represented by an instance * of this class. * <p>This will write out only the common OLE2 streams. If you require all * streams to be written out, use {@link #write(OutputStream, boolean)} * with <code>preserveNodes</code> set to <code>true</code>. * * @param out The OutputStream to write to. * @throws IOException If there is an unexpected IOException from * the passed in OutputStream */ @Override public void write(OutputStream out) throws IOException { // Write out, but only the common streams write(out, false); }
private int addPersistentObject(PositionDependentRecord slideRecord) { slideRecord.setLastOnDiskOffset(HSLFSlideShowImpl.UNSET_OFFSET); _hslfSlideShow.appendRootLevelRecord((Record)slideRecord); // For position dependent records, hold where they were and now are // As we go along, update, and hand over, to any Position Dependent // records we happen across Map<RecordTypes,PositionDependentRecord> interestingRecords = new HashMap<>(); try { _hslfSlideShow.updateAndWriteDependantRecords(null,interestingRecords); } catch (IOException e) { throw new HSLFException(e); } PersistPtrHolder ptr = (PersistPtrHolder)interestingRecords.get(RecordTypes.PersistPtrIncrementalBlock); UserEditAtom usr = (UserEditAtom)interestingRecords.get(RecordTypes.UserEditAtom); // persist ID is UserEditAtom.maxPersistWritten + 1 int psrId = usr.getMaxPersistWritten() + 1; // Last view is now of the slide usr.setLastViewType((short) UserEditAtom.LAST_VIEW_SLIDE_VIEW); // increment the number of persistent objects usr.setMaxPersistWritten(psrId); // Add the new slide into the last PersistPtr // (Also need to tell it where it is) int slideOffset = slideRecord.getLastOnDiskOffset(); slideRecord.setLastOnDiskOffset(slideOffset); ptr.addSlideLookup(psrId, slideOffset); logger.log(POILogger.INFO, "New slide/object ended up at " + slideOffset); return psrId; }
if (!getDirectory().hasEntry("Pictures")) { return; DocumentEntry entry = (DocumentEntry) getDirectory().getEntry("Pictures"); DocumentInputStream is = getDirectory().createDocumentInputStream(entry); byte[] pictstream = IOUtils.toByteArray(is, entry.getSize()); is.close(); try (HSLFSlideShowEncrypted decryptData = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom())) {
@Override public void close() throws IOException { // only close the filesystem, if we are based on the root node. // embedded documents/slideshows shouldn't close the parent container if (getDirectory().getParent() == null) { POIFSFileSystem fs = getDirectory().getFileSystem(); if (fs != null) { fs.close(); } } }
/** * Constructs a new, empty, Powerpoint document. */ public HSLFSlideShow() { this(HSLFSlideShowImpl.create()); }
@Override public void close() throws IOException { _hslfSlideShow.close(); }
pict.setData(data); int offset = _hslfSlideShow.addPicture(pict);
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); Record[] records = ss.getRecords(); for(int i=0; i<records.length; i++) { if(records[i] instanceof Document) { ss.close();
HSLFSlideShowImpl slideShow1 = new HSLFSlideShowImpl(leftIs); HSLFSlideShowImpl slideShow2 = new HSLFSlideShowImpl(new FileInputStream(newFile)); String lastEditUsername1 = slideShow1.getCurrentUserAtom().getLastEditUsername(); String lastEditUsername2 = slideShow2.getCurrentUserAtom().getLastEditUsername(); try slideShow1.write(os); try slideShow2.write(os2);
public static PowerpointMetadata instance( InputStream stream ) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(stream); HSLFSlideShow rawSlideShow = new HSLFSlideShow(fs); List<SlideMetadata> slidesMetadata = rawSlideShow.getSlides() .stream() .map(slide -> processSlide(rawSlideShow, slide)) .collect(Collectors.toList()); PowerpointMetadata deck = new PowerpointMetadata(); deck.setSlides(slidesMetadata); deck.setMetadata(new HSLFSlideShowImpl(fs).getSummaryInformation()); return deck; }
/** * Writes out the slideshow file the is represented by an instance * of this class. * <p>This will write out only the common OLE2 streams. If you require all * streams to be written out, use {@link #write(File, boolean)} * with <code>preserveNodes</code> set to <code>true</code>. * * @param newFile The File to write to. * @throws IOException If there is an unexpected IOException from writing to the File */ @Override public void write(File newFile) throws IOException { // Write out, but only the common streams write(newFile, false); }