@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(); } } }
/** * Find the "Current User" stream, and load it */ private void readCurrentUserStream() { try { currentUser = new CurrentUserAtom(getDirectory()); } catch (IOException ie) { logger.log(POILogger.ERROR, "Error finding Current User Atom:\n" + ie); currentUser = new CurrentUserAtom(); } }
/** * 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(); }
/** * Extracts the main PowerPoint document stream from the * POI file, ready to be passed * * @throws IOException when the powerpoint can't be read */ private void readPowerPointStream() throws IOException { final DirectoryNode dir = getDirectory(); if (!dir.hasEntry(POWERPOINT_DOCUMENT) && dir.hasEntry(PP95_DOCUMENT)) { throw new OldPowerPointFormatException("You seem to have supplied a PowerPoint95 file, which isn't supported"); } // Get the main document stream DocumentEntry docProps = (DocumentEntry)dir.getEntry(POWERPOINT_DOCUMENT); // Grab the document stream int len = docProps.getSize(); try (InputStream is = dir.createDocumentInputStream(docProps)) { _docstream = IOUtils.toByteArray(is, len); } }
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();
EntryUtils.copyNodes(getDirectory().getFileSystem(), outFS, writtenEntries);