private void setShort(int offset, int value) { LittleEndian.putShort( _rawData, offset, (short)value); } private int getInt(int offset) {
/** * write the value out to an array of bytes at the appropriate * offset * * @param data the array of bytes to which the value is to be * written * * @exception ArrayIndexOutOfBoundsException if the offset is out * of range */ public void writeToBytes(final byte [] data) throws ArrayIndexOutOfBoundsException { LittleEndian.putShort(data, _offset, _value); }
/** * Serialize the simple part of the escher record. * * @return the number of bytes serialized. */ @Override public int serializeSimplePart( byte[] data, int offset ) { LittleEndian.putShort(data, offset, getId()); LittleEndian.putInt(data, offset + 2, propertyValue); return 6; }
/** * Serializes the simple part of this property. i.e. the first 6 bytes. */ @Override public int serializeSimplePart(byte[] data, int pos) { LittleEndian.putShort(data, pos, getId()); LittleEndian.putInt(data, pos + 2, _complexData.length); return 6; }
@Override public int serialize(int offset, byte[] data, EscherSerializationListener listener) { listener.beforeRecordSerialize(offset, getRecordId(), this); LittleEndian.putShort( data, offset, getOptions() ); LittleEndian.putShort( data, offset + 2, getRecordId() ); System.arraycopy( field_pictureData, 0, data, offset + 4, field_pictureData.length ); listener.afterRecordSerialize(offset + 4 + field_pictureData.length, getRecordId(), field_pictureData.length + 4, this); return field_pictureData.length + 4; }
@Override public int serialize(int offset, byte[] data, EscherSerializationListener listener) { listener.beforeRecordSerialize( offset, getRecordId(), this ); if (remainingData == null) { remainingData = new byte[0]; } LittleEndian.putShort( data, offset, getOptions() ); LittleEndian.putShort( data, offset + 2, getRecordId() ); LittleEndian.putInt( data, offset + 4, remainingData.length ); System.arraycopy( remainingData, 0, data, offset + 8, remainingData.length ); int pos = offset + 8 + remainingData.length; listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this ); return pos - offset; }
/** * Serializes the simple part of this property. ie the first 6 bytes. * * Needs special code to handle the case when the size doesn't * include the size of the header block */ @Override public int serializeSimplePart(byte[] data, int pos) { LittleEndian.putShort(data, pos, getId()); int recordSize = getComplexData().length; if(!sizeIncludesHeaderSize) { recordSize -= 6; } LittleEndian.putInt(data, pos + 2, recordSize); return 6; }
@Override public int serialize( int offset, byte[] data, EscherSerializationListener listener ) { listener.beforeRecordSerialize(offset, getRecordId(), this); LittleEndian.putShort( data, offset, getOptions() ); LittleEndian.putShort( data, offset + 2, getRecordId() ); LittleEndian.putInt( data, offset + 4, getRecordSize() - HEADER_SIZE ); int pos = offset + HEADER_SIZE; System.arraycopy( field_1_UID, 0, data, pos, 16 ); data[pos + 16] = field_2_marker; byte pd[] = getPicturedata(); System.arraycopy( pd, 0, data, pos + 17, pd.length ); listener.afterRecordSerialize(offset + getRecordSize(), getRecordId(), getRecordSize(), this); return HEADER_SIZE + 16 + 1 + pd.length; }
@Override public int serialize(int offset, byte[] data, EscherSerializationListener listener) { listener.beforeRecordSerialize( offset, getRecordId(), this ); LittleEndian.putShort(data, offset, getOptions()); LittleEndian.putShort(data, offset+2, getRecordId()); int remainingBytes = thedata.length; for (EscherRecord r : _childRecords) { remainingBytes += r.getRecordSize(); } LittleEndian.putInt(data, offset+4, remainingBytes); System.arraycopy(thedata, 0, data, offset+8, thedata.length); int pos = offset+8+thedata.length; for (EscherRecord r : _childRecords) { pos += r.serialize(pos, data, listener ); } listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this ); return pos - offset; }
public void setNumberOfElementsInMemory(int numberOfElements) { int expectedArraySize = numberOfElements * getActualSizeOfElements(getSizeOfElements()) + FIXED_SIZE; if (expectedArraySize != getComplexData().length) { byte[] newArray = IOUtils.safelyAllocate(expectedArraySize, MAX_RECORD_LENGTH); System.arraycopy(getComplexData(), 0, newArray, 0, expectedArraySize); setComplexData(newArray); } LittleEndian.putShort(getComplexData(), 2, (short) numberOfElements); }
@Override public int serialize( int offset, byte[] data, EscherSerializationListener listener ) { listener.beforeRecordSerialize( offset, getRecordId(), this ); LittleEndian.putShort(data, offset, getOptions()); LittleEndian.putShort(data, offset+2, getRecordId()); int remainingBytes = thedata.length; LittleEndian.putInt(data, offset+4, remainingBytes); System.arraycopy(thedata, 0, data, offset+8, thedata.length); int pos = offset+8+thedata.length; listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this ); int size = pos - offset; if (size != getRecordSize()) { throw new RecordFormatException(size + " bytes written but getRecordSize() reports " + getRecordSize()); } return size; }
public void setNumberOfElementsInArray(int numberOfElements) { int expectedArraySize = numberOfElements * getActualSizeOfElements(getSizeOfElements()) + FIXED_SIZE; if (expectedArraySize != getComplexData().length) { byte[] newArray = IOUtils.safelyAllocate(expectedArraySize, MAX_RECORD_LENGTH); System.arraycopy(getComplexData(), 0, newArray, 0, getComplexData().length); setComplexData(newArray); } LittleEndian.putShort(getComplexData(), 0, (short) numberOfElements); }
public void setSizeOfElements(int sizeOfElements) { LittleEndian.putShort( getComplexData(), 4, (short) sizeOfElements ); int expectedArraySize = getNumberOfElementsInArray() * getActualSizeOfElements(getSizeOfElements()) + FIXED_SIZE; if (expectedArraySize != getComplexData().length) { // Keep just the first 6 bytes. The rest is no good to us anyway. byte[] newArray = IOUtils.safelyAllocate(expectedArraySize, MAX_RECORD_LENGTH); System.arraycopy( getComplexData(), 0, newArray, 0, 6 ); setComplexData(newArray); } }
@Override public int serialize( int offset, byte[] data, EscherSerializationListener listener ) { listener.beforeRecordSerialize( offset, getRecordId(), this ); LittleEndian.putShort( data, offset, getOptions() ); LittleEndian.putShort( data, offset + 2, getRecordId() ); LittleEndian.putInt( data, offset + 4, 8 ); LittleEndian.putInt( data, offset + 8, field_1_numShapes ); LittleEndian.putInt( data, offset + 12, field_2_lastMSOSPID ); // System.arraycopy( remainingData, 0, data, offset + 26, remainingData.length ); // int pos = offset + 8 + 18 + remainingData.length; listener.afterRecordSerialize( offset + 16, getRecordId(), getRecordSize(), this ); return getRecordSize(); }
@Override public int serialize(int offset, byte[] data, EscherSerializationListener listener) { listener.beforeRecordSerialize( offset, getRecordId(), this ); int pos = offset; LittleEndian.putShort( data, pos, getOptions() ); pos += 2; LittleEndian.putShort( data, pos, getRecordId() ); pos += 2; LittleEndian.putInt( data, pos, getRecordSize()-8 ); pos += 4; LittleEndian.putInt( data, pos, field_1_dx1 ); pos += 4; LittleEndian.putInt( data, pos, field_2_dy1 ); pos += 4; LittleEndian.putInt( data, pos, field_3_dx2 ); pos += 4; LittleEndian.putInt( data, pos, field_4_dy2 ); pos += 4; listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this ); return pos - offset; }
@Override public int serialize( int offset, byte[] data, EscherSerializationListener listener ) { // int field_2_numIdClusters = field_5_fileIdClusters.length + 1; listener.beforeRecordSerialize( offset, getRecordId(), this ); int pos = offset; LittleEndian.putShort( data, pos, getOptions() ); pos += 2; LittleEndian.putShort( data, pos, getRecordId() ); pos += 2; int remainingBytes = getRecordSize() - 8; LittleEndian.putInt( data, pos, remainingBytes ); pos += 4; LittleEndian.putInt( data, pos, field_1_color1 ); pos += 4; LittleEndian.putInt( data, pos, field_2_color2 ); pos += 4; LittleEndian.putInt( data, pos, field_3_color3 ); pos += 4; LittleEndian.putInt( data, pos, field_4_color4 ); pos += 4; listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this ); return getRecordSize(); }
@Override public int serialize( int offset, byte[] data, EscherSerializationListener listener ) { listener.beforeRecordSerialize( offset, getRecordId(), this ); LittleEndian.putShort( data, offset, getOptions() ); LittleEndian.putShort( data, offset + 2, getRecordId() ); int remainingBytes = 16; LittleEndian.putInt( data, offset + 4, remainingBytes ); LittleEndian.putInt( data, offset + 8, field_1_rectX1 ); LittleEndian.putInt( data, offset + 12, field_2_rectY1 ); LittleEndian.putInt( data, offset + 16, field_3_rectX2 ); LittleEndian.putInt( data, offset + 20, field_4_rectY2 ); // System.arraycopy( remainingData, 0, data, offset + 26, remainingData.length ); // int pos = offset + 8 + 18 + remainingData.length; listener.afterRecordSerialize( offset + getRecordSize(), getRecordId(), offset + getRecordSize(), this ); return 8 + 16; }
@Override public int serialize(int offset, byte[] data, EscherSerializationListener listener) { listener.beforeRecordSerialize( offset, getRecordId(), this ); int pos = offset; LittleEndian.putShort( data, pos, getOptions() ); pos += 2; LittleEndian.putShort( data, pos, getRecordId() ); pos += 2; int remainingBytes = getRecordSize() - 8; LittleEndian.putInt( data, pos, remainingBytes ); pos += 4; LittleEndian.putInt( data, pos, field_1_shapeIdMax ); pos += 4; LittleEndian.putInt( data, pos, getNumIdClusters() ); pos += 4; LittleEndian.putInt( data, pos, field_3_numShapesSaved ); pos += 4; LittleEndian.putInt( data, pos, field_4_drawingsSaved ); pos += 4; for (FileIdCluster fic : field_5_fileIdClusters) { LittleEndian.putInt( data, pos, fic.getDrawingGroupId() ); pos += 4; LittleEndian.putInt( data, pos, fic.getNumShapeIdsUsed() ); pos += 4; } listener.afterRecordSerialize( pos, getRecordId(), getRecordSize(), this ); return getRecordSize(); }