/// <summary> /// This method deSerializes the record from a byte array. /// </summary> /// <param name="data">The byte array containing the escher record information</param> /// <param name="offset">The starting offset into data</param> /// <param name="recordFactory">May be null since this is not a container record.</param> /// <returns>The number of bytes Read from the byte array.</returns> public override int FillFields(byte[] data, int offset, IEscherRecordFactory recordFactory ) { int bytesRemaining = ReadHeader(data, offset); int pos = offset + 8; field_1_blipTypeWin32 = data[pos]; field_2_blipTypeMacOS = data[pos + 1]; field_3_uid = new byte[16]; Array.Copy(data, pos + 2, field_3_uid, 0, 16); field_4_tag = LittleEndian.GetShort(data, pos + 18); field_5_size = LittleEndian.GetInt(data, pos + 20); field_6_ref = LittleEndian.GetInt(data, pos + 24); field_7_offset = LittleEndian.GetInt(data, pos + 28); field_8_usage = data[pos + 32]; field_9_name = data[pos + 33]; field_10_unused2 = data[pos + 34]; field_11_unused3 = data[pos + 35]; bytesRemaining -= 36; int bytesRead = 0; if (bytesRemaining > 0) { field_12_blipRecord = (EscherBlipRecord)recordFactory.CreateRecord(data, pos + 36); bytesRead = field_12_blipRecord.FillFields(data, pos + 36, recordFactory); } pos += 36 + bytesRead; bytesRemaining -= bytesRead; _remainingData = new byte[bytesRemaining]; Array.Copy(data, pos, _remainingData, 0, bytesRemaining); return(bytesRemaining + 8 + 36 + (field_12_blipRecord == null ? 0 : field_12_blipRecord.RecordSize)); }
/// <summary> /// This method deSerializes the record from a byte array. /// </summary> /// <param name="data">The byte array containing the escher record information</param> /// <param name="offset">The starting offset into data</param> /// <param name="recordFactory">May be null since this is not a container record.</param> /// <returns>The number of bytes Read from the byte array.</returns> public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory ) { int bytesRemaining = ReadHeader(data, offset); int pos = offset + 8; field_1_blipTypeWin32 = data[pos]; field_2_blipTypeMacOS = data[pos + 1]; Array.Copy(data, pos + 2, field_3_uid = new byte[16], 0, 16); field_4_tag = LittleEndian.GetShort(data, pos + 18); field_5_size = LittleEndian.GetInt(data, pos + 20); field_6_ref = LittleEndian.GetInt(data, pos + 24); field_7_offset = LittleEndian.GetInt(data, pos + 28); field_8_usage = data[pos + 32]; field_9_name = data[pos + 33]; field_10_unused2 = data[pos + 34]; field_11_unused3 = data[pos + 35]; bytesRemaining -= 36; int bytesRead = 0; if (bytesRemaining > 0) { field_12_blipRecord = (EscherBlipRecord)recordFactory.CreateRecord(data, pos + 36); bytesRead = field_12_blipRecord.FillFields(data, pos + 36, recordFactory); } pos += 36 + bytesRead; bytesRemaining -= bytesRead; // if (field_1_blipTypeWin32 == BT_PNG) // { // byte[] uid = new byte[16]; // Array.Copy( data, pos + 36, uid, 0, 16 ); // byte[] puid = new byte[16]; // Array.Copy( data, pos + 52, puid, 0, 16 ); // byte tag = data[pos+68]; // Console.WriteLine( HexDump.dump( data, 0, 0 ) ); // byte[] pngBytes = EscherBlipRecord.decompress( data, pos+69, bytesRemaining); // } remainingData = new byte[bytesRemaining]; Array.Copy(data, pos, remainingData, 0, bytesRemaining); return(bytesRemaining + 8 + 36 + (field_12_blipRecord == null ? 0 : field_12_blipRecord.RecordSize)); }
/// <summary> /// Constructs a picture object. /// </summary> /// <param name="blip">the underlying blip record containing the bitmap data.</param> public HSSFPictureData(EscherBlipRecord blip) { this.blip = blip; }
/// <summary> /// This method deSerializes the record from a byte array. /// </summary> /// <param name="data">The byte array containing the escher record information</param> /// <param name="offset">The starting offset into data</param> /// <param name="recordFactory">May be null since this is not a container record.</param> /// <returns>The number of bytes Read from the byte array.</returns> public override int FillFields(byte[] data, int offset, IEscherRecordFactory recordFactory ) { int bytesRemaining = ReadHeader(data, offset); int pos = offset + 8; field_1_blipTypeWin32 = data[pos]; field_2_blipTypeMacOS = data[pos + 1]; field_3_uid = new byte[16]; Array.Copy(data, pos + 2, field_3_uid, 0, 16); field_4_tag = LittleEndian.GetShort(data, pos + 18); field_5_size = LittleEndian.GetInt(data, pos + 20); field_6_ref = LittleEndian.GetInt(data, pos + 24); field_7_offset = LittleEndian.GetInt(data, pos + 28); field_8_usage = data[pos + 32]; field_9_name = data[pos + 33]; field_10_unused2 = data[pos + 34]; field_11_unused3 = data[pos + 35]; bytesRemaining -= 36; int bytesRead = 0; if (bytesRemaining > 0) { field_12_blipRecord = (EscherBlipRecord)recordFactory.CreateRecord(data, pos + 36); bytesRead = field_12_blipRecord.FillFields(data, pos + 36, recordFactory); } pos += 36 + bytesRead; bytesRemaining -= bytesRead; _remainingData = new byte[bytesRemaining]; Array.Copy(data, pos, _remainingData, 0, bytesRemaining); return bytesRemaining + 8 + 36 + (field_12_blipRecord == null ? 0 : field_12_blipRecord.RecordSize); }
/// <summary> /// Generates an escher record including the any children contained under that record. /// An exception is thrown if the record could not be generated. /// </summary> /// <param name="data">The byte array containing the records</param> /// <param name="offset">The starting offset into the byte array</param> /// <returns>The generated escher record</returns> public virtual EscherRecord CreateRecord(byte[] data, int offset) { short options = LittleEndian.GetShort(data, offset); short recordId = LittleEndian.GetShort(data, offset + 2); // int remainingBytes = LittleEndian.getInt( data, offset + 4 ); // Options of 0x000F means container record // However, EscherTextboxRecord are containers of records for the // host application, not of other Escher records, so treat them // differently if (IsContainer(options, recordId)) { EscherContainerRecord r = new EscherContainerRecord(); r.RecordId = recordId; r.Options = options; return r; } if (recordId >= EscherBlipRecord.RECORD_ID_START && recordId <= EscherBlipRecord.RECORD_ID_END) { EscherBlipRecord r; if (recordId == EscherBitmapBlip.RECORD_ID_DIB || recordId == EscherBitmapBlip.RECORD_ID_JPEG || recordId == EscherBitmapBlip.RECORD_ID_PNG) { r = new EscherBitmapBlip(); } else if (recordId == EscherMetafileBlip.RECORD_ID_EMF || recordId == EscherMetafileBlip.RECORD_ID_WMF || recordId == EscherMetafileBlip.RECORD_ID_PICT) { r = new EscherMetafileBlip(); } else { r = new EscherBlipRecord(); } r.RecordId = recordId; r.Options = options; return r; } //ConstructorInfo recordConstructor = (ConstructorInfo) recordsMap[header.RecordId]; ConstructorInfo recordConstructor = null; if (recordsMap.ContainsKey(recordId)) recordConstructor = recordsMap[recordId]; EscherRecord escherRecord = null; if (recordConstructor == null) { return new UnknownEscherRecord(); } try { escherRecord = (EscherRecord)recordConstructor.Invoke(new object[] { }); //escherRecord = (EscherRecord)Activator.CreateInstance(recordConstructor); } catch (Exception) { return new UnknownEscherRecord(); } escherRecord.RecordId = recordId; escherRecord.Options = options; return escherRecord; }
/// <summary> /// This method deSerializes the record from a byte array. /// </summary> /// <param name="data">The byte array containing the escher record information</param> /// <param name="offset">The starting offset into data</param> /// <param name="recordFactory">May be null since this is not a container record.</param> /// <returns>The number of bytes Read from the byte array.</returns> public override int FillFields(byte[] data, int offset, EscherRecordFactory recordFactory ) { int bytesRemaining = ReadHeader(data, offset); int pos = offset + 8; field_1_blipTypeWin32 = data[pos]; field_2_blipTypeMacOS = data[pos + 1]; Array.Copy(data, pos + 2, field_3_uid = new byte[16], 0, 16); field_4_tag = LittleEndian.GetShort(data, pos + 18); field_5_size = LittleEndian.GetInt(data, pos + 20); field_6_ref = LittleEndian.GetInt(data, pos + 24); field_7_offset = LittleEndian.GetInt(data, pos + 28); field_8_usage = data[pos + 32]; field_9_name = data[pos + 33]; field_10_unused2 = data[pos + 34]; field_11_unused3 = data[pos + 35]; bytesRemaining -= 36; int bytesRead = 0; if (bytesRemaining > 0) { field_12_blipRecord = (EscherBlipRecord)recordFactory.CreateRecord(data, pos + 36); bytesRead = field_12_blipRecord.FillFields(data, pos + 36, recordFactory); } pos += 36 + bytesRead; bytesRemaining -= bytesRead; // if (field_1_blipTypeWin32 == BT_PNG) // { // byte[] uid = new byte[16]; // Array.Copy( data, pos + 36, uid, 0, 16 ); // byte[] puid = new byte[16]; // Array.Copy( data, pos + 52, puid, 0, 16 ); // byte tag = data[pos+68]; // Console.WriteLine( HexDump.dump( data, 0, 0 ) ); // byte[] pngBytes = EscherBlipRecord.decompress( data, pos+69, bytesRemaining); // } remainingData = new byte[bytesRemaining]; Array.Copy(data, pos, remainingData, 0, bytesRemaining); return bytesRemaining + 8 + 36 + (field_12_blipRecord == null ? 0 : field_12_blipRecord.RecordSize); }
/// <summary> /// Generates an escher record including the any children contained under that record. /// An exception is thrown if the record could not be generated. /// </summary> /// <param name="data">The byte array containing the records</param> /// <param name="offset">The starting offset into the byte array</param> /// <returns>The generated escher record</returns> public virtual EscherRecord CreateRecord(byte[] data, int offset) { short options = LittleEndian.GetShort(data, offset); short recordId = LittleEndian.GetShort(data, offset + 2); // int remainingBytes = LittleEndian.getInt( data, offset + 4 ); // Options of 0x000F means container record // However, EscherTextboxRecord are containers of records for the // host application, not of other Escher records, so treat them // differently if (IsContainer(options, recordId)) { EscherContainerRecord r = new EscherContainerRecord(); r.RecordId = recordId; r.Options = options; return r; } if (recordId >= EscherBlipRecord.RECORD_ID_START && recordId <= EscherBlipRecord.RECORD_ID_END) { EscherBlipRecord r; if (recordId == EscherBitmapBlip.RECORD_ID_DIB || recordId == EscherBitmapBlip.RECORD_ID_JPEG || recordId == EscherBitmapBlip.RECORD_ID_PNG) { r = new EscherBitmapBlip(); } else if (recordId == EscherMetafileBlip.RECORD_ID_EMF || recordId == EscherMetafileBlip.RECORD_ID_WMF || recordId == EscherMetafileBlip.RECORD_ID_PICT) { r = new EscherMetafileBlip(); } else { r = new EscherBlipRecord(); } r.RecordId = recordId; r.Options = options; return r; } //ConstructorInfo recordConstructor = (ConstructorInfo) recordsMap[header.RecordId]; ConstructorInfo recordConstructor = null; if (recordsMap.ContainsKey(recordId)) recordConstructor = recordsMap[recordId]; EscherRecord escherRecord = null; if (recordConstructor == null) { return new UnknownEscherRecord(); } try { escherRecord = (EscherRecord)recordConstructor.Invoke(new object[] { }); //escherRecord = (EscherRecord)Activator.CreateInstance(recordConstructor); } catch (Exception) { return new UnknownEscherRecord(); } escherRecord.RecordId = recordId; escherRecord.Options = options; return escherRecord; }
/// <summary> /// Generates an escher record including the any children contained under that record. /// An exception is thrown if the record could not be generated. /// </summary> /// <param name="data">The byte array containing the records</param> /// <param name="offset">The starting offset into the byte array</param> /// <returns>The generated escher record</returns> public virtual EscherRecord CreateRecord(byte[] data, int offset) { EscherRecord.EscherRecordHeader header = EscherRecord.EscherRecordHeader.ReadHeader(data, offset); // Options of 0x000F means container record // However, EscherTextboxRecord are containers of records for the // host application, not of other Escher records, so treat them // differently if ((header.Options & (short)0x000F) == (short)0x000F && header.RecordId != EscherTextboxRecord.RECORD_ID) { EscherContainerRecord r = new EscherContainerRecord(); r.RecordId = header.RecordId; r.Options = header.Options; return(r); } else if (header.RecordId >= EscherBlipRecord.RECORD_ID_START && header.RecordId <= EscherBlipRecord.RECORD_ID_END) { EscherBlipRecord r; if (header.RecordId == EscherBitmapBlip.RECORD_ID_DIB || header.RecordId == EscherBitmapBlip.RECORD_ID_JPEG || header.RecordId == EscherBitmapBlip.RECORD_ID_PNG) { r = new EscherBitmapBlip(); } else if (header.RecordId == EscherMetafileBlip.RECORD_ID_EMF || header.RecordId == EscherMetafileBlip.RECORD_ID_WMF || header.RecordId == EscherMetafileBlip.RECORD_ID_PICT) { r = new EscherMetafileBlip(); } else { r = new EscherBlipRecord(); } r.RecordId = header.RecordId; r.Options = header.Options; return(r); } else { //ConstructorInfo recordConstructor = (ConstructorInfo) recordsMap[header.RecordId]; Type record = (Type)recordsMap[header.RecordId]; EscherRecord escherRecord = null; //if ( recordConstructor != null ) if (record != null) { try { escherRecord = (EscherRecord)Activator.CreateInstance(record); escherRecord.RecordId = header.RecordId; escherRecord.Options = header.Options; } catch (Exception) { escherRecord = null; } } return(escherRecord == null ? new UnknownEscherRecord() : escherRecord); } }
/// <summary> /// Generates an escher record including the any children contained under that record. /// An exception is thrown if the record could not be generated. /// </summary> /// <param name="data">The byte array containing the records</param> /// <param name="offset">The starting offset into the byte array</param> /// <returns>The generated escher record</returns> public virtual EscherRecord CreateRecord(byte[] data, int offset) { EscherRecord.EscherRecordHeader header = EscherRecord.EscherRecordHeader.ReadHeader(data, offset); // Options of 0x000F means container record // However, EscherTextboxRecord are containers of records for the // host application, not of other Escher records, so treat them // differently if ((header.Options & (short)0x000F) == (short)0x000F && header.RecordId != EscherTextboxRecord.RECORD_ID) { EscherContainerRecord r = new EscherContainerRecord(); r.RecordId = header.RecordId; r.Options = header.Options; return r; } else if (header.RecordId >= EscherBlipRecord.RECORD_ID_START && header.RecordId <= EscherBlipRecord.RECORD_ID_END) { EscherBlipRecord r; if (header.RecordId == EscherBitmapBlip.RECORD_ID_DIB || header.RecordId == EscherBitmapBlip.RECORD_ID_JPEG || header.RecordId == EscherBitmapBlip.RECORD_ID_PNG) { r = new EscherBitmapBlip(); } else if (header.RecordId == EscherMetafileBlip.RECORD_ID_EMF || header.RecordId == EscherMetafileBlip.RECORD_ID_WMF || header.RecordId == EscherMetafileBlip.RECORD_ID_PICT) { r = new EscherMetafileBlip(); } else { r = new EscherBlipRecord(); } r.RecordId = header.RecordId; r.Options = header.Options; return r; } else { //ConstructorInfo recordConstructor = (ConstructorInfo) recordsMap[header.RecordId]; Type record = (Type)recordsMap[header.RecordId]; EscherRecord escherRecord = null; //if ( recordConstructor != null ) if (record != null) { try { escherRecord = (EscherRecord)Activator.CreateInstance(record); escherRecord.RecordId = header.RecordId; escherRecord.Options = header.Options; } catch (Exception) { escherRecord = null; } } return escherRecord == null ? new UnknownEscherRecord() : escherRecord; } }