Search in sources :

Example 1 with PersistRecord

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()]);
}
Also used : PersistRecord(org.apache.poi.hslf.record.PersistRecord) HashMap(java.util.HashMap) Record(org.apache.poi.hslf.record.Record) PositionDependentRecord(org.apache.poi.hslf.record.PositionDependentRecord) PersistRecord(org.apache.poi.hslf.record.PersistRecord) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 NavigableMap (java.util.NavigableMap)1 TreeMap (java.util.TreeMap)1 PersistRecord (org.apache.poi.hslf.record.PersistRecord)1 PositionDependentRecord (org.apache.poi.hslf.record.PositionDependentRecord)1 Record (org.apache.poi.hslf.record.Record)1