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 (int i = 0; i < field_5_fileIdClusters.length; i++) { LittleEndian.putInt(data, pos, field_5_fileIdClusters[i].field_1_drawingGroupId); pos += 4; LittleEndian.putInt(data, pos, field_5_fileIdClusters[i].field_2_numShapeIdsUsed); pos += 4; } listener.afterRecordSerialize(pos, getRecordId(), getRecordSize(), this); return getRecordSize(); }
public void serialize(byte[] data, int offset) { LittleEndian.putShort(data, 0x0 + offset, field_1_rgf); LittleEndian.putShort(data, 0x2 + offset, field_2_unused); field_3_brcTop.serialize(data, 0x4 + offset); field_4_brcLeft.serialize(data, 0x8 + offset); field_5_brcBottom.serialize(data, 0xc + offset); field_6_brcRight.serialize(data, 0x10 + offset); }
static void write(Sttb sttb, HWPFOutputStream tableStream) throws IOException { final int headerSize = sttb.cDataLength == 2 ? 6 : 8; byte[] header = new byte[headerSize]; LittleEndian.putShort(header, 0, (short) 0xffff); if (sttb.data == null || sttb.data.length == 0) { if (sttb.cDataLength == 4) { LittleEndian.putInt(header, 2, 0); LittleEndian.putUShort(header, 6, sttb.cbExtra); tableStream.write(header); return; } LittleEndian.putUShort(header, 2, 0); LittleEndian.putUShort(header, 4, sttb.cbExtra); tableStream.write(header); return; } if (sttb.cDataLength == 4) { LittleEndian.putInt(header, 2, sttb.data.length); LittleEndian.putUShort(header, 6, sttb.cbExtra); tableStream.write(header); } else { LittleEndian.putUShort(header, 2, sttb.data.length); LittleEndian.putUShort(header, 4, sttb.cbExtra); tableStream.write(header); } for (int i = 0; i < sttb.data.length; i++) { String entry = sttb.data[i]; if (entry == null) { // is it correct? tableStream.write(new byte[] {-1, 0}); continue; } byte[] buf = new byte[entry.length() * 2 + sttb.cbExtra + 2]; LittleEndian.putShort(buf, 0, (short) entry.length()); StringUtil.putUnicodeLE(entry, buf, 2); if (sttb.extraData != null && i < sttb.extraData.length && sttb.extraData[i] != null) System.arraycopy( sttb.extraData[i], 0, buf, entry.length() * 2, Math.min(sttb.extraData[i].length, sttb.cbExtra)); tableStream.write(buf); } }
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; }
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; }
/** * Writes a two-byte value (short) to an output stream. * * @param out The stream to write to. * @param n The value to write. * @return The number of bytes that have been written. * @exception IOException if an I/O error occurs */ public static int writeToStream(final OutputStream out, final short n) throws IOException { final int length = LittleEndian.SHORT_SIZE; byte[] buffer = new byte[length]; LittleEndian.putShort(buffer, 0, n); // FIXME: unsigned out.write(buffer, 0, length); return length; }
/** Constructs a new empty sound container. */ protected SoundData() { _header = new byte[8]; _data = new byte[0]; LittleEndian.putShort(_header, 2, (short) getRecordType()); LittleEndian.putInt(_header, 4, _data.length); }
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; }
/** * Convert the supplied java Date into a SystemTime struct, and write it into the supplied byte * array. */ public static void storeDate(Date date, byte[] dest, int offset) { Calendar cal = new GregorianCalendar(); cal.setTime(date); LittleEndian.putShort(dest, offset + 0, (short) cal.get(Calendar.YEAR)); LittleEndian.putShort(dest, offset + 2, (short) (cal.get(Calendar.MONTH) + 1)); LittleEndian.putShort(dest, offset + 4, (short) (cal.get(Calendar.DAY_OF_WEEK) - 1)); LittleEndian.putShort(dest, offset + 6, (short) cal.get(Calendar.DAY_OF_MONTH)); LittleEndian.putShort(dest, offset + 8, (short) cal.get(Calendar.HOUR_OF_DAY)); LittleEndian.putShort(dest, offset + 10, (short) cal.get(Calendar.MINUTE)); LittleEndian.putShort(dest, offset + 12, (short) cal.get(Calendar.SECOND)); LittleEndian.putShort(dest, offset + 14, (short) cal.get(Calendar.MILLISECOND)); }
public int serialize(int offset, byte[] data) { int pos = 0; LittleEndian.putShort(data, 0 + offset, sid); LittleEndian.putShort(data, 2 + offset, (short) (getRecordSize() - 4)); LittleEndian.putShort(data, 4 + offset + pos, field_1_categoryDataType); LittleEndian.putShort(data, 6 + offset + pos, field_2_valuesDataType); LittleEndian.putShort(data, 8 + offset + pos, field_3_numCategories); LittleEndian.putShort(data, 10 + offset + pos, field_4_numValues); LittleEndian.putShort(data, 12 + offset + pos, field_5_bubbleSeriesType); LittleEndian.putShort(data, 14 + offset + pos, field_6_numBubbleValues); return getRecordSize(); }
void writeTo(byte mainStream[], int offset, HWPFOutputStream tableStream) throws IOException { int length = _fields.length / 2; LittleEndian.putShort(mainStream, offset, (short) length); offset += 2; for (int x = 0; x < length; x++) { UnhandledDataStructure ds = (UnhandledDataStructure) _unknownMap.get(Integer.valueOf(x)); if (ds != null) { _fields[x * 2] = tableStream.getOffset(); LittleEndian.putInt(mainStream, offset, tableStream.getOffset()); offset += 4; byte buf[] = ds.getBuf(); tableStream.write(buf); _fields[x * 2 + 1] = buf.length; LittleEndian.putInt(mainStream, offset, buf.length); offset += 4; } else { LittleEndian.putInt(mainStream, offset, _fields[x * 2]); offset += 4; LittleEndian.putInt(mainStream, offset, _fields[x * 2 + 1]); offset += 4; } } }
public int serialize(int offset, byte[] data) { LittleEndian.putShort(data, 0 + offset, sid); LittleEndian.putShort(data, 2 + offset, ((short) 0x02)); // 2 bytes (6 total) LittleEndian.putShort(data, 4 + offset, field_1_save_link_values); return getRecordSize(); }