1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 23 31 32 public class GutsRecord 33 extends Record 34 { 35 public final static short sid = 0x80; 36 private short field_1_left_row_gutter; private short field_2_top_col_gutter; private short field_3_row_level_max; private short field_4_col_level_max; 41 public GutsRecord() 42 { 43 } 44 45 52 53 public GutsRecord(short id, short size, byte [] data) 54 { 55 super(id, size, data); 56 } 57 58 66 67 public GutsRecord(short id, short size, byte [] data, int offset) 68 { 69 super(id, size, data, offset); 70 } 71 72 protected void validateSid(short id) 73 { 74 if (id != sid) 75 { 76 throw new RecordFormatException("NOT A Guts RECORD"); 77 } 78 } 79 80 protected void fillFields(byte [] data, short size, int offset) 81 { 82 field_1_left_row_gutter = LittleEndian.getShort(data, 0 + offset); 83 field_2_top_col_gutter = LittleEndian.getShort(data, 2 + offset); 84 field_3_row_level_max = LittleEndian.getShort(data, 4 + offset); 85 field_4_col_level_max = LittleEndian.getShort(data, 6 + offset); 86 } 87 88 93 94 public void setLeftRowGutter(short gut) 95 { 96 field_1_left_row_gutter = gut; 97 } 98 99 104 105 public void setTopColGutter(short gut) 106 { 107 field_2_top_col_gutter = gut; 108 } 109 110 115 116 public void setRowLevelMax(short max) 117 { 118 field_3_row_level_max = max; 119 } 120 121 126 127 public void setColLevelMax(short max) 128 { 129 field_4_col_level_max = max; 130 } 131 132 137 138 public short getLeftRowGutter() 139 { 140 return field_1_left_row_gutter; 141 } 142 143 148 149 public short getTopColGutter() 150 { 151 return field_2_top_col_gutter; 152 } 153 154 159 160 public short getRowLevelMax() 161 { 162 return field_3_row_level_max; 163 } 164 165 170 171 public short getColLevelMax() 172 { 173 return field_4_col_level_max; 174 } 175 176 public String toString() 177 { 178 StringBuffer buffer = new StringBuffer (); 179 180 buffer.append("[GUTS]\n"); 181 buffer.append(" .leftgutter = ") 182 .append(Integer.toHexString(getLeftRowGutter())).append("\n"); 183 buffer.append(" .topgutter = ") 184 .append(Integer.toHexString(getTopColGutter())).append("\n"); 185 buffer.append(" .rowlevelmax = ") 186 .append(Integer.toHexString(getRowLevelMax())).append("\n"); 187 buffer.append(" .collevelmax = ") 188 .append(Integer.toHexString(getColLevelMax())).append("\n"); 189 buffer.append("[/GUTS]\n"); 190 return buffer.toString(); 191 } 192 193 public int serialize(int offset, byte [] data) 194 { 195 LittleEndian.putShort(data, 0 + offset, sid); 196 LittleEndian.putShort(data, 2 + offset, ( short ) 0x8); 197 LittleEndian.putShort(data, 4 + offset, getLeftRowGutter()); 198 LittleEndian.putShort(data, 6 + offset, getTopColGutter()); 199 LittleEndian.putShort(data, 8 + offset, getRowLevelMax()); 200 LittleEndian.putShort(data, 10 + offset, getColLevelMax()); 201 return getRecordSize(); 202 } 203 204 public int getRecordSize() 205 { 206 return 12; 207 } 208 209 public short getSid() 210 { 211 return this.sid; 212 } 213 214 public Object clone() { 215 GutsRecord rec = new GutsRecord(); 216 rec.field_1_left_row_gutter = field_1_left_row_gutter; 217 rec.field_2_top_col_gutter = field_2_top_col_gutter; 218 rec.field_3_row_level_max = field_3_row_level_max; 219 rec.field_4_col_level_max = field_4_col_level_max; 220 return rec; 221 } 222 } 223 | Popular Tags |