Package org.apache.poi.poifs.filesystem

Examples of org.apache.poi.poifs.filesystem.DocumentEntry


  {
    //do Ole stuff
    POIFSFileSystem filesystem = new POIFSFileSystem(istream);

    // read in the main stream.
    DocumentEntry documentProps =
       (DocumentEntry)filesystem.getRoot().getEntry("WordDocument");
    _mainStream = new byte[documentProps.getSize()];
    filesystem.createDocumentInputStream("WordDocument").read(_mainStream);

    // use the fib to determine the name of the table stream.
    _fib = new FileInformationBlock(_mainStream);

    String name = "0Table";
    if (_fib.isFWhichTblStm())
    {
      name = "1Table";
    }

    // read in the table stream.
    DocumentEntry tableProps =
      (DocumentEntry)filesystem.getRoot().getEntry(name);
    _tableStream = new byte[tableProps.getSize()];
    filesystem.createDocumentInputStream(name).read(_tableStream);

    _fib.fillVariableFields(_mainStream, _tableStream);

    // read in the data stream.
    try
    {
      DocumentEntry dataProps =
          (DocumentEntry) filesystem.getRoot().getEntry("Data");
      _dataStream = new byte[dataProps.getSize()];
      filesystem.createDocumentInputStream("Data").read(_dataStream);
    }
    catch(java.io.FileNotFoundException e)
    {
        _dataStream = new byte[0];
View Full Code Here



      POIFSFileSystem filesystem = new POIFSFileSystem(new FileInputStream(
        new File(filename)));

      DocumentEntry documentProps =
        (DocumentEntry) filesystem.getRoot().getEntry("WordDocument");
      _mainStream = new byte[documentProps.getSize()];
      filesystem.createDocumentInputStream("WordDocument").read(_mainStream);

      // use the fib to determine the name of the table stream.
      _fib = new FileInformationBlock(_mainStream);

      String name = "0Table";
      if (_fib.isFWhichTblStm())
      {
        name = "1Table";
      }

      // read in the table stream.
      DocumentEntry tableProps =
        (DocumentEntry) filesystem.getRoot().getEntry(name);
      _tableStream = new byte[tableProps.getSize()];
      filesystem.createDocumentInputStream(name).read(_tableStream);

      _fib.fillVariableFields(_mainStream, _tableStream);
    }
    catch (Throwable t)
View Full Code Here

  public SlideShowDumper(POIFSFileSystem filesystem) throws IOException
  {
  this.filesystem = filesystem;

  // Get the main document stream
  DocumentEntry docProps =
    (DocumentEntry)filesystem.getRoot().getEntry("PowerPoint Document");

  // Grab the document stream
  _docstream = new byte[docProps.getSize()];
  filesystem.createDocumentInputStream("PowerPoint Document").read(_docstream);
  }
View Full Code Here

   * @throws IOException
   */
  private void readPowerPointStream() throws IOException
  {
    // Get the main document stream
    DocumentEntry docProps =
      (DocumentEntry)directory.getEntry("PowerPoint Document");

    // Grab the document stream
    _docstream = new byte[docProps.getSize()];
    directory.createDocumentInputStream("PowerPoint Document").read(_docstream);
  }
View Full Code Here

        _pictures = new ArrayList<PictureData>();

    byte[] pictstream;

    try {
      DocumentEntry entry = (DocumentEntry)directory.getEntry("Pictures");
      pictstream = new byte[entry.getSize()];
      DocumentInputStream is = directory.createDocumentInputStream("Pictures");
      is.read(pictstream);
    } catch (FileNotFoundException e){
      // Silently catch exceptions if the presentation doesn't
      //  contain pictures - will use a null set instead
View Full Code Here

   */
  public QuickButCruddyTextExtractor(POIFSFileSystem poifs) throws IOException {
    fs = poifs;

    // Find the PowerPoint bit, and get out the bytes
    DocumentEntry docProps =
      (DocumentEntry)fs.getRoot().getEntry("PowerPoint Document");
    pptContents = new byte[docProps.getSize()];
    fs.createDocumentInputStream("PowerPoint Document").read(pptContents);
  }
View Full Code Here

    // 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];
View Full Code Here

  public void testWriteNormal() throws Exception {
    // Get raw contents from a known file
    POIFSFileSystem fs = new POIFSFileSystem(
        new FileInputStream(normalFile)
    );
    DocumentEntry docProps = (DocumentEntry)fs.getRoot().getEntry("Current User");
    byte[] contents = new byte[docProps.getSize()];
    InputStream in = fs.getRoot().createDocumentInputStream("Current User");
    in.read(contents);

    // Now build up a new one
    CurrentUserAtom cu = new CurrentUserAtom();
View Full Code Here

        byte[] oledata = readAll(record.getData());
        assertEquals(len, oledata.length);

        POIFSFileSystem fs = new POIFSFileSystem(record.getData());
        assertTrue("Constructed POIFS from ExOleObjStg data", true);
        DocumentEntry doc = (DocumentEntry)fs.getRoot().getEntry("Contents");
        assertNotNull(doc);
        assertTrue("Fetched the Contents stream containing OLE properties", true);
    }
View Full Code Here

    chunkFactory = new ChunkFactory(11);

    FileInputStream fin = new FileInputStream(filename);
    filesystem = new POIFSFileSystem(fin);

    DocumentEntry docProps =
      (DocumentEntry)filesystem.getRoot().getEntry("VisioDocument");

    // Grab the document stream
    contents = new byte[docProps.getSize()];
    filesystem.createDocumentInputStream("VisioDocument").read(contents);
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.poifs.filesystem.DocumentEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.