1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 23 32 33 public class DefaultColWidthRecord 34 extends Record 35 { 36 public final static short sid = 0x55; 37 private short field_1_col_width; 38 39 public DefaultColWidthRecord() 40 { 41 } 42 43 50 51 public DefaultColWidthRecord(short id, short size, byte [] data) 52 { 53 super(id, size, data); 54 } 55 56 64 65 public DefaultColWidthRecord(short id, short size, byte [] data, 66 int offset) 67 { 68 super(id, size, data, offset); 69 } 70 71 protected void validateSid(short id) 72 { 73 if (id != sid) 74 { 75 throw new RecordFormatException("NOT A DefaultColWidth RECORD"); 76 } 77 } 78 79 protected void fillFields(byte [] data, short size, int offset) 80 { 81 field_1_col_width = LittleEndian.getShort(data, 0 + offset); 82 } 83 84 88 89 public void setColWidth(short height) 90 { 91 field_1_col_width = height; 92 } 93 94 98 99 public short getColWidth() 100 { 101 return field_1_col_width; 102 } 103 104 public String toString() 105 { 106 StringBuffer buffer = new StringBuffer (); 107 108 buffer.append("[DEFAULTCOLWIDTH]\n"); 109 buffer.append(" .colwidth = ") 110 .append(Integer.toHexString(getColWidth())).append("\n"); 111 buffer.append("[/DEFAULTCOLWIDTH]\n"); 112 return buffer.toString(); 113 } 114 115 public int serialize(int offset, byte [] data) 116 { 117 LittleEndian.putShort(data, 0 + offset, sid); 118 LittleEndian.putShort(data, 2 + offset, ( short ) 0x2); 119 LittleEndian.putShort(data, 4 + offset, getColWidth()); 120 return getRecordSize(); 121 } 122 123 public int getRecordSize() 124 { 125 return 6; 126 } 127 128 public short getSid() 129 { 130 return this.sid; 131 } 132 133 public Object clone() { 134 DefaultColWidthRecord rec = new DefaultColWidthRecord(); 135 rec.field_1_col_width = field_1_col_width; 136 return rec; 137 } 138 } 139 | Popular Tags |