@Override public int available(){ return _in.available(); }
public ExtSSTRecord(RecordInputStream in) { _stringsPerBucket = in.readShort(); int nInfos = in.remaining() / InfoSubRecord.ENCODED_SIZE; ArrayList<InfoSubRecord> lst = new ArrayList<>(nInfos); while (in.available() > 0) { InfoSubRecord info = new InfoSubRecord(in); lst.add(info); if(in.available() == 0 && in.hasNextRecord() && in.getNextSid() == ContinueRecord.sid) { in.nextRecord(); } } _sstInfos = lst.toArray(new InfoSubRecord[lst.size()]); }
/** * @param in the RecordInputstream to read the record from */ public SharedFormulaRecord(RecordInputStream in) { super(in); field_5_reserved = in.readShort(); int field_6_expression_len = in.readShort(); int nAvailableBytes = in.available(); field_7_parsed_expr = Formula.read(field_6_expression_len, in, nAvailableBytes); }
protected void readFully(byte[] buf, int off, int len, boolean isPlain) { int origLen = len; if (buf == null) { throw new NullPointerException(); } else if (off < 0 || len < 0 || len > buf.length - off) { throw new IndexOutOfBoundsException(); } while (len > 0) { int nextChunk = Math.min(available(),len); if (nextChunk == 0) { if (!hasNextRecord()) { throw new RecordFormatException("Can't read the remaining "+len+" bytes of the requested "+origLen+" bytes. No further record exists."); } else { nextRecord(); nextChunk = Math.min(available(),len); assert(nextChunk > 0); } } checkRecordPosition(nextChunk); if (isPlain) { _dataInput.readPlain(buf, off, nextChunk); } else { _dataInput.readFully(buf, off, nextChunk); } _currentDataOffset+=nextChunk; off += nextChunk; len -= nextChunk; } }
public ArrayRecord(RecordInputStream in) { super(in); _options = in.readUShort(); _field3notUsed = in.readInt(); int formulaTokenLen = in.readUShort(); int totalFormulaLen = in.available(); _formula = Formula.read(formulaTokenLen, in, totalFormulaLen); }
public ChartEndBlockRecord(RecordInputStream in) { rt = in.readShort(); grbitFrt = in.readShort(); iObjectKind = in.readShort(); // Often, but not always has 6 unused bytes at the end if(in.available() == 0) { unused = new byte[0]; } else { unused = new byte[6]; in.readFully(unused); } }
public void run() throws IOException { try (POIFSFileSystem fs = new POIFSFileSystem(new File(file), true); InputStream din = BiffViewer.getPOIFSInputStream(fs)) { RecordInputStream rinp = new RecordInputStream(din); while (rinp.hasNextRecord()) { int sid = rinp.getNextSid(); rinp.nextRecord(); int size = rinp.available(); Class<? extends Record> clz = RecordFactory.getRecordClass(sid); System.out.print( formatSID(sid) + " - " + formatSize(size) + " bytes" ); if (clz != null) { System.out.print(" \t"); System.out.print(clz.getName().replace("org.apache.poi.hssf.record.", "")); } System.out.println(); byte[] data = rinp.readRemainder(); if (data.length > 0) { System.out.print(" "); System.out.println(formatData(data)); } } } }
public FormulaRecord(RecordInputStream ris) { super(ris); long valueLongBits = ris.readLong(); field_5_options = ris.readShort(); specialCachedValue = SpecialCachedValue.create(valueLongBits); if (specialCachedValue == null) { field_4_value = Double.longBitsToDouble(valueLongBits); } field_6_zero = ris.readInt(); int field_7_expression_len = ris.readShort(); // this length does not include any extra array data int nBytesAvailable = ris.available(); field_8_parsed_expr = Formula.read(field_7_expression_len, ris, nBytesAvailable); }
public ChartEndObjectRecord(RecordInputStream in) { rt = in.readShort(); grbitFrt = in.readShort(); iObjectKind = in.readShort(); // The spec says that there should be 6 bytes at the // end, which must be there and must be zero // However, sometimes Excel forgets them... reserved = new byte[6]; if(in.available() == 0) { // They've gone missing... } else { // Read the reserved bytes in.readFully(reserved); } }
public DrawingSelectionRecord(RecordInputStream in) { _header = new OfficeArtRecordHeader(in); _cpsp = in.readInt(); _dgslk = in.readInt(); _spidFocus = in.readInt(); int nShapes = in.available() / 4; int[] shapeIds = new int[nShapes]; for (int i = 0; i < nShapes; i++) { shapeIds[i] = in.readInt(); } _shapeIds = shapeIds; }
/** * Read the record data from the supplied <code>RecordInputStream</code> * * @param in the RecordInputStream to read from */ public NoteRecord(RecordInputStream in) { field_1_row = in.readUShort(); field_2_col = in.readShort(); field_3_flags = in.readShort(); field_4_shapeid = in.readUShort(); int length = in.readShort(); field_5_hasMultibyte = in.readByte() != 0x00; if (field_5_hasMultibyte) { field_6_author = StringUtil.readUnicodeLE(in, length); } else { field_6_author = StringUtil.readCompressedUnicode(in, length); } if (in.available() == 1) { field_7_padding = Byte.valueOf(in.readByte()); } else if (in.available() == 2 && length == 0) { // If there's no author, may be double padded field_7_padding = Byte.valueOf(in.readByte()); in.readByte(); } }
/** * This is the starting point where strings are constructed. Note that * strings may span across multiple continuations. Read the SST record * carefully before beginning to hack. */ public void manufactureStrings( int stringCount, RecordInputStream in ) { for (int i=0;i<stringCount;i++) { // Extract exactly the count of strings from the SST record. UnicodeString str; if(in.available() == 0 && ! in.hasNextRecord()) { logger.log( POILogger.ERROR, "Ran out of data before creating all the strings! String at index " + i + ""); str = new UnicodeString(""); } else { str = new UnicodeString(in); } addToStringTable( strings, str ); } }
public CatLabRecord(RecordInputStream in) { rt = in.readShort(); grbitFrt = in.readShort(); wOffset = in.readShort(); at = in.readShort(); grbit = in.readShort(); // Often, but not always has an unused short at the end if(in.available() == 0) { unused = null; } else { unused = in.readShort(); } }
public DimensionsRecord(RecordInputStream in) { field_1_first_row = in.readInt(); field_2_last_row = in.readInt(); field_3_first_col = in.readShort(); field_4_last_col = in.readShort(); field_5_zero = in.readShort(); //POI-61045 -- in practice, there can be an extra 2 bytes if (in.available() == 2) { logger.log(POILogger.INFO, "DimensionsRecord has extra 2 bytes."); in.readShort(); } }
public OldFormulaRecord(RecordInputStream ris) { super(ris, ris.getSid() == biff2_sid); if (isBiff2()) { field_4_value = ris.readDouble(); } else { long valueLongBits = ris.readLong(); specialCachedValue = SpecialCachedValue.create(valueLongBits); if (specialCachedValue == null) { field_4_value = Double.longBitsToDouble(valueLongBits); } } if (isBiff2()) { field_5_options = (short)ris.readUByte(); } else { field_5_options = ris.readShort(); } int expression_len = ris.readShort(); int nBytesAvailable = ris.available(); field_6_parsed_expr = Formula.read(expression_len, ris, nBytesAvailable); }
public ExternalNameRecord(RecordInputStream in) { field_1_option_flag = in.readShort(); field_2_ixals = in.readShort(); field_3_not_used = in.readShort(); int numChars = in.readUByte(); field_4_name = StringUtil.readUnicodeString(in, numChars); // the record body can take different forms. // The form is dictated by the values of 3-th and 4-th bits in field_1_option_flag if(!isOLELink() && !isStdDocumentNameIdentifier()){ // another switch: the fWantAdvise bit specifies whether the body describes // an external defined name or a DDE data item if(isAutomaticLink()){ if(in.available() > 0) { //body specifies DDE data item int nColumns = in.readUByte() + 1; int nRows = in.readShort() + 1; int totalCount = nRows * nColumns; _ddeValues = ConstantValueParser.parse(in, totalCount); _nColumns = nColumns; _nRows = nRows; } } else { //body specifies an external defined name int formulaLen = in.readUShort(); field_5_name_definition = Formula.read(formulaLen, in); } } }
@Override public int available(){ return _in.available(); }
public FormulaRecord(RecordInputStream ris) { super(ris); long valueLongBits = ris.readLong(); field_5_options = ris.readShort(); specialCachedValue = SpecialCachedValue.create(valueLongBits); if (specialCachedValue == null) { field_4_value = Double.longBitsToDouble(valueLongBits); } field_6_zero = ris.readInt(); int field_7_expression_len = ris.readShort(); // this length does not include any extra array data int nBytesAvailable = ris.available(); field_8_parsed_expr = Formula.read(field_7_expression_len, ris, nBytesAvailable); }
public DrawingSelectionRecord(RecordInputStream in) { _header = new OfficeArtRecordHeader(in); _cpsp = in.readInt(); _dgslk = in.readInt(); _spidFocus = in.readInt(); int nShapes = in.available() / 4; int[] shapeIds = new int[nShapes]; for (int i = 0; i < nShapes; i++) { shapeIds[i] = in.readInt(); } _shapeIds = shapeIds; }