use of org.apache.poi.hssf.record.Record in project poi by apache.
the class LinkTable method findFirstRecordLocBySid.
/**
* copied from Workbook
*/
private int findFirstRecordLocBySid(short sid) {
int index = 0;
for (Iterator<Record> iterator = _workbookRecordList.iterator(); iterator.hasNext(); ) {
Record record = iterator.next();
if (record.getSid() == sid) {
return index;
}
index++;
}
return -1;
}
use of org.apache.poi.hssf.record.Record in project poi by apache.
the class CFRecordsAggregate method createCFAggregate.
/**
* Create CFRecordsAggregate from a list of CF Records
* @param rs - the stream to read from
* @return CFRecordsAggregate object
*/
public static CFRecordsAggregate createCFAggregate(RecordStream rs) {
Record rec = rs.getNext();
if (rec.getSid() != CFHeaderRecord.sid && rec.getSid() != CFHeader12Record.sid) {
throw new IllegalStateException("next record sid was " + rec.getSid() + " instead of " + CFHeaderRecord.sid + " or " + CFHeader12Record.sid + " as expected");
}
CFHeaderBase header = (CFHeaderBase) rec;
int nRules = header.getNumberOfConditionalFormats();
CFRuleBase[] rules = new CFRuleBase[nRules];
for (int i = 0; i < rules.length; i++) {
rules[i] = (CFRuleBase) rs.getNext();
}
return new CFRecordsAggregate(header, rules);
}
use of org.apache.poi.hssf.record.Record in project poi by apache.
the class ValueRecordsAggregate method visitCellsForRow.
public void visitCellsForRow(int rowIndex, RecordVisitor rv) {
CellValueRecordInterface[] rowCells = records[rowIndex];
if (rowCells == null) {
throw new IllegalArgumentException("Row [" + rowIndex + "] is empty");
}
for (int i = 0; i < rowCells.length; i++) {
RecordBase cvr = (RecordBase) rowCells[i];
if (cvr == null) {
continue;
}
int nBlank = countBlanks(rowCells, i);
if (nBlank > 1) {
rv.visitRecord(createMBR(rowCells, i, nBlank));
i += nBlank - 1;
} else if (cvr instanceof RecordAggregate) {
RecordAggregate agg = (RecordAggregate) cvr;
agg.visitContainedRecords(rv);
} else {
rv.visitRecord((Record) cvr);
}
}
}
use of org.apache.poi.hssf.record.Record in project poi by apache.
the class InternalWorkbook method setSheetOrder.
/**
* sets the order of appearance for a given sheet.
*
* @param sheetname the name of the sheet to reorder
* @param pos the position that we want to insert the sheet into (0 based)
*/
public void setSheetOrder(String sheetname, int pos) {
int sheetNumber = getSheetIndex(sheetname);
//remove the sheet that needs to be reordered and place it in the spot we want
boundsheets.add(pos, boundsheets.remove(sheetNumber));
// also adjust order of Records, calculate the position of the Boundsheets via getBspos()...
int initialBspos = records.getBspos();
int pos0 = initialBspos - (boundsheets.size() - 1);
Record removed = records.get(pos0 + sheetNumber);
records.remove(pos0 + sheetNumber);
records.add(pos0 + pos, removed);
records.setBspos(initialBspos);
}
use of org.apache.poi.hssf.record.Record in project poi by apache.
the class HSSFWorkbook method getAllPictures.
/**
* Gets all pictures from the Workbook.
*
* @return the list of pictures (a list of {@link HSSFPictureData} objects.)
*/
@Override
public List<HSSFPictureData> getAllPictures() {
// The drawing group record always exists at the top level, so we won't need to do this recursively.
List<HSSFPictureData> pictures = new ArrayList<HSSFPictureData>();
for (Record r : workbook.getRecords()) {
if (r instanceof AbstractEscherHolderRecord) {
((AbstractEscherHolderRecord) r).decode();
List<EscherRecord> escherRecords = ((AbstractEscherHolderRecord) r).getEscherRecords();
searchForPictures(escherRecords, pictures);
}
}
return Collections.unmodifiableList(pictures);
}
Aggregations