/** * * @return <code>true</code> when a {@link ContinueRecord} is next. */ private boolean isContinueNext() { if (_currentDataLength != DATA_LEN_NEEDS_TO_BE_READ && _currentDataOffset != _currentDataLength) { throw new IllegalStateException("Should never be called before end of current record"); } if (!hasNextRecord()) { return false; } // At what point are records continued? // - Often from within the char data of long strings (caller is within readStringCommon()). // - From UnicodeString construction (many different points - call via checkRecordPosition) // - During TextObjectRecord construction (just before the text, perhaps within the text, // and before the formatting run data) return _nextSid == ContinueRecord.sid; }
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()]); }
private void prepare() { if (! ris.hasNextRecord()) { throw new IllegalArgumentException("File contains no records!"); } ris.nextRecord(); // Work out what version we're dealing with int bofSid = ris.getSid(); switch (bofSid) { case BOFRecord.biff2_sid: biffVersion = 2; break; case BOFRecord.biff3_sid: biffVersion = 3; break; case BOFRecord.biff4_sid: biffVersion = 4; break; case BOFRecord.biff5_sid: biffVersion = 5; break; default: throw new IllegalArgumentException("File does not begin with a BOF, found sid of " + bofSid); } // Get the type BOFRecord bof = new BOFRecord(ris); fileType = bof.getType(); }
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)); } } } }
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; } }
if (rs.hasNextRecord()) { rs.nextRecord(); rec = RecordFactory.createSingleRecord(rs); if (rec instanceof WriteProtectRecord && rs.hasNextRecord()) { rs.nextRecord(); rec = RecordFactory.createSingleRecord(rs);
boolean hasNext; try { hasNext = recStream.hasNextRecord(); } catch (LeftoverDataException e) { logger.log(POILogger.ERROR, "Discarding " + recStream.remaining() + " bytes and continuing", e); recStream.readRemainder(); hasNext = recStream.hasNextRecord();
/** * 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 ); } }
if (!_recStream.hasNextRecord()) {
while (recStream.hasNextRecord()) { recStream.nextRecord();
while (ris.hasNextRecord()) { int sid = ris.getNextSid(); ris.nextRecord();
/** * * @return <code>true</code> when a {@link ContinueRecord} is next. */ private boolean isContinueNext() { if (_currentDataLength != DATA_LEN_NEEDS_TO_BE_READ && _currentDataOffset != _currentDataLength) { throw new IllegalStateException("Should never be called before end of current record"); } if (!hasNextRecord()) { return false; } // At what point are records continued? // - Often from within the char data of long strings (caller is within readStringCommon()). // - From UnicodeString construction (many different points - call via checkRecordPosition) // - During TextObjectRecord construction (just before the text, perhaps within the text, // and before the formatting run data) return _nextSid == ContinueRecord.sid; }
/** * * @return <code>true</code> when a {@link ContinueRecord} is next. */ private boolean isContinueNext() { if (_currentDataLength != DATA_LEN_NEEDS_TO_BE_READ && _currentDataOffset != _currentDataLength) { throw new IllegalStateException("Should never be called before end of current record"); } if (!hasNextRecord()) { return false; } // At what point are records continued? // - Often from within the char data of long strings (caller is within readStringCommon()). // - From UnicodeString construction (many different points - call via checkRecordPosition) // - During TextObjectRecord construction (just before the text, perhaps within the text, // and before the formatting run data) return _nextSid == ContinueRecord.sid; }
/** * * @return <code>true</code> when a {@link ContinueRecord} is next. */ private boolean isContinueNext() { if (_currentDataLength != DATA_LEN_NEEDS_TO_BE_READ && _currentDataOffset != _currentDataLength) { throw new IllegalStateException("Should never be called before end of current record"); } if (!hasNextRecord()) { return false; } // At what point are records continued? // - Often from within the char data of long strings (caller is within readStringCommon()). // - From UnicodeString construction (many different points - call via checkRecordPosition) // - During TextObjectRecord construction (just before the text, perhaps within the text, // and before the formatting run data) return _nextSid == ContinueRecord.sid; }
public ExtSSTRecord(RecordInputStream in) { _stringsPerBucket = in.readShort(); int nInfos = in.remaining() / InfoSubRecord.ENCODED_SIZE; ArrayList<InfoSubRecord> lst = new ArrayList<InfoSubRecord>(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()]); }
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()]); }
public ExtSSTRecord(RecordInputStream in) { _stringsPerBucket = in.readShort(); int nInfos = in.remaining() / InfoSubRecord.ENCODED_SIZE; ArrayList<InfoSubRecord> lst = new ArrayList<InfoSubRecord>(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()]); }
/** * 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()) { System.err.println("Ran out of data before creating all the strings! String at index " + i + ""); str = new UnicodeString(""); } else { str = new UnicodeString(in); } addToStringTable( strings, str ); } }
/** * 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 ); } }
/** * 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 ); } }