Search in sources :

Example 1 with RecordAggregate

use of org.apache.poi.hssf.record.aggregates.RecordAggregate in project poi by apache.

the class InternalSheet method visitContainedRecords.

public void visitContainedRecords(RecordVisitor rv, int offset) {
    PositionTrackingVisitor ptv = new PositionTrackingVisitor(rv, offset);
    boolean haveSerializedIndex = false;
    for (int k = 0; k < _records.size(); k++) {
        RecordBase record = _records.get(k);
        if (record instanceof RecordAggregate) {
            RecordAggregate agg = (RecordAggregate) record;
            agg.visitContainedRecords(ptv);
        } else {
            ptv.visitRecord((Record) record);
        }
        // If the BOF record was just serialized then add the IndexRecord
        if (record instanceof BOFRecord) {
            if (!haveSerializedIndex) {
                haveSerializedIndex = true;
                //  and one shouldn't go in after that!
                if (_isUncalced) {
                    ptv.visitRecord(new UncalcedRecord());
                }
                //remove this guard. So be safe it is left here.
                if (_rowsAggregate != null) {
                    // find forward distance to first RowRecord
                    int initRecsSize = getSizeOfInitialSheetRecords(k);
                    int currentPos = ptv.getPosition();
                    ptv.visitRecord(_rowsAggregate.createIndexRecord(currentPos, initRecsSize));
                }
            }
        }
    }
}
Also used : PositionTrackingVisitor(org.apache.poi.hssf.record.aggregates.RecordAggregate.PositionTrackingVisitor) UncalcedRecord(org.apache.poi.hssf.record.UncalcedRecord) RecordBase(org.apache.poi.hssf.record.RecordBase) CustomViewSettingsRecordAggregate(org.apache.poi.hssf.record.aggregates.CustomViewSettingsRecordAggregate) RecordAggregate(org.apache.poi.hssf.record.aggregates.RecordAggregate) ChartSubstreamRecordAggregate(org.apache.poi.hssf.record.aggregates.ChartSubstreamRecordAggregate) BOFRecord(org.apache.poi.hssf.record.BOFRecord)

Example 2 with RecordAggregate

use of org.apache.poi.hssf.record.aggregates.RecordAggregate in project poi by apache.

the class InternalSheet method cloneSheet.

/**
     * Clones the low level records of this sheet and returns the new sheet instance.
     * This method is implemented by adding methods for deep cloning to all records that
     * can be added to a sheet. The <b>Record</b> object does not implement cloneable.
     * When adding a new record, implement a public clone method if and only if the record
     * belongs to a sheet.
     * 
     * @return the cloned sheet
     */
public InternalSheet cloneSheet() {
    List<Record> clonedRecords = new ArrayList<Record>(_records.size());
    for (int i = 0; i < _records.size(); i++) {
        RecordBase rb = _records.get(i);
        if (rb instanceof RecordAggregate) {
            ((RecordAggregate) rb).visitContainedRecords(new RecordCloner(clonedRecords));
            continue;
        }
        if (rb instanceof EscherAggregate) {
            /**
                 * this record will be removed after reading actual data from EscherAggregate
                 */
            rb = new DrawingRecord();
        }
        try {
            Record rec = (Record) ((Record) rb).clone();
            clonedRecords.add(rec);
        } catch (CloneNotSupportedException e) {
            throw new RecordFormatException(e);
        }
    }
    return createSheet(new RecordStream(clonedRecords, 0));
}
Also used : EscherAggregate(org.apache.poi.hssf.record.EscherAggregate) RecordFormatException(org.apache.poi.hssf.record.RecordFormatException) RecordBase(org.apache.poi.hssf.record.RecordBase) ArrayList(java.util.ArrayList) GutsRecord(org.apache.poi.hssf.record.GutsRecord) MergeCellsRecord(org.apache.poi.hssf.record.MergeCellsRecord) DefaultColWidthRecord(org.apache.poi.hssf.record.DefaultColWidthRecord) DefaultRowHeightRecord(org.apache.poi.hssf.record.DefaultRowHeightRecord) GridsetRecord(org.apache.poi.hssf.record.GridsetRecord) SCLRecord(org.apache.poi.hssf.record.SCLRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) NoteRecord(org.apache.poi.hssf.record.NoteRecord) CFHeaderRecord(org.apache.poi.hssf.record.CFHeaderRecord) Record(org.apache.poi.hssf.record.Record) EOFRecord(org.apache.poi.hssf.record.EOFRecord) PrintHeadersRecord(org.apache.poi.hssf.record.PrintHeadersRecord) RefModeRecord(org.apache.poi.hssf.record.RefModeRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) CalcCountRecord(org.apache.poi.hssf.record.CalcCountRecord) ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) PrintGridlinesRecord(org.apache.poi.hssf.record.PrintGridlinesRecord) IterationRecord(org.apache.poi.hssf.record.IterationRecord) FeatHdrRecord(org.apache.poi.hssf.record.FeatHdrRecord) CalcModeRecord(org.apache.poi.hssf.record.CalcModeRecord) SelectionRecord(org.apache.poi.hssf.record.SelectionRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) DVALRecord(org.apache.poi.hssf.record.DVALRecord) DeltaRecord(org.apache.poi.hssf.record.DeltaRecord) PaneRecord(org.apache.poi.hssf.record.PaneRecord) FeatRecord(org.apache.poi.hssf.record.FeatRecord) WSBoolRecord(org.apache.poi.hssf.record.WSBoolRecord) SaveRecalcRecord(org.apache.poi.hssf.record.SaveRecalcRecord) CFHeader12Record(org.apache.poi.hssf.record.CFHeader12Record) UncalcedRecord(org.apache.poi.hssf.record.UncalcedRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) CustomViewSettingsRecordAggregate(org.apache.poi.hssf.record.aggregates.CustomViewSettingsRecordAggregate) RecordAggregate(org.apache.poi.hssf.record.aggregates.RecordAggregate) ChartSubstreamRecordAggregate(org.apache.poi.hssf.record.aggregates.ChartSubstreamRecordAggregate) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord)

Aggregations

BOFRecord (org.apache.poi.hssf.record.BOFRecord)2 RecordBase (org.apache.poi.hssf.record.RecordBase)2 UncalcedRecord (org.apache.poi.hssf.record.UncalcedRecord)2 ChartSubstreamRecordAggregate (org.apache.poi.hssf.record.aggregates.ChartSubstreamRecordAggregate)2 CustomViewSettingsRecordAggregate (org.apache.poi.hssf.record.aggregates.CustomViewSettingsRecordAggregate)2 RecordAggregate (org.apache.poi.hssf.record.aggregates.RecordAggregate)2 ArrayList (java.util.ArrayList)1 CFHeader12Record (org.apache.poi.hssf.record.CFHeader12Record)1 CFHeaderRecord (org.apache.poi.hssf.record.CFHeaderRecord)1 CalcCountRecord (org.apache.poi.hssf.record.CalcCountRecord)1 CalcModeRecord (org.apache.poi.hssf.record.CalcModeRecord)1 ColumnInfoRecord (org.apache.poi.hssf.record.ColumnInfoRecord)1 DVALRecord (org.apache.poi.hssf.record.DVALRecord)1 DefaultColWidthRecord (org.apache.poi.hssf.record.DefaultColWidthRecord)1 DefaultRowHeightRecord (org.apache.poi.hssf.record.DefaultRowHeightRecord)1 DeltaRecord (org.apache.poi.hssf.record.DeltaRecord)1 DimensionsRecord (org.apache.poi.hssf.record.DimensionsRecord)1 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)1 EOFRecord (org.apache.poi.hssf.record.EOFRecord)1 EscherAggregate (org.apache.poi.hssf.record.EscherAggregate)1