1 2 17 18 package org.apache.poi.ddf; 19 20 import org.apache.poi.util.HexDump; 21 import org.apache.poi.util.LittleEndian; 22 import org.apache.poi.hssf.record.RecordFormatException; 23 24 30 public class EscherSpgrRecord 31 extends EscherRecord 32 { 33 public static final short RECORD_ID = (short) 0xF009; 34 public static final String RECORD_DESCRIPTION = "MsofbtSpgr"; 35 36 private int field_1_rectX1; 37 private int field_2_rectY1; 38 private int field_3_rectX2; 39 private int field_4_rectY2; 40 41 49 public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory ) 50 { 51 int bytesRemaining = readHeader( data, offset ); 52 int pos = offset + 8; 53 int size = 0; 54 field_1_rectX1 = LittleEndian.getInt( data, pos + size );size+=4; 55 field_2_rectY1 = LittleEndian.getInt( data, pos + size );size+=4; 56 field_3_rectX2 = LittleEndian.getInt( data, pos + size );size+=4; 57 field_4_rectY2 = LittleEndian.getInt( data, pos + size );size+=4; 58 bytesRemaining -= size; 59 if (bytesRemaining != 0) throw new RecordFormatException("Expected no remaining bytes but got " + bytesRemaining); 60 return 8 + size + bytesRemaining; 63 } 64 65 75 public int serialize( int offset, byte[] data, EscherSerializationListener listener ) 76 { 77 listener.beforeRecordSerialize( offset, getRecordId(), this ); 78 LittleEndian.putShort( data, offset, getOptions() ); 79 LittleEndian.putShort( data, offset + 2, getRecordId() ); 80 int remainingBytes = 16; 81 LittleEndian.putInt( data, offset + 4, remainingBytes ); 82 LittleEndian.putInt( data, offset + 8, field_1_rectX1 ); 83 LittleEndian.putInt( data, offset + 12, field_2_rectY1 ); 84 LittleEndian.putInt( data, offset + 16, field_3_rectX2 ); 85 LittleEndian.putInt( data, offset + 20, field_4_rectY2 ); 86 listener.afterRecordSerialize( offset + getRecordSize(), getRecordId(), offset + getRecordSize(), this ); 89 return 8 + 16; 90 } 91 92 97 public int getRecordSize() 98 { 99 return 8 + 16; 100 } 101 102 105 public short getRecordId() 106 { 107 return RECORD_ID; 108 } 109 110 113 public String getRecordName() 114 { 115 return "Spgr"; 116 } 117 118 121 public String toString() 122 { 123 String nl = System.getProperty("line.separator"); 124 125 return getClass().getName() + ":" + nl + 137 " RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl + 138 " Options: 0x" + HexDump.toHex(getOptions()) + nl + 139 " RectX: " + field_1_rectX1 + nl + 140 " RectY: " + field_2_rectY1 + nl + 141 " RectWidth: " + field_3_rectX2 + nl + 142 " RectHeight: " + field_4_rectY2 + nl; 143 144 } 145 146 149 public int getRectX1() 150 { 151 return field_1_rectX1; 152 } 153 154 157 public void setRectX1( int x1 ) 158 { 159 this.field_1_rectX1 = x1; 160 } 161 162 165 public int getRectY1() 166 { 167 return field_2_rectY1; 168 } 169 170 173 public void setRectY1( int y1 ) 174 { 175 this.field_2_rectY1 = y1; 176 } 177 178 181 public int getRectX2() 182 { 183 return field_3_rectX2; 184 } 185 186 189 public void setRectX2( int x2 ) 190 { 191 this.field_3_rectX2 = x2; 192 } 193 194 197 public int getRectY2() 198 { 199 return field_4_rectY2; 200 } 201 202 205 public void setRectY2( int field_4_rectY2 ) 206 { 207 this.field_4_rectY2 = field_4_rectY2; 208 } 209 } 210 | Popular Tags |