예제 #1
0
  /**
   * Constructor
   *
   * @param name the name of the POIFSDocument
   * @param stream the InputStream we read data from
   */
  public OPOIFSDocument(String name, POIFSBigBlockSize bigBlockSize, InputStream stream)
      throws IOException {
    List<DocumentBlock> blocks = new ArrayList<DocumentBlock>();

    _size = 0;
    _bigBigBlockSize = bigBlockSize;
    while (true) {
      DocumentBlock block = new DocumentBlock(stream, bigBlockSize);
      int blockSize = block.size();

      if (blockSize > 0) {
        blocks.add(block);
        _size += blockSize;
      }
      if (block.partiallyRead()) {
        break;
      }
    }
    DocumentBlock[] bigBlocks = blocks.toArray(new DocumentBlock[blocks.size()]);

    _big_store = new BigBlockStore(bigBlockSize, bigBlocks);
    _property = new DocumentProperty(name, _size);
    _property.setDocument(this);
    if (_property.shouldUseSmallBlocks()) {
      _small_store =
          new SmallBlockStore(
              bigBlockSize, SmallDocumentBlock.convert(bigBlockSize, bigBlocks, _size));
      _big_store = new BigBlockStore(bigBlockSize, new DocumentBlock[0]);
    } else {
      _small_store = new SmallBlockStore(bigBlockSize, EMPTY_SMALL_BLOCK_ARRAY);
    }
  }
예제 #2
0
  /**
   * Constructor from small blocks
   *
   * @param name the name of the POIFSDocument
   * @param blocks the small blocks making up the POIFSDocument
   * @param length the actual length of the POIFSDocument
   */
  public OPOIFSDocument(String name, SmallDocumentBlock[] blocks, int length) {
    _size = length;

    if (blocks.length == 0) {
      _bigBigBlockSize = POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS;
    } else {
      _bigBigBlockSize = blocks[0].getBigBlockSize();
    }

    _big_store = new BigBlockStore(_bigBigBlockSize, EMPTY_BIG_BLOCK_ARRAY);
    _property = new DocumentProperty(name, _size);
    _small_store = new SmallBlockStore(_bigBigBlockSize, blocks);
    _property.setDocument(this);
  }
예제 #3
0
 /**
  * Constructor from small blocks
  *
  * @param name the name of the POIFSDocument
  * @param blocks the small blocks making up the POIFSDocument
  * @param length the actual length of the POIFSDocument
  */
 public POIFSDocument(
     String name, POIFSBigBlockSize bigBlockSize, ListManagedBlock[] blocks, int length)
     throws IOException {
   _size = length;
   _property = new DocumentProperty(name, _size);
   _property.setDocument(this);
   if (Property.isSmall(_size)) {
     _big_store = new BigBlockStore(bigBlockSize, EMPTY_BIG_BLOCK_ARRAY);
     _small_store = new SmallBlockStore(bigBlockSize, convertRawBlocksToSmallBlocks(blocks));
   } else {
     _big_store = new BigBlockStore(bigBlockSize, convertRawBlocksToBigBlocks(blocks));
     _small_store = new SmallBlockStore(bigBlockSize, EMPTY_SMALL_BLOCK_ARRAY);
   }
 }
예제 #4
0
  /**
   * Constructor from large blocks
   *
   * @param name the name of the POIFSDocument
   * @param blocks the big blocks making up the POIFSDocument
   * @param length the actual length of the POIFSDocument
   */
  public OPOIFSDocument(String name, RawDataBlock[] blocks, int length) throws IOException {
    _size = length;
    if (blocks.length == 0) {
      _bigBigBlockSize = POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS;
    } else {
      _bigBigBlockSize =
          (blocks[0].getBigBlockSize() == POIFSConstants.SMALLER_BIG_BLOCK_SIZE
              ? POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS
              : POIFSConstants.LARGER_BIG_BLOCK_SIZE_DETAILS);
    }

    _big_store = new BigBlockStore(_bigBigBlockSize, convertRawBlocksToBigBlocks(blocks));
    _property = new DocumentProperty(name, _size);
    _small_store = new SmallBlockStore(_bigBigBlockSize, EMPTY_SMALL_BLOCK_ARRAY);
    _property.setDocument(this);
  }
예제 #5
0
 /**
  * Constructor
  *
  * @param name the name of the POIFSDocument
  * @param size the length of the POIFSDocument
  * @param path the path of the POIFSDocument
  * @param writer the writer who will eventually write the document contents
  */
 public OPOIFSDocument(
     String name,
     int size,
     POIFSBigBlockSize bigBlockSize,
     POIFSDocumentPath path,
     POIFSWriterListener writer) {
   _size = size;
   _bigBigBlockSize = bigBlockSize;
   _property = new DocumentProperty(name, _size);
   _property.setDocument(this);
   if (_property.shouldUseSmallBlocks()) {
     _small_store = new SmallBlockStore(_bigBigBlockSize, path, name, size, writer);
     _big_store = new BigBlockStore(_bigBigBlockSize, EMPTY_BIG_BLOCK_ARRAY);
   } else {
     _small_store = new SmallBlockStore(_bigBigBlockSize, EMPTY_SMALL_BLOCK_ARRAY);
     _big_store = new BigBlockStore(_bigBigBlockSize, path, name, size, writer);
   }
 }