Examples of DocumentInputStream


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

        {
            /* The following declarations are shortcuts for accessing the
             * "event" object. */
            final POIFSDocumentPath path = event.getPath();
            final String name = event.getName();
            final DocumentInputStream stream = event.getStream();

            Throwable t = null;

            try
            {
View Full Code Here

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

                                 final StringBuffer msg)
    throws NoPropertySetStreamException, MarkUnsupportedException,
           UnsupportedEncodingException, IOException
    {
        boolean equal = true;
        final DocumentInputStream dis1 = new DocumentInputStream(d1);
        final DocumentInputStream dis2 = new DocumentInputStream(d2);
        if (PropertySet.isPropertySetStream(dis1) &&
            PropertySet.isPropertySetStream(dis2))
        {
            final PropertySet ps1 = PropertySetFactory.create(dis1);
            final PropertySet ps2 = PropertySetFactory.create(dis2);
            equal = ps1.equals(ps2);
            if (!equal)
            {
                msg.append("Property sets are not equal.\n");
                return equal;
            }
        }
        else
        {
            int i1;
            int i2;
            do
            {
                i1 = dis1.read();
                i2 = dis2.read();
                if (i1 != i2)
                {
                    equal = false;
                    msg.append("Documents are not equal.\n");
                    break;
View Full Code Here

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

        {
            /* The following declarations are shortcuts for accessing the
             * "event" object. */
            final POIFSDocumentPath path = event.getPath();
            final String name = event.getName();
            final DocumentInputStream stream = event.getStream();

            Throwable t = null;

            try
            {
View Full Code Here

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

     * adds them to a tree model.</p>
     */
    public void processPOIFSReaderEvent(final POIFSReaderEvent event)
    {
        DocumentDescriptor d;
        final DocumentInputStream is = event.getStream();
        if (!is.markSupported())
            throw new UnsupportedOperationException(is.getClass().getName() +
                " does not support mark().");

        /* Try do handle this document as a property set. We receive
         * an exception if is no property set and handle it as a
         * document of some other format. We are not concerned about
         * that document's details. */
        try
        {
            d = new PropertySetDescriptor(event.getName(), event.getPath(),
                                          is, nrOfBytes);
        }
        catch (HPSFException ex)
        {
            d = new DocumentDescriptor(event.getName(), event.getPath(),
                                       is, nrOfBytes);
        }
        catch (Throwable t)
        {
            System.err.println
                ("Unexpected exception while processing " +
                event.getName() + " in " + event.getPath().toString());
            t.printStackTrace(System.err);
            throw new RuntimeException(t.getMessage());
        }

        try
        {
            is.close();
        }
        catch (IOException ex)
        {
            System.err.println
                ("Unexpected exception while closing " +
View Full Code Here

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

  /**
   * For a given named property entry, either return it or null if
   *  if it wasn't found
   */
  protected PropertySet getPropertySet(String setName) {
    DocumentInputStream dis;
    try {
      // Find the entry, and get an input stream for it
      dis = filesystem.createDocumentInputStream(setName);
    } catch(IOException ie) {
      // Oh well, doesn't exist
View Full Code Here

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

    public void extractText(POIFSFileSystem fsys, Appendable appendable)
            throws IOException, TikaException {
        // load our POIFS document streams.
        DocumentEntry headerProps =
            (DocumentEntry) fsys.getRoot().getEntry("WordDocument");
        DocumentInputStream din = fsys.createDocumentInputStream("WordDocument");
        byte[] header = new byte[headerProps.getSize()];

        din.read(header);
        din.close();

        int info = LittleEndian.getShort(header, 0xa);
        if ((info & 0x4) != 0) {
            throw new TikaException("Fast-saved files are unsupported");
        }
        if ((info & 0x100) != 0) {
            throw new TikaException("This document is password protected");
        }

        // determine the version of Word this document came from.
        int nFib = LittleEndian.getShort(header, 0x2);
        switch (nFib) {
        case 101:
        case 102:
        case 103:
        case 104:
            // this is a Word 6.0 doc send it to the extractor for that version.
            Word6Extractor oldExtractor = new Word6Extractor(appendable);
            oldExtractor.extractText(header);
        }

        //get the location of the piece table
        int complexOffset = LittleEndian.getInt(header, 0x1a2);

        // determine which table stream we must use.
        //Get the information we need from the header
        String tableName = null;
        boolean useTable1 = (info & 0x200) != 0;
        if (useTable1) {
            tableName = "1Table";
        } else {
            tableName = "0Table";
        }

        DocumentEntry table = (DocumentEntry)fsys.getRoot().getEntry(tableName);
        byte[] tableStream = new byte[table.getSize()];

        din = fsys.createDocumentInputStream(tableName);

        din.read(tableStream);
        din.close();

        int chpOffset = LittleEndian.getInt(header, 0xfa);
        int chpSize = LittleEndian.getInt(header, 0xfe);
        int fcMin = LittleEndian.getInt(header, 0x18);
        CHPBinTable cbt = new CHPBinTable(header, tableStream, chpOffset, chpSize, fcMin);
View Full Code Here

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

            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));
            }
            if (properties.isDocumentSummaryInformation()) {
                parse(new DocumentSummaryInformation(properties));
View Full Code Here

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

    public void processPOIFSReaderEvent(POIFSReaderEvent event) {
      try {
        if (!event.getName().equalsIgnoreCase("PowerPoint Document"))
          return;
        DocumentInputStream input = event.getStream();
        byte[] buffer = new byte[input.available()];
        input.read(buffer, 0, input.available());
        for (int i = 0; i < buffer.length - 20; i++) {
          long type = LittleEndian.getUShort(buffer, i + 2);
          long size = LittleEndian.getUInt(buffer, i + 4);
          if (type == 4008) {
            os.write(buffer, i + 4 + 1, (int) size + 3);
View Full Code Here

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

   * @param event
   */
  public void processPOIFSReaderEvent(POIFSReaderEvent event) {
    try {
      if (event.getName().equalsIgnoreCase("PowerPoint Document")) {
        DocumentInputStream input = event.getStream();
        byte[] buffer = new byte[input.available()];
        input.read(buffer, 0, input.available());
        processContent(0, buffer.length, buffer);
      } else if (event.getName().equalsIgnoreCase("DocumentSummaryInformation")
          || event.getName().equalsIgnoreCase("SummaryInformation")) {
        ps = PropertySetFactory.create(event.getStream());
      }
View Full Code Here

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

    private static MediaType processCompObjFormatType(DirectoryEntry root) {
        try {
            Entry e = root.getEntry("\u0001CompObj");
            if (e != null && e.isDocumentEntry()) {
                DocumentNode dn = (DocumentNode)e;
                DocumentInputStream stream = new DocumentInputStream(dn);
                byte [] bytes = IOUtils.toByteArray(stream);
                /*
                 * This array contains a string with a normal ASCII name of the
                 * application used to create this file. We want to search for that
                 * name.
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.