use of org.apache.poi.hslf.record.PersistRecord in project poi by apache.
the class HSLFSlideShowImpl method read.
private Record[] read(byte[] docstream, int usrOffset) throws IOException {
//sort found records by offset.
//(it is not necessary but SlideShow.findMostRecentCoreRecords() expects them sorted)
// offset -> record
NavigableMap<Integer, Record> records = new TreeMap<Integer, Record>();
// offset -> persistId
Map<Integer, Integer> persistIds = new HashMap<Integer, Integer>();
initRecordOffsets(docstream, usrOffset, records, persistIds);
HSLFSlideShowEncrypted decryptData = new HSLFSlideShowEncrypted(docstream, records);
for (Map.Entry<Integer, Record> entry : records.entrySet()) {
Integer offset = entry.getKey();
Record record = entry.getValue();
Integer persistId = persistIds.get(offset);
if (record == null) {
// all plain records have been already added,
// only new records need to be decrypted (tbd #35897)
decryptData.decryptRecord(docstream, persistId, offset);
record = Record.buildRecordAtOffset(docstream, offset);
entry.setValue(record);
}
if (record instanceof PersistRecord) {
((PersistRecord) record).setPersistId(persistId);
}
}
decryptData.close();
return records.values().toArray(new Record[records.size()]);
}
Aggregations