1 19 20 package jxl.biff.drawing; 21 22 import jxl.biff.IntegerHelper; 23 24 28 final class EscherRecordData 29 { 30 33 private int pos; 34 35 38 private int instance; 39 40 43 private int version; 44 45 48 private int recordId; 49 50 53 private int length; 54 55 58 private int streamLength; 59 60 63 private boolean container; 64 65 68 private EscherRecordType type; 69 70 74 private EscherStream escherStream; 75 76 79 public EscherRecordData(EscherStream dg, int p) 80 { 81 escherStream = dg; 82 pos = p; 83 byte[] data = escherStream.getData(); 84 85 streamLength = data.length; 86 87 int value = IntegerHelper.getInt(data[pos], data[pos+1]); 89 90 instance = (value & 0xfff0) >> 4; 92 93 version = value & 0xf; 95 96 recordId = IntegerHelper.getInt(data[pos+2], data[pos+3]); 98 99 length = IntegerHelper.getInt(data[pos+4], data[pos+5], 101 data[pos+6], data[pos+7]); 102 103 if (version == 0x0f) 104 { 105 container = true; 106 } 107 else 108 { 109 container = false; 110 } 111 } 112 113 118 public EscherRecordData(EscherRecordType t) 119 { 120 type = t; 121 recordId = type.getValue(); 122 } 123 124 129 public boolean isContainer() 130 { 131 return container; 132 } 133 134 139 public int getLength() 140 { 141 return length; 142 } 143 144 149 public int getRecordId() 150 { 151 return recordId; 152 } 153 154 159 EscherStream getDrawingGroup() 160 { 161 return escherStream; 162 } 163 164 169 int getPos() 170 { 171 return pos; 172 } 173 174 177 EscherRecordType getType() 178 { 179 if (type == null) 180 { 181 type = EscherRecordType.getType(recordId); 182 } 183 184 return type; 185 } 186 187 192 int getInstance() 193 { 194 return instance; 195 } 196 197 203 void setContainer(boolean c) 204 { 205 container = c; 206 } 207 208 213 void setInstance(int inst) 214 { 215 instance = inst; 216 } 217 218 223 void setLength(int l) 224 { 225 length = l; 226 } 227 228 233 void setVersion(int v) 234 { 235 version = v; 236 } 237 238 245 byte[] setHeaderData(byte[] d) 246 { 247 byte[] data = new byte[d.length + 8]; 248 System.arraycopy(d, 0, data, 8, d.length); 249 250 if (container) 251 { 252 version = 0x0f; 253 } 254 255 int value = instance << 4; 257 value |= version; 258 IntegerHelper.getTwoBytes(value, data, 0); 259 260 IntegerHelper.getTwoBytes(recordId, data, 2); 262 263 IntegerHelper.getFourBytes(d.length, data, 4); 265 266 return data; 267 } 268 269 274 EscherStream getEscherStream() 275 { 276 return escherStream; 277 } 278 279 284 byte[] getBytes() 285 { 286 byte[] d = new byte[length]; 287 System.arraycopy(escherStream.getData(), pos+8, d, 0, length); 288 return d; 289 } 290 291 296 int getStreamLength() 297 { 298 return streamLength; 299 } 300 } 301 | Popular Tags |