1 2 17 18 19 24 package org.apache.poi.hssf.record; 25 26 import org.apache.poi.util.LittleEndian; 27 28 40 41 public class MulBlankRecord 42 extends Record 43 { 44 public final static short sid = 0xbe; 45 private int field_1_row; 47 private short field_2_first_col; 48 private short[] field_3_xfs; 49 private short field_4_last_col; 50 51 52 53 public MulBlankRecord() 54 { 55 } 56 57 64 65 public MulBlankRecord(short id, short size, byte [] data) 66 { 67 super(id, size, data); 68 } 69 70 78 79 public MulBlankRecord(short id, short size, byte [] data, int offset) 80 { 81 super(id, size, data, offset); 82 } 83 84 89 90 public int getRow() 92 { 93 return field_1_row; 94 } 95 96 100 101 public short getFirstColumn() 102 { 103 return field_2_first_col; 104 } 105 106 110 111 public short getLastColumn() 112 { 113 return field_4_last_col; 114 } 115 116 120 121 public int getNumColumns() 122 { 123 return field_4_last_col - field_2_first_col + 1; 124 } 125 126 131 132 public short getXFAt(int coffset) 133 { 134 return field_3_xfs[ coffset ]; 135 } 136 137 144 145 protected void fillFields(byte [] data, short size, int offset) 146 { 147 field_1_row = LittleEndian.getUShort(data, 0 + offset); 149 field_2_first_col = LittleEndian.getShort(data, 2 + offset); 150 field_3_xfs = parseXFs(data, 4, offset, size); 151 field_4_last_col = LittleEndian.getShort(data, 152 (field_3_xfs.length * 2) 153 + 4 + offset); 154 } 155 156 private short [] parseXFs(byte [] data, int offset, int recoffset, 157 short size) 158 { 159 short[] retval = new short[ ((size - offset) - 2) / 2 ]; 160 int idx = 0; 161 162 for (; offset < size - 2; ) 163 { 164 short xf = 0; 165 166 xf = LittleEndian.getShort(data, offset + recoffset); 167 offset += 2; 168 retval[ idx ] = xf; 169 idx++; 170 } 171 return retval; 172 } 173 174 public String toString() 175 { 176 StringBuffer buffer = new StringBuffer (); 177 178 buffer.append("[MULBLANK]\n"); 179 buffer.append("row = ") 180 .append(Integer.toHexString(getRow())).append("\n"); 181 buffer.append("firstcol = ") 182 .append(Integer.toHexString(getFirstColumn())).append("\n"); 183 buffer.append(" lastcol = ") 184 .append(Integer.toHexString(getLastColumn())).append("\n"); 185 for (int k = 0; k < getNumColumns(); k++) 186 { 187 buffer.append("xf").append(k).append(" = ") 188 .append(Integer.toHexString(getXFAt(k))).append("\n"); 189 } 190 buffer.append("[/MULBLANK]\n"); 191 return buffer.toString(); 192 } 193 194 200 201 protected void validateSid(short id) 202 { 203 if (id != sid) 204 { 205 throw new RecordFormatException("Not a MulBlankRecord!"); 206 } 207 } 208 209 public short getSid() 210 { 211 return this.sid; 212 } 213 214 public int serialize(int offset, byte [] data) 215 { 216 throw new RecordFormatException( 217 "Sorry, you can't serialize a MulBlank in this release"); 218 } 219 } 220 | Popular Tags |