// Sort out the hpsf properties
super(directory, pfilesystem);
readProperties();
// read in the main stream.
DocumentEntry documentProps = (DocumentEntry)
directory.getEntry("WordDocument");
_mainStream = new byte[documentProps.getSize()];
directory.createDocumentInputStream("WordDocument").read(_mainStream);
// Create our FIB, and check for the doc being encrypted
_fib = new FileInformationBlock(_mainStream);
_cpSplit = new CPSplitCalculator(_fib);
if(_fib.isFEncrypted()) {
throw new EncryptedDocumentException("Cannot process encrypted word files!");
}
// use the fib to determine the name of the table stream.
String name = "0Table";
if (_fib.isFWhichTblStm())
{
name = "1Table";
}
// Grab the table stream.
DocumentEntry tableProps;
try {
tableProps =
(DocumentEntry)directory.getEntry(name);
} catch(FileNotFoundException fnfe) {
throw new IllegalStateException("Table Stream '" + name + "' wasn't found - Either the document is corrupt, or is Word95 (or earlier)");
}
// read in the table stream.
_tableStream = new byte[tableProps.getSize()];
directory.createDocumentInputStream(name).read(_tableStream);
_fib.fillVariableFields(_mainStream, _tableStream);
// read in the data stream.
try
{
DocumentEntry dataProps =
(DocumentEntry)directory.getEntry("Data");
_dataStream = new byte[dataProps.getSize()];
filesystem.createDocumentInputStream("Data").read(_dataStream);
}
catch(java.io.FileNotFoundException e)
{
_dataStream = new byte[0];