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 23 import java.io.ByteArrayOutputStream ; 24 25 34 public class EscherClientAnchorRecord 35 extends EscherRecord 36 { 37 public static final short RECORD_ID = (short) 0xF010; 38 public static final String RECORD_DESCRIPTION = "MsofbtClientAnchor"; 39 40 private short field_1_flag; 41 private short field_2_col1; 42 private short field_3_dx1; 43 private short field_4_row1; 44 private short field_5_dy1; 45 private short field_6_col2; 46 private short field_7_dx2; 47 private short field_8_row2; 48 private short field_9_dy2; 49 private byte[] remainingData; 50 51 59 public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory ) 60 { 61 int bytesRemaining = readHeader( data, offset ); 62 int pos = offset + 8; 63 int size = 0; 64 field_1_flag = LittleEndian.getShort( data, pos + size ); size += 2; 65 field_2_col1 = LittleEndian.getShort( data, pos + size ); size += 2; 66 field_3_dx1 = LittleEndian.getShort( data, pos + size ); size += 2; 67 field_4_row1 = LittleEndian.getShort( data, pos + size ); size += 2; 68 field_5_dy1 = LittleEndian.getShort( data, pos + size ); size += 2; 69 field_6_col2 = LittleEndian.getShort( data, pos + size ); size += 2; 70 field_7_dx2 = LittleEndian.getShort( data, pos + size ); size += 2; 71 field_8_row2 = LittleEndian.getShort( data, pos + size ); size += 2; 72 field_9_dy2 = LittleEndian.getShort( data, pos + size ); size += 2; 73 bytesRemaining -= size; 74 remainingData = new byte[bytesRemaining]; 75 System.arraycopy( data, pos + size, remainingData, 0, bytesRemaining ); 76 return 8 + size + bytesRemaining; 77 } 78 79 88 public int serialize( int offset, byte[] data, EscherSerializationListener listener ) 89 { 90 listener.beforeRecordSerialize( offset, getRecordId(), this ); 91 92 if (remainingData == null) remainingData = new byte[0]; 93 LittleEndian.putShort( data, offset, getOptions() ); 94 LittleEndian.putShort( data, offset + 2, getRecordId() ); 95 int remainingBytes = remainingData.length + 18; 96 LittleEndian.putInt( data, offset + 4, remainingBytes ); 97 LittleEndian.putShort( data, offset + 8, field_1_flag ); 98 LittleEndian.putShort( data, offset + 10, field_2_col1 ); 99 LittleEndian.putShort( data, offset + 12, field_3_dx1 ); 100 LittleEndian.putShort( data, offset + 14, field_4_row1 ); 101 LittleEndian.putShort( data, offset + 16, field_5_dy1 ); 102 LittleEndian.putShort( data, offset + 18, field_6_col2 ); 103 LittleEndian.putShort( data, offset + 20, field_7_dx2 ); 104 LittleEndian.putShort( data, offset + 22, field_8_row2 ); 105 LittleEndian.putShort( data, offset + 24, field_9_dy2 ); 106 System.arraycopy( remainingData, 0, data, offset + 26, remainingData.length ); 107 int pos = offset + 8 + 18 + remainingData.length; 108 109 listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this ); 110 return pos - offset; 111 } 112 113 118 public int getRecordSize() 119 { 120 return 8 + 18 + (remainingData == null ? 0 : remainingData.length); 121 } 122 123 126 public short getRecordId() 127 { 128 return RECORD_ID; 129 } 130 131 134 public String getRecordName() 135 { 136 return "ClientAnchor"; 137 } 138 139 144 public String toString() 145 { 146 String nl = System.getProperty("line.separator"); 147 148 String extraData; 149 ByteArrayOutputStream b = new ByteArrayOutputStream (); 150 try 151 { 152 HexDump.dump(this.remainingData, 0, b, 0); 153 extraData = b.toString(); 154 } 155 catch ( Exception e ) 156 { 157 extraData = "error"; 158 } 159 return getClass().getName() + ":" + nl + 160 " RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl + 161 " Options: 0x" + HexDump.toHex(getOptions()) + nl + 162 " Flag: " + field_1_flag + nl + 163 " Col1: " + field_2_col1 + nl + 164 " DX1: " + field_3_dx1 + nl + 165 " Row1: " + field_4_row1 + nl + 166 " DY1: " + field_5_dy1 + nl + 167 " Col2: " + field_6_col2 + nl + 168 " DX2: " + field_7_dx2 + nl + 169 " Row2: " + field_8_row2 + nl + 170 " DY2: " + field_9_dy2 + nl + 171 " Extra Data:" + nl + extraData; 172 173 } 174 175 178 public short getFlag() 179 { 180 return field_1_flag; 181 } 182 183 186 public void setFlag( short field_1_flag ) 187 { 188 this.field_1_flag = field_1_flag; 189 } 190 191 194 public short getCol1() 195 { 196 return field_2_col1; 197 } 198 199 202 public void setCol1( short field_2_col1 ) 203 { 204 this.field_2_col1 = field_2_col1; 205 } 206 207 210 public short getDx1() 211 { 212 return field_3_dx1; 213 } 214 215 218 public void setDx1( short field_3_dx1 ) 219 { 220 this.field_3_dx1 = field_3_dx1; 221 } 222 223 226 public short getRow1() 227 { 228 return field_4_row1; 229 } 230 231 234 public void setRow1( short field_4_row1 ) 235 { 236 this.field_4_row1 = field_4_row1; 237 } 238 239 242 public short getDy1() 243 { 244 return field_5_dy1; 245 } 246 247 250 public void setDy1( short field_5_dy1 ) 251 { 252 this.field_5_dy1 = field_5_dy1; 253 } 254 255 258 public short getCol2() 259 { 260 return field_6_col2; 261 } 262 263 266 public void setCol2( short field_6_col2 ) 267 { 268 this.field_6_col2 = field_6_col2; 269 } 270 271 274 public short getDx2() 275 { 276 return field_7_dx2; 277 } 278 279 282 public void setDx2( short field_7_dx2 ) 283 { 284 this.field_7_dx2 = field_7_dx2; 285 } 286 287 290 public short getRow2() 291 { 292 return field_8_row2; 293 } 294 295 298 public void setRow2( short field_8_row2 ) 299 { 300 this.field_8_row2 = field_8_row2; 301 } 302 303 306 public short getDy2() 307 { 308 return field_9_dy2; 309 } 310 311 314 public void setDy2( short field_9_dy2 ) 315 { 316 this.field_9_dy2 = field_9_dy2; 317 } 318 319 322 public byte[] getRemainingData() 323 { 324 return remainingData; 325 } 326 327 330 public void setRemainingData( byte[] remainingData ) 331 { 332 this.remainingData = remainingData; 333 } 334 } 335 | Popular Tags |