1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 23 34 35 public class CalcModeRecord 36 extends Record 37 { 38 public final static short sid = 0xD; 39 40 43 44 public final static short MANUAL = 0; 45 46 49 50 public final static short AUTOMATIC = 1; 51 52 55 56 public final static short AUTOMATIC_EXCEPT_TABLES = -1; 57 private short field_1_calcmode; 58 59 public CalcModeRecord() 60 { 61 } 62 63 70 71 public CalcModeRecord(short id, short size, byte [] data) 72 { 73 super(id, size, data); 74 } 75 76 84 85 public CalcModeRecord(short id, short size, byte [] data, int offset) 86 { 87 super(id, size, data, offset); 88 } 89 90 protected void validateSid(short id) 91 { 92 if (id != sid) 93 { 94 throw new RecordFormatException("NOT An Calc Mode RECORD"); 95 } 96 } 97 98 protected void fillFields(byte [] data, short size, int offset) 99 { 100 field_1_calcmode = LittleEndian.getShort(data, 0 + offset); 101 } 102 103 112 113 public void setCalcMode(short calcmode) 114 { 115 field_1_calcmode = calcmode; 116 } 117 118 127 128 public short getCalcMode() 129 { 130 return field_1_calcmode; 131 } 132 133 public String toString() 134 { 135 StringBuffer buffer = new StringBuffer (); 136 137 buffer.append("[CALCMODE]\n"); 138 buffer.append(" .calcmode = ") 139 .append(Integer.toHexString(getCalcMode())).append("\n"); 140 buffer.append("[/CALCMODE]\n"); 141 return buffer.toString(); 142 } 143 144 public int serialize(int offset, byte [] data) 145 { 146 LittleEndian.putShort(data, 0 + offset, sid); 147 LittleEndian.putShort(data, 2 + offset, ( short ) 0x2); 148 LittleEndian.putShort(data, 4 + offset, getCalcMode()); 149 return getRecordSize(); 150 } 151 152 public int getRecordSize() 153 { 154 return 6; 155 } 156 157 public short getSid() 158 { 159 return this.sid; 160 } 161 162 public Object clone() { 163 CalcModeRecord rec = new CalcModeRecord(); 164 rec.field_1_calcmode = field_1_calcmode; 165 return rec; 166 } 167 } 168 | Popular Tags |