List<Record> records = new ArrayList<Record>(recs.size() / 3);
retval.records.setRecords(records);
int k;
for (k = 0; k < recs.size(); k++) {
Record rec = recs.get(k);
if (rec.getSid() == EOFRecord.sid) {
records.add(rec);
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found workbook eof record at " + k);
break;
}
switch (rec.getSid()) {
case BoundSheetRecord.sid :
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found boundsheet record at " + k);
retval.boundsheets.add((BoundSheetRecord) rec);
retval.records.setBspos( k );
break;
case SSTRecord.sid :
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found sst record at " + k);
retval.sst = ( SSTRecord ) rec;
break;
case FontRecord.sid :
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found font record at " + k);
retval.records.setFontpos( k );
retval.numfonts++;
break;
case ExtendedFormatRecord.sid :
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found XF record at " + k);
retval.records.setXfpos( k );
retval.numxfs++;
break;
case TabIdRecord.sid :
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found tabid record at " + k);
retval.records.setTabpos( k );
break;
case ProtectRecord.sid :
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found protect record at " + k);
retval.records.setProtpos( k );
break;
case BackupRecord.sid :
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found backup record at " + k);
retval.records.setBackuppos( k );
break;
case ExternSheetRecord.sid :
throw new RuntimeException("Extern sheet is part of LinkTable");
case NameRecord.sid :
case SupBookRecord.sid :
// LinkTable can start with either of these
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found SupBook record at " + k);
retval.linkTable = new LinkTable(recs, k, retval.records, retval.commentRecords);
k+=retval.linkTable.getRecordCount() - 1;
continue;
case FormatRecord.sid :
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found format record at " + k);
retval.formats.add((FormatRecord) rec);
retval.maxformatid = retval.maxformatid >= ((FormatRecord)rec).getIndexCode() ? retval.maxformatid : ((FormatRecord)rec).getIndexCode();
break;
case DateWindow1904Record.sid :
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found datewindow1904 record at " + k);
retval.uses1904datewindowing = ((DateWindow1904Record)rec).getWindowing() == 1;
break;
case PaletteRecord.sid:
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found palette record at " + k);
retval.records.setPalettepos( k );
break;
case WindowOneRecord.sid:
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found WindowOneRecord at " + k);
retval.windowOne = (WindowOneRecord) rec;
break;
case WriteAccessRecord.sid:
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found WriteAccess at " + k);
retval.writeAccess = (WriteAccessRecord) rec;
break;
case WriteProtectRecord.sid:
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found WriteProtect at " + k);
retval.writeProtect = (WriteProtectRecord) rec;
break;
case FileSharingRecord.sid:
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found FileSharing at " + k);
retval.fileShare = (FileSharingRecord) rec;
break;
case NameCommentRecord.sid:
final NameCommentRecord ncr = (NameCommentRecord) rec;
if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found NameComment at " + k);
retval.commentRecords.put(ncr.getNameText(), ncr);
default :
}
records.add(rec);
}
//What if we dont have any ranges and supbooks
// if (retval.records.supbookpos == 0) {
// retval.records.supbookpos = retval.records.bspos + 1;
// retval.records.namepos = retval.records.supbookpos + 1;
// }
// Look for other interesting values that
// follow the EOFRecord
for ( ; k < recs.size(); k++) {
Record rec = recs.get(k);
switch (rec.getSid()) {
case HyperlinkRecord.sid:
retval.hyperlinks.add((HyperlinkRecord)rec);
break;
}
}