Java Code Examples for org.apache.poi.poifs.common.POIFSConstants#SMALLER_BIG_BLOCK_SIZE_DETAILS

The following examples show how to use org.apache.poi.poifs.common.POIFSConstants#SMALLER_BIG_BLOCK_SIZE_DETAILS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OPOIFSDocument.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: OPOIFSDocument.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: DocumentBlock.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * create a document block from a raw data block
 *
 * @param block the raw data block
 *
 * @exception IOException
 */

public DocumentBlock(final RawDataBlock block)
    throws IOException
{
    super(
          block.getBigBlockSize() == POIFSConstants.SMALLER_BIG_BLOCK_SIZE ?
                POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS :
                POIFSConstants.LARGER_BIG_BLOCK_SIZE_DETAILS
    );
    _data       = block.getData();
    _bytes_read = _data.length;
}
 
Example 4
Source File: OPOIFSDocument.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public OPOIFSDocument(String name, ListManagedBlock[] blocks, int length) throws IOException {
   this(name, POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS, blocks, length);
}
 
Example 5
Source File: OPOIFSDocument.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public OPOIFSDocument(String name, InputStream stream) throws IOException {
   this(name, POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS, stream);
}
 
Example 6
Source File: OPOIFSDocument.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public OPOIFSDocument(String name, int size, POIFSDocumentPath path, POIFSWriterListener writer) {
   this(name, size, POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS, path, writer);
}
 
Example 7
Source File: HeaderBlock.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private HeaderBlock(byte[] data) throws IOException {
   this._data = data.clone();
   
	// verify signature
   FileMagic fm = FileMagic.valueOf(data);
   
   switch (fm) {
   case OLE2:
       break;
   case OOXML:
          throw new OfficeXmlFileException("The supplied data appears to be in the Office 2007+ XML. "
              + "You are calling the part of POI that deals with OLE2 Office Documents. "
              + "You need to call a different part of POI to process this data (eg XSSF instead of HSSF)");
   case XML:
          throw new NotOLE2FileException("The supplied data appears to be a raw XML file. "
              + "Formats such as Office 2003 XML are not supported");
   case MSWRITE:
          throw new NotOLE2FileException("The supplied data appears to be in the old MS Write format. "
              + "Apache POI doesn't currently support this format");
      case BIFF2:
      case BIFF3:
      case BIFF4:
          throw new OldExcelFormatException("The supplied data appears to be in "+fm+" format. "
              + "HSSF only supports the BIFF8 format, try OldExcelExtractor");
   default:
          // Give a generic error if the OLE2 signature isn't found
       String exp = HexDump.longToHex(_signature);
       String act = HexDump.longToHex(LittleEndian.getLong(data, 0));
          throw new NotOLE2FileException(
              "Invalid header signature; read " + act + ", expected " + exp +
              " - Your file appears not to be a valid OLE2 document");
   }
   
	// Figure out our block size
	if (_data[30] == 12) {
		this.bigBlockSize = POIFSConstants.LARGER_BIG_BLOCK_SIZE_DETAILS;
	} else if(_data[30] == 9) {
		this.bigBlockSize = POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS;
	} else {
	   throw new IOException("Unsupported blocksize  (2^"+ _data[30] + "). Expected 2^9 or 2^12.");
	}

   // Setup the fields to read and write the counts and starts
     _bat_count  = new IntegerField(_bat_count_offset, data).get();
     _property_start = new IntegerField(_property_start_offset,_data).get();
     _sbat_start = new IntegerField(_sbat_start_offset, _data).get();
     _sbat_count = new IntegerField(_sbat_block_count_offset, _data).get();
     _xbat_start = new IntegerField(_xbat_start_offset, _data).get();
     _xbat_count = new IntegerField(_xbat_count_offset, _data).get();
}