1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 23 38 39 public class RecalcIdRecord 40 extends Record 41 { 42 public final static short sid = 0x1c1; 43 public short[] field_1_recalcids; 44 45 private boolean isNeeded = false; 46 47 public RecalcIdRecord() 48 { 49 } 50 51 58 59 public RecalcIdRecord(short id, short size, byte [] data) 60 { 61 super(id, size, data); 62 } 63 64 72 73 public RecalcIdRecord(short id, short size, byte [] data, int offset) 74 { 75 super(id, size, data, offset); 76 } 77 78 protected void validateSid(short id) 79 { 80 if (id != sid) 81 { 82 throw new RecordFormatException("NOT A RECALCID RECORD"); 83 } 84 } 85 86 protected void fillFields(byte [] data, short size, int offset) 87 { 88 field_1_recalcids = new short[ size / 2 ]; 89 for (int k = 0; k < field_1_recalcids.length; k++) 90 { 91 field_1_recalcids[ k ] = LittleEndian.getShort(data, 92 (k * 2) + offset); 93 } 94 } 95 96 100 101 public void setRecalcIdArray(short [] array) 102 { 103 field_1_recalcids = array; 104 } 105 106 110 111 public short [] getRecalcIdArray() 112 { 113 return field_1_recalcids; 114 } 115 116 public void setIsNeeded(boolean isNeeded) { 117 this.isNeeded = isNeeded; 118 } 119 120 public boolean isNeeded() { 121 return isNeeded; 122 } 123 124 public String toString() 125 { 126 StringBuffer buffer = new StringBuffer (); 127 128 buffer.append("[RECALCID]\n"); 129 buffer.append(" .elements = ").append(field_1_recalcids.length) 130 .append("\n"); 131 for (int k = 0; k < field_1_recalcids.length; k++) 132 { 133 buffer.append(" .element_" + k + " = ") 134 .append(field_1_recalcids[ k ]).append("\n"); 135 } 136 buffer.append("[/RECALCID]\n"); 137 return buffer.toString(); 138 } 139 140 public int serialize(int offset, byte [] data) 141 { 142 short[] tabids = getRecalcIdArray(); 143 short length = ( short ) (tabids.length * 2); 144 int byteoffset = 4; 145 146 LittleEndian.putShort(data, 0 + offset, sid); 147 LittleEndian.putShort(data, 2 + offset, 148 (( short ) length)); 149 150 for (int k = 0; k < (length / 2); k++) 152 { 153 LittleEndian.putShort(data, byteoffset + offset, tabids[ k ]); 154 byteoffset += 2; 155 } 156 return getRecordSize(); 157 } 158 159 public int getRecordSize() 160 { 161 return 4 + (getRecalcIdArray().length * 2); 162 } 163 164 public short getSid() 165 { 166 return this.sid; 167 } 168 } 169 | Popular Tags |