1 16 package org.apache.poi.hssf.record; 17 18 import org.apache.poi.util.LittleEndian; 19 20 public class DrawingRecord extends Record 21 { 22 public static final short sid = 0xEC; 23 24 private byte[] recordData; 25 26 public DrawingRecord() 27 { 28 } 29 30 public DrawingRecord( short id, short size, byte[] data ) 31 { 32 super( id, size, data ); 33 } 34 35 public DrawingRecord( short id, short size, byte[] data, int offset ) 36 { 37 super( id, size, data, offset ); 38 } 39 40 45 protected void validateSid(short id) 46 { 47 if (id != sid) 48 { 49 throw new RecordFormatException("Not a MSODRAWING record"); 50 } 51 } 52 53 protected void fillFields( byte[] data, short size, int offset ) 54 { 55 if (offset == 0 && size == data.length) 56 { 57 recordData = data; 58 } 59 else 60 { 61 recordData = new byte[size]; 62 System.arraycopy(data, offset, recordData, 0, size); 63 } 64 } 65 66 protected void fillFields( byte[] data, short size ) 67 { 68 recordData = data; 69 } 70 71 public int serialize( int offset, byte[] data ) 72 { 73 if (recordData == null) 74 { 75 recordData = new byte[ 0 ]; 76 } 77 LittleEndian.putShort(data, 0 + offset, sid); 78 LittleEndian.putShort(data, 2 + offset, ( short ) (recordData.length)); 79 if (recordData.length > 0) 80 { 81 System.arraycopy(recordData, 0, data, 4 + offset, recordData.length); 82 } 83 return getRecordSize(); 84 } 85 86 public int getRecordSize() 87 { 88 int retval = 4; 89 90 if (recordData != null) 91 { 92 retval += recordData.length; 93 } 94 return retval; 95 } 96 97 public short getSid() 98 { 99 return sid; 100 } 101 102 public byte[] getData() 103 { 104 return recordData; 105 } 106 107 public void setData( byte[] thedata ) 108 { 109 this.recordData = thedata; 110 } 111 112 } 113 | Popular Tags |