Package org.apache.poi.poifs.filesystem

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


    {
      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()];
      directory.createDocumentInputStream("Data").read(_dataStream);
    }
    catch(java.io.FileNotFoundException e)
    {
        _dataStream = new byte[0];
View Full Code Here


    private void parseSummaryEntryIfExists(
            POIFSFileSystem filesystem, String entryName, Metadata metadata)
            throws IOException, TikaException {
        try {
            DocumentEntry entry =
                (DocumentEntry) filesystem.getRoot().getEntry(entryName);
            PropertySet properties =
                new PropertySet(new DocumentInputStream(entry));
            if (properties.isSummaryInformation()) {
                parse(new SummaryInformation(properties), metadata);
View Full Code Here

  public HWPFDocumentCore(DirectoryNode directory) throws IOException {
    // Sort out the hpsf properties
    super(directory);

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

    directory.createDocumentInputStream(STREAM_WORD_DOCUMENT).read(_mainStream);

    // Create our FIB, and check for the doc being encrypted
    _fib = new FileInformationBlock(_mainStream);
View Full Code Here

    {
      name = STREAM_TABLE_1;
    }

    // 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(STREAM_DATA);
      _dataStream = new byte[dataProps.getSize()];
      directory.createDocumentInputStream(STREAM_DATA).read(_dataStream);
    }
    catch(java.io.FileNotFoundException e)
    {
        _dataStream = new byte[0];
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

        throws FileNotFoundException, NoPropertySetStreamException,
               IOException, UnsupportedEncodingException
    {
        InputStream inp = null;
        try {
            DocumentEntry entry = (DocumentEntry)dir.getEntry(name);
            inp = new DocumentInputStream(entry);
            try {
                return create(inp);
            } catch (MarkUnsupportedException e) { return null; }
        } finally {
View Full Code Here

        FileInputStream fis = new FileInputStream(ppt);
        POIFSFileSystem fs = new POIFSFileSystem(fis);
        fis.close();

        //read the document entry from OLE file system
        DocumentEntry entry = (DocumentEntry)fs.getRoot().getEntry(PPDOC_ENTRY);
        docstream = new byte[entry.getSize()];
        DocumentInputStream is = fs.createDocumentInputStream(PPDOC_ENTRY);
        is.read(docstream);

        try {
            entry = (DocumentEntry)fs.getRoot().getEntry(PICTURES_ENTRY);
            pictstream = new byte[entry.getSize()];
            is = fs.createDocumentInputStream(PICTURES_ENTRY);
            is.read(pictstream);
        } catch(FileNotFoundException e){
            //silently catch errors if the presentation does not contain pictures
        }
View Full Code Here

    // Use POIFS to query that lot
    POIFSFileSystem npfs = new POIFSFileSystem(bais);

    // Check that the "PowerPoint Document" sections have the same size
    DocumentEntry oProps = (DocumentEntry)pfs.getRoot().getEntry("PowerPoint Document");
    DocumentEntry nProps = (DocumentEntry)npfs.getRoot().getEntry("PowerPoint Document");
    assertEquals(oProps.getSize(),nProps.getSize());

    // Check that they contain the same data
    byte[] _oData = new byte[oProps.getSize()];
    byte[] _nData = new byte[nProps.getSize()];
    pfs.createDocumentInputStream("PowerPoint Document").read(_oData);
    npfs.createDocumentInputStream("PowerPoint Document").read(_nData);
    for(int i=0; i<_oData.length; i++) {
      //System.out.println(i + "\t" + Integer.toHexString(i));
      assertEquals(_oData[i], _nData[i]);
View Full Code Here

    // Use POIFS to query that lot
    POIFSFileSystem npfs = new POIFSFileSystem(bais);

    // Check that the "PowerPoint Document" sections have the same size
    DocumentEntry oProps = (DocumentEntry)pfs.getRoot().getEntry("PowerPoint Document");
    DocumentEntry nProps = (DocumentEntry)npfs.getRoot().getEntry("PowerPoint Document");
    assertEquals(oProps.getSize(),nProps.getSize());

    // Check that they contain the same data
    byte[] _oData = new byte[oProps.getSize()];
    byte[] _nData = new byte[nProps.getSize()];
    pfs.createDocumentInputStream("PowerPoint Document").read(_oData);
    npfs.createDocumentInputStream("PowerPoint Document").read(_nData);
    for(int i=0; i<_oData.length; i++) {
      if(_oData[i] != _nData[i])
        System.out.println(i + "\t" + Integer.toHexString(i));
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.