1 2 17 18 19 24 package org.apache.poi.hssf.record; 25 26 import java.util.ArrayList ; 27 28 import org.apache.poi.util.LittleEndian; 29 import org.apache.poi.hssf.util.RKUtil; 30 31 38 39 public class MulRKRecord 40 extends Record 41 { 42 public final static short sid = 0xbd; 43 private int field_1_row; 45 private short field_2_first_col; 46 private ArrayList field_3_rks; 47 private short field_4_last_col; 48 49 50 51 public MulRKRecord() 52 { 53 } 54 55 62 63 public MulRKRecord(short id, short size, byte [] data) 64 { 65 super(id, size, data); 66 } 67 68 76 77 public MulRKRecord(short id, short size, byte [] data, int offset) 78 { 79 super(id, size, data, offset); 80 } 81 82 public int getRow() 84 { 85 return field_1_row; 86 } 87 88 92 93 public short getFirstColumn() 94 { 95 return field_2_first_col; 96 } 97 98 102 103 public short getLastColumn() 104 { 105 return field_4_last_col; 106 } 107 108 112 113 public int getNumColumns() 114 { 115 return field_4_last_col - field_2_first_col + 1; 116 } 117 118 122 123 public short getXFAt(int coffset) 124 { 125 return (( RkRec ) field_3_rks.get(coffset)).xf; 126 } 127 128 132 133 public double getRKNumberAt(int coffset) 134 { 135 return RKUtil.decodeNumber((( RkRec ) field_3_rks.get(coffset)).rk); 136 } 137 138 145 146 protected void fillFields(byte [] data, short size, int offset) 147 { 148 field_1_row = LittleEndian.getUShort(data, 0 + offset); 150 field_2_first_col = LittleEndian.getShort(data, 2 + offset); 151 field_3_rks = parseRKs(data, 4, offset, size); 152 field_4_last_col = LittleEndian.getShort(data, 153 (field_3_rks.size() * 6) 154 + 4 + offset); 155 } 156 157 private ArrayList parseRKs(byte [] data, int offset, int recoffset, 158 short size) 159 { 160 ArrayList retval = new ArrayList (); 161 162 for (; offset < size - 2; ) 163 { 164 RkRec rec = new RkRec(); 165 166 rec.xf = LittleEndian.getShort(data, offset + recoffset); 167 offset += 2; 168 rec.rk = LittleEndian.getInt(data, offset + recoffset); 169 offset += 4; 170 retval.add(rec); 171 } 172 return retval; 173 } 174 175 public String toString() 176 { 177 StringBuffer buffer = new StringBuffer (); 178 179 buffer.append("[MULRK]\n"); 180 buffer.append("firstcol = ") 181 .append(Integer.toHexString(getFirstColumn())).append("\n"); 182 buffer.append(" lastcol = ") 183 .append(Integer.toHexString(getLastColumn())).append("\n"); 184 for (int k = 0; k < getNumColumns(); k++) 185 { 186 buffer.append("xf").append(k).append(" = ") 187 .append(Integer.toHexString(getXFAt(k))).append("\n"); 188 buffer.append("rk").append(k).append(" = ") 189 .append(getRKNumberAt(k)).append("\n"); 190 } 191 buffer.append("[/MULRK]\n"); 192 return buffer.toString(); 193 } 194 195 201 202 protected void validateSid(short id) 203 { 204 if (id != sid) 205 { 206 throw new RecordFormatException("Not a MulRKRecord!"); 207 } 208 } 209 210 public short getSid() 211 { 212 return this.sid; 213 } 214 215 public int serialize(int offset, byte [] data) 216 { 217 throw new RecordFormatException( 218 "Sorry, you can't serialize a MulRK in this release"); 219 } 220 } 221 222 class RkRec 223 { 224 public short xf; 225 public int rk; 226 } 227 | Popular Tags |