private SummaryInformation sInf;
/** Holds further metadata on our document */
private DocumentSummaryInformation dsInf;
- /** The open POIFS FileSystem that contains our document */
- protected POIFSFileSystem filesystem;
/** The directory that our document lives in */
protected DirectoryNode directory;
private boolean initialized = false;
- protected POIDocument(DirectoryNode dir, POIFSFileSystem fs) {
- this.filesystem = fs;
+ protected POIDocument(DirectoryNode dir) {
this.directory = dir;
}
+ @Deprecated
+ protected POIDocument(DirectoryNode dir, POIFSFileSystem fs) {
+ this.directory = dir;
+ }
protected POIDocument(POIFSFileSystem fs) {
- this(fs.getRoot(), fs);
+ this(fs.getRoot());
}
/**
* this document.
*/
public POIFSFileSystem getFileSystem() {
- return document.filesystem;
+ return document.directory.getFileSystem();
}
}
package org.apache.poi.hpsf.extractor;
+import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.poi.hpsf.SpecialPropertySet;
import org.apache.poi.hpsf.SummaryInformation;
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
+import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.LittleEndian;
public HPSFPropertiesExtractor(POIFSFileSystem fs) {
super(new PropertiesOnlyDocument(fs));
}
+ public HPSFPropertiesExtractor(NPOIFSFileSystem fs) {
+ super(new PropertiesOnlyDocument(fs));
+ }
public String getDocumentSummaryInformationText() {
DocumentSummaryInformation dsi = document.getDocumentSummaryInformation();
* random OLE2 document.
*/
private static final class PropertiesOnlyDocument extends POIDocument {
+ public PropertiesOnlyDocument(NPOIFSFileSystem fs) {
+ super(fs.getRoot());
+ }
public PropertiesOnlyDocument(POIFSFileSystem fs) {
super(fs);
}
public static void main(String[] args) throws IOException {
for(String file : args) {
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(
- new POIFSFileSystem(new FileInputStream(file))
+ new NPOIFSFileSystem(new File(file))
);
System.out.println(ext.getText());
}
}
private HSSFWorkbook(InternalWorkbook book) {
- super(null, null);
+ super((DirectoryNode)null);
workbook = book;
_sheets = new ArrayList(INITIAL_CAPACITY);
names = new ArrayList(INITIAL_CAPACITY);
public HSSFWorkbook(DirectoryNode directory, POIFSFileSystem fs, boolean preserveNodes)
throws IOException
{
- super(directory, fs);
+ super(directory);
String workbookName = getWorkbookDirEntryName(directory);
this.preserveNodes = preserveNodes;
// If we're not preserving nodes, don't track the
// POIFS any more
if(! preserveNodes) {
- this.filesystem = null;
this.directory = null;
}
// out correctly shortly, so don't include the old one
excepts.add("WORKBOOK");
- POIFSFileSystem srcFs = this.filesystem;
+ POIFSFileSystem srcFs = this.directory.getFileSystem();
// Copy over all the other nodes to our new poifs
copyNodes(srcFs, fs, excepts);
Object sub = subRecordIter.next();
if (sub instanceof EmbeddedObjectRefSubRecord)
{
- objects.add(new HSSFObjectData((ObjRecord) obj, filesystem));
+ objects.add(new HSSFObjectData((ObjRecord) obj, directory.getFileSystem()));
}
}
}
import java.util.Arrays;
import java.util.HashMap;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.List;
import org.apache.poi.POIDocument;
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
import org.apache.poi.hslf.exceptions.HSLFException;
-import org.apache.poi.hslf.record.*;
+import org.apache.poi.hslf.record.CurrentUserAtom;
+import org.apache.poi.hslf.record.ExOleObjStg;
+import org.apache.poi.hslf.record.PersistPtrHolder;
+import org.apache.poi.hslf.record.PersistRecord;
+import org.apache.poi.hslf.record.PositionDependentRecord;
+import org.apache.poi.hslf.record.Record;
+import org.apache.poi.hslf.record.UserEditAtom;
import org.apache.poi.hslf.usermodel.ObjectData;
import org.apache.poi.hslf.usermodel.PictureData;
import org.apache.poi.poifs.filesystem.DirectoryNode;
* that is open.
*/
protected POIFSFileSystem getPOIFSFileSystem() {
- return filesystem;
+ return directory.getFileSystem();
}
/**
*/
public HSLFSlideShow(POIFSFileSystem filesystem) throws IOException
{
- this(filesystem.getRoot(), filesystem);
+ this(filesystem.getRoot());
}
+ /**
+ * 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
+ * @param filesystem the POIFS FileSystem to read from
+ * @throws IOException if there is a problem while parsing the document.
+ */
+ public HSLFSlideShow(DirectoryNode dir, POIFSFileSystem filesystem) throws IOException
+ {
+ this(dir);
+ }
+
/**
* 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
- * @param filesystem the POIFS FileSystem to read from
* @throws IOException if there is a problem while parsing the document.
*/
- public HSLFSlideShow(DirectoryNode dir, POIFSFileSystem filesystem) throws IOException
+ public HSLFSlideShow(DirectoryNode dir) throws IOException
{
- super(dir, filesystem);
+ super(dir);
// First up, grab the "Current User" stream
// We need this before we can detect Encrypted Documents
// If requested, write out any other streams we spot
if(preserveNodes) {
- copyNodes(filesystem, outFS, writtenEntries);
+ copyNodes(directory.getFileSystem(), outFS, writtenEntries);
}
// Send the POIFSFileSystem object out to the underlying stream
*/
public HWPFDocument(POIFSFileSystem pfilesystem) throws IOException
{
- this(pfilesystem.getRoot(), pfilesystem);
+ this(pfilesystem.getRoot());
}
/**
* This constructor loads a Word document from a specific point
* in a POIFSFileSystem, probably not the default.
- * Used typically to open embeded documents.
+ * Used typically to open embedded documents.
*
* @param pfilesystem The POIFSFileSystem that contains the Word document.
* @throws IOException If there is an unexpected IOException from the passed
* in POIFSFileSystem.
*/
public HWPFDocument(DirectoryNode directory, POIFSFileSystem pfilesystem) throws IOException
+ {
+ this(directory);
+ }
+
+ /**
+ * This constructor loads a Word document from a specific point
+ * in a POIFSFileSystem, probably not the default.
+ * Used typically to open embeded documents.
+ *
+ * @param pfilesystem The POIFSFileSystem that contains the Word document.
+ * @throws IOException If there is an unexpected IOException from the passed
+ * in POIFSFileSystem.
+ */
+ public HWPFDocument(DirectoryNode directory) throws IOException
{
// Load the main stream and FIB
// Also handles HPSF bits
- super(directory, pfilesystem);
+ super(directory);
// Do the CP Split
_cpSplit = new CPSplitCalculator(_fib);
DocumentEntry dataProps =
(DocumentEntry)directory.getEntry("Data");
_dataStream = new byte[dataProps.getSize()];
- filesystem.createDocumentInputStream("Data").read(_dataStream);
+ directory.createDocumentInputStream("Data").read(_dataStream);
}
catch(java.io.FileNotFoundException e)
{
protected HWPFDocumentCore()
{
- super(null, null);
+ super((DirectoryNode)null);
}
/**
*/
public HWPFDocumentCore(POIFSFileSystem pfilesystem) throws IOException
{
- this(pfilesystem.getRoot(), pfilesystem);
+ this(pfilesystem.getRoot());
}
/**
* @throws IOException If there is an unexpected IOException from the passed
* in POIFSFileSystem.
*/
- public HWPFDocumentCore(DirectoryNode directory, POIFSFileSystem pfilesystem) throws IOException
+ public HWPFDocumentCore(DirectoryNode directory) throws IOException
{
// Sort out the hpsf properties
- super(directory, pfilesystem);
+ super(directory);
// read in the main stream.
DocumentEntry documentProps = (DocumentEntry)
private TextPieceTable tpt;
public HWPFOldDocument(POIFSFileSystem fs) throws IOException {
- this(fs.getRoot(), fs);
+ this(fs.getRoot());
}
public HWPFOldDocument(DirectoryNode directory, POIFSFileSystem fs)
throws IOException {
- super(directory, fs);
+ this(directory);
+ }
+ public HWPFOldDocument(DirectoryNode directory)
+ throws IOException {
+ super(directory);
// Where are things?
int sedTableOffset = LittleEndian.getInt(_mainStream, 0x88);
POIFSFileSystem inFS = new POIFSFileSystem(bais);
// Check they're still there
- doc.filesystem = inFS;
+ doc.directory = inFS.getRoot();
doc.readProperties();
// Delegate test
assertNotNull(dirB.getEntry("PowerPoint Document"));
// Check the first file
- ss = new HSLFSlideShow(dirA, fs);
+ ss = new HSLFSlideShow(dirA);
ppe = new PowerPointExtractor(ss);
assertEquals("Sample PowerPoint file\nThis is the 1st file\nNot much too it\n",
ppe.getText(true, false)
);
// And the second
- ss = new HSLFSlideShow(dirB, fs);
+ ss = new HSLFSlideShow(dirB);
ppe = new PowerPointExtractor(ss);
assertEquals("Sample PowerPoint file\nThis is the 2nd file\nNot much too it either\n",
ppe.getText(true, false)
POIFSFileSystem inFS = new POIFSFileSystem(bais);
// Check they're still there
- doc.filesystem = inFS;
+ doc.directory = inFS.getRoot();
doc.readProperties();
// Delegate test