1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 24 import org.apache.poi.util.*; 25 26 33 public class CommonObjectDataSubRecord 34 extends SubRecord 35 { 36 public final static short sid = 0x15; 37 private short field_1_objectType; 38 public final static short OBJECT_TYPE_GROUP = 0; 39 public final static short OBJECT_TYPE_LINE = 1; 40 public final static short OBJECT_TYPE_RECTANGLE = 2; 41 public final static short OBJECT_TYPE_OVAL = 3; 42 public final static short OBJECT_TYPE_ARC = 4; 43 public final static short OBJECT_TYPE_CHART = 5; 44 public final static short OBJECT_TYPE_TEXT = 6; 45 public final static short OBJECT_TYPE_BUTTON = 7; 46 public final static short OBJECT_TYPE_PICTURE = 8; 47 public final static short OBJECT_TYPE_POLYGON = 9; 48 public final static short OBJECT_TYPE_RESERVED1 = 10; 49 public final static short OBJECT_TYPE_CHECKBOX = 11; 50 public final static short OBJECT_TYPE_OPTION_BUTTON = 12; 51 public final static short OBJECT_TYPE_EDIT_BOX = 13; 52 public final static short OBJECT_TYPE_LABEL = 14; 53 public final static short OBJECT_TYPE_DIALOG_BOX = 15; 54 public final static short OBJECT_TYPE_SPINNER = 16; 55 public final static short OBJECT_TYPE_SCROLL_BAR = 17; 56 public final static short OBJECT_TYPE_LIST_BOX = 18; 57 public final static short OBJECT_TYPE_GROUP_BOX = 19; 58 public final static short OBJECT_TYPE_COMBO_BOX = 20; 59 public final static short OBJECT_TYPE_RESERVED2 = 21; 60 public final static short OBJECT_TYPE_RESERVED3 = 22; 61 public final static short OBJECT_TYPE_RESERVED4 = 23; 62 public final static short OBJECT_TYPE_RESERVED5 = 24; 63 public final static short OBJECT_TYPE_COMMENT = 25; 64 public final static short OBJECT_TYPE_RESERVED6 = 26; 65 public final static short OBJECT_TYPE_RESERVED7 = 27; 66 public final static short OBJECT_TYPE_RESERVED8 = 28; 67 public final static short OBJECT_TYPE_RESERVED9 = 29; 68 public final static short OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING = 30; 69 private short field_2_objectId; 70 private short field_3_option; 71 private BitField locked = new BitField(0x1); 72 private BitField printable = new BitField(0x10); 73 private BitField autofill = new BitField(0x2000); 74 private BitField autoline = new BitField(0x4000); 75 private int field_4_reserved1; 76 private int field_5_reserved2; 77 private int field_6_reserved3; 78 79 80 public CommonObjectDataSubRecord() 81 { 82 83 } 84 85 93 94 public CommonObjectDataSubRecord(short id, short size, byte [] data) 95 { 96 super(id, size, data); 97 98 } 99 100 109 110 public CommonObjectDataSubRecord(short id, short size, byte [] data, int offset) 111 { 112 super(id, size, data, offset); 113 114 } 115 116 121 protected void validateSid(short id) 122 { 123 if (id != sid) 124 { 125 throw new RecordFormatException("Not a CommonObjectData record"); 126 } 127 } 128 129 protected void fillFields(byte [] data, short size, int offset) 130 { 131 132 int pos = 0; 133 field_1_objectType = LittleEndian.getShort(data, pos + 0x0 + offset); 134 field_2_objectId = LittleEndian.getShort(data, pos + 0x2 + offset); 135 field_3_option = LittleEndian.getShort(data, pos + 0x4 + offset); 136 field_4_reserved1 = LittleEndian.getInt(data, pos + 0x6 + offset); 137 field_5_reserved2 = LittleEndian.getInt(data, pos + 0xa + offset); 138 field_6_reserved3 = LittleEndian.getInt(data, pos + 0xe + offset); 139 140 } 141 142 public String toString() 143 { 144 StringBuffer buffer = new StringBuffer (); 145 146 buffer.append("[ftCmo]\n"); 147 buffer.append(" .objectType = ") 148 .append("0x").append(HexDump.toHex( getObjectType ())) 149 .append(" (").append( getObjectType() ).append(" )"); 150 buffer.append(System.getProperty("line.separator")); 151 buffer.append(" .objectId = ") 152 .append("0x").append(HexDump.toHex( getObjectId ())) 153 .append(" (").append( getObjectId() ).append(" )"); 154 buffer.append(System.getProperty("line.separator")); 155 buffer.append(" .option = ") 156 .append("0x").append(HexDump.toHex( getOption ())) 157 .append(" (").append( getOption() ).append(" )"); 158 buffer.append(System.getProperty("line.separator")); 159 buffer.append(" .locked = ").append(isLocked()).append('\n'); 160 buffer.append(" .printable = ").append(isPrintable()).append('\n'); 161 buffer.append(" .autofill = ").append(isAutofill()).append('\n'); 162 buffer.append(" .autoline = ").append(isAutoline()).append('\n'); 163 buffer.append(" .reserved1 = ") 164 .append("0x").append(HexDump.toHex( getReserved1 ())) 165 .append(" (").append( getReserved1() ).append(" )"); 166 buffer.append(System.getProperty("line.separator")); 167 buffer.append(" .reserved2 = ") 168 .append("0x").append(HexDump.toHex( getReserved2 ())) 169 .append(" (").append( getReserved2() ).append(" )"); 170 buffer.append(System.getProperty("line.separator")); 171 buffer.append(" .reserved3 = ") 172 .append("0x").append(HexDump.toHex( getReserved3 ())) 173 .append(" (").append( getReserved3() ).append(" )"); 174 buffer.append(System.getProperty("line.separator")); 175 176 buffer.append("[/ftCmo]\n"); 177 return buffer.toString(); 178 } 179 180 public int serialize(int offset, byte[] data) 181 { 182 int pos = 0; 183 184 LittleEndian.putShort(data, 0 + offset, sid); 185 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 186 187 LittleEndian.putShort(data, 4 + offset + pos, field_1_objectType); 188 LittleEndian.putShort(data, 6 + offset + pos, field_2_objectId); 189 LittleEndian.putShort(data, 8 + offset + pos, field_3_option); 190 LittleEndian.putInt(data, 10 + offset + pos, field_4_reserved1); 191 LittleEndian.putInt(data, 14 + offset + pos, field_5_reserved2); 192 LittleEndian.putInt(data, 18 + offset + pos, field_6_reserved3); 193 194 return getRecordSize(); 195 } 196 197 200 public int getRecordSize() 201 { 202 return 4 + 2 + 2 + 2 + 4 + 4 + 4; 203 } 204 205 public short getSid() 206 { 207 return this.sid; 208 } 209 210 public Object clone() { 211 CommonObjectDataSubRecord rec = new CommonObjectDataSubRecord(); 212 213 rec.field_1_objectType = field_1_objectType; 214 rec.field_2_objectId = field_2_objectId; 215 rec.field_3_option = field_3_option; 216 rec.field_4_reserved1 = field_4_reserved1; 217 rec.field_5_reserved2 = field_5_reserved2; 218 rec.field_6_reserved3 = field_6_reserved3; 219 return rec; 220 } 221 222 223 259 public short getObjectType() 260 { 261 return field_1_objectType; 262 } 263 264 301 public void setObjectType(short field_1_objectType) 302 { 303 this.field_1_objectType = field_1_objectType; 304 } 305 306 309 public short getObjectId() 310 { 311 return field_2_objectId; 312 } 313 314 317 public void setObjectId(short field_2_objectId) 318 { 319 this.field_2_objectId = field_2_objectId; 320 } 321 322 325 public short getOption() 326 { 327 return field_3_option; 328 } 329 330 333 public void setOption(short field_3_option) 334 { 335 this.field_3_option = field_3_option; 336 } 337 338 341 public int getReserved1() 342 { 343 return field_4_reserved1; 344 } 345 346 349 public void setReserved1(int field_4_reserved1) 350 { 351 this.field_4_reserved1 = field_4_reserved1; 352 } 353 354 357 public int getReserved2() 358 { 359 return field_5_reserved2; 360 } 361 362 365 public void setReserved2(int field_5_reserved2) 366 { 367 this.field_5_reserved2 = field_5_reserved2; 368 } 369 370 373 public int getReserved3() 374 { 375 return field_6_reserved3; 376 } 377 378 381 public void setReserved3(int field_6_reserved3) 382 { 383 this.field_6_reserved3 = field_6_reserved3; 384 } 385 386 390 public void setLocked(boolean value) 391 { 392 field_3_option = locked.setShortBoolean(field_3_option, value); 393 } 394 395 399 public boolean isLocked() 400 { 401 return locked.isSet(field_3_option); 402 } 403 404 408 public void setPrintable(boolean value) 409 { 410 field_3_option = printable.setShortBoolean(field_3_option, value); 411 } 412 413 417 public boolean isPrintable() 418 { 419 return printable.isSet(field_3_option); 420 } 421 422 426 public void setAutofill(boolean value) 427 { 428 field_3_option = autofill.setShortBoolean(field_3_option, value); 429 } 430 431 435 public boolean isAutofill() 436 { 437 return autofill.isSet(field_3_option); 438 } 439 440 444 public void setAutoline(boolean value) 445 { 446 field_3_option = autoline.setShortBoolean(field_3_option, value); 447 } 448 449 453 public boolean isAutoline() 454 { 455 return autoline.isSet(field_3_option); 456 } 457 458 459 } 461 462 | Popular Tags |