本文整理汇总了Java中org.apache.poi.util.LittleEndian.INT_SIZE属性的典型用法代码示例。如果您正苦于以下问题:Java LittleEndian.INT_SIZE属性的具体用法?Java LittleEndian.INT_SIZE怎么用?Java LittleEndian.INT_SIZE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.poi.util.LittleEndian
的用法示例。
在下文中一共展示了LittleEndian.INT_SIZE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
/**
* Write this picture into <code>OutputStream</code>
*/
public void write(OutputStream out) throws IOException {
byte[] data;
data = new byte[LittleEndian.SHORT_SIZE];
LittleEndian.putUShort(data, 0, getSignature());
out.write(data);
data = new byte[LittleEndian.SHORT_SIZE];
LittleEndian.putUShort(data, 0, getType() + 0xF018);
out.write(data);
byte[] rawdata = getRawData();
data = new byte[LittleEndian.INT_SIZE];
LittleEndian.putInt(data, 0, rawdata.length);
out.write(data);
out.write(rawdata);
}
示例2: read
public void read(byte[] data, int offset){
int pos = offset;
int key = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE; //header key
if (key != APMHEADER_KEY) throw new HSLFException("Not a valid WMF file");
handle = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
left = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
top = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
right = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
bottom = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
inch = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
reserved = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
checksum = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE;
if (checksum != getChecksum()){
logger.log(POILogger.WARN, "WMF checksum does not match the header data");
}
}
示例3: write
public void write(OutputStream out) throws IOException {
byte[] header = new byte[22];
int pos = 0;
LittleEndian.putInt(header, pos, APMHEADER_KEY); pos += LittleEndian.INT_SIZE; //header key
LittleEndian.putUShort(header, pos, 0); pos += LittleEndian.SHORT_SIZE; //hmf
LittleEndian.putUShort(header, pos, left); pos += LittleEndian.SHORT_SIZE; //left
LittleEndian.putUShort(header, pos, top); pos += LittleEndian.SHORT_SIZE; //top
LittleEndian.putUShort(header, pos, right); pos += LittleEndian.SHORT_SIZE; //right
LittleEndian.putUShort(header, pos, bottom); pos += LittleEndian.SHORT_SIZE; //bottom
LittleEndian.putUShort(header, pos, inch); pos += LittleEndian.SHORT_SIZE; //inch
LittleEndian.putInt(header, pos, 0); pos += LittleEndian.INT_SIZE; //reserved
checksum = getChecksum();
LittleEndian.putUShort(header, pos, checksum);
out.write(header);
}
示例4: read
public void read(byte[] data, int offset){
int pos = offset;
wmfsize = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
int left = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
int top = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
int right = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
int bottom = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
bounds = new Rectangle(left, top, right-left, bottom-top);
int width = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
int height = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
size = new Dimension(width, height);
zipsize = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;
compression = LittleEndian.getUnsignedByte(data, pos); pos++;
filter = LittleEndian.getUnsignedByte(data, pos); pos++;
}
示例5: toByteArray
protected byte[] toByteArray()
{
// set up the fc
int tempFc = fc;
if (!unicode)
{
tempFc *= 2;
tempFc |= (0x40000000);
}
int offset = 0;
byte[] buf = new byte[8];
LittleEndian.putShort(buf, offset, descriptor);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putInt(buf, offset, tempFc);
offset += LittleEndian.INT_SIZE;
LittleEndian.putShort(buf, offset, prm.getValue());
return buf;
}
示例6: ComplexFileTable
public ComplexFileTable(byte[] documentStream, byte[] tableStream, int offset, int fcMin) throws IOException
{
//skips through the prms before we reach the piece table. These contain data
//for actual fast saved files
List<SprmBuffer> sprmBuffers = new LinkedList<SprmBuffer>();
while ( tableStream[offset] == GRPPRL_TYPE )
{
offset++;
int size = LittleEndian.getShort( tableStream, offset );
offset += LittleEndian.SHORT_SIZE;
byte[] bs = LittleEndian.getByteArray( tableStream, offset, size );
offset += size;
SprmBuffer sprmBuffer = new SprmBuffer( bs, false, 0 );
sprmBuffers.add( sprmBuffer );
}
this._grpprls = sprmBuffers.toArray( new SprmBuffer[sprmBuffers.size()] );
if(tableStream[offset] != TEXT_PIECE_TABLE_TYPE)
{
throw new IOException("The text piece table is corrupted");
}
int pieceTableSize = LittleEndian.getInt(tableStream, ++offset);
offset += LittleEndian.INT_SIZE;
_tpt = new TextPieceTable(documentStream, tableStream, offset, pieceTableSize, fcMin);
}
示例7: dump
/**
* Dump a part of the document stream into XML
* @param data PPT binary data
* @param offset offset from the beginning of the document
* @param length of the document
* @param padding used for formatting results
* @throws java.io.IOException
*/
public void dump(byte[] data, int offset, int length, int padding) throws IOException {
int pos = offset;
while (pos <= (offset + length - HEADER_SIZE)){
if (pos < 0) break;
//read record header
int info = LittleEndian.getUShort(data, pos);
pos += LittleEndian.SHORT_SIZE;
int type = LittleEndian.getUShort(data, pos);
pos += LittleEndian.SHORT_SIZE;
int size = (int)LittleEndian.getUInt(data, pos);
pos += LittleEndian.INT_SIZE;
//get name of the record by type
String recname = RecordTypes.recordName(type);
write(out, "<"+recname + " info=\""+info+"\" type=\""+type+"\" size=\""+size+"\" offset=\""+(pos-8)+"\"", padding);
if (hexHeader){
out.write(" header=\"");
dump(out, data, pos-8, 8, 0, false);
out.write("\"");
}
out.write(">" + CR);
padding++;
//this check works both for Escher and PowerPoint records
boolean isContainer = (info & 0x000F) == 0x000F;
if (isContainer) {
//continue to dump child records
dump(data, pos, size, padding);
} else {
//dump first 100 bytes of the atom data
dump(out, data, pos, Math.min(size, data.length-pos), padding, true);
}
padding--;
write(out, "</"+recname + ">" + CR, padding);
pos += size;
}
}
示例8: SectionDescriptor
public SectionDescriptor(byte[] buf, int offset)
{
fn = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
fcSepx = LittleEndian.getInt(buf, offset);
offset += LittleEndian.INT_SIZE;
fnMpr = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE;
fcMpr = LittleEndian.getInt(buf, offset);
}
示例9: writeTo
public void writeTo( HWPFOutputStream wordDocumentStream,
HWPFOutputStream tableStream ) throws IOException
{
tableStream.write( TEXT_PIECE_TABLE_TYPE );
byte[] table = _tpt.writeTo( wordDocumentStream );
byte[] numHolder = new byte[LittleEndian.INT_SIZE];
LittleEndian.putInt( numHolder, table.length );
tableStream.write( numHolder );
tableStream.write( table );
}
示例10: LFOData
LFOData( byte[] buf, int startOffset, int cLfolvl )
{
int offset = startOffset;
_cp = LittleEndian.getInt( buf, offset );
offset += LittleEndian.INT_SIZE;
_rgLfoLvl = new ListFormatOverrideLevel[cLfolvl];
for ( int x = 0; x < cLfolvl; x++ )
{
_rgLfoLvl[x] = new ListFormatOverrideLevel( buf, offset );
offset += _rgLfoLvl[x].getSizeInBytes();
}
}
示例11: getSizeInBytes
public int getSizeInBytes()
{
int result = 0;
result += LittleEndian.INT_SIZE;
for ( ListFormatOverrideLevel lfolvl : _rgLfoLvl )
result += lfolvl.getSizeInBytes();
return result;
}
示例12: toByteArray
public byte[] toByteArray()
{
int offset = 0;
byte[] buf = new byte[12];
LittleEndian.putShort(buf, offset, fn);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putInt(buf, offset, fcSepx);
offset += LittleEndian.INT_SIZE;
LittleEndian.putShort(buf, offset, fnMpr);
offset += LittleEndian.SHORT_SIZE;
LittleEndian.putInt(buf, offset, fcMpr);
return buf;
}
示例13: FIBFieldHandler
FIBFieldHandler(byte[] mainStream, int offset, int cbRgFcLcb, byte[] tableStream,
HashSet<Integer> offsetList, boolean areKnown)
{
_fields = new int[cbRgFcLcb * 2];
for (int x = 0; x < cbRgFcLcb; x++)
{
int fieldOffset = (x * FIELD_SIZE) + offset;
int dsOffset = LittleEndian.getInt(mainStream, fieldOffset);
fieldOffset += LittleEndian.INT_SIZE;
int dsSize = LittleEndian.getInt(mainStream, fieldOffset);
if (offsetList.contains(Integer.valueOf(x)) ^ areKnown)
{
if (dsSize > 0)
{
if (dsOffset + dsSize > tableStream.length)
{
log.log(POILogger.WARN, "Unhandled data structure points to outside the buffer. " +
"offset = " + dsOffset + ", length = " + dsSize +
", buffer length = " + tableStream.length);
}
else
{
UnhandledDataStructure unhandled = new UnhandledDataStructure(
tableStream, dsOffset, dsSize);
_unknownMap.put(Integer.valueOf(x), unhandled);
}
}
}
_fields[x*2] = dsOffset;
_fields[(x*2) + 1] = dsSize;
}
}
示例14: writeTo
void writeTo(byte[] mainStream, int offset, HWPFOutputStream tableStream)
throws IOException
{
for (int x = 0; x < _fields.length/2; x++)
{
UnhandledDataStructure ds = _unknownMap.get(Integer.valueOf(x));
if (ds != null)
{
_fields[x * 2] = tableStream.getOffset();
LittleEndian.putInt(mainStream, offset, tableStream.getOffset());
offset += LittleEndian.INT_SIZE;
byte[] buf = ds.getBuf();
tableStream.write(buf);
_fields[(x * 2) + 1] = buf.length;
LittleEndian.putInt(mainStream, offset, buf.length);
offset += LittleEndian.INT_SIZE;
}
else
{
LittleEndian.putInt(mainStream, offset, _fields[x * 2]);
offset += LittleEndian.INT_SIZE;
LittleEndian.putInt(mainStream, offset, _fields[(x * 2) + 1]);
offset += LittleEndian.INT_SIZE;
}
}
}
示例15: addSprm
public void addSprm(short opcode, int operand)
{
int addition = LittleEndian.SHORT_SIZE + LittleEndian.INT_SIZE;
ensureCapacity(addition);
LittleEndian.putShort(_buf, _offset, opcode);
_offset += LittleEndian.SHORT_SIZE;
LittleEndian.putInt(_buf, _offset, operand);
_offset += LittleEndian.INT_SIZE;
}