package jxl.biff.drawing;

import common.Logger;
import java.util.ArrayList;
import jxl.biff.IntegerHelper;

/* JADX INFO: loaded from: classes.dex */
public class Dgg extends EscherAtom {
    public static /* synthetic */ Class class$jxl$biff$drawing$Dgg;
    private static Logger logger;
    private ArrayList clusters;
    private byte[] data;
    private int drawingsSaved;
    private int maxShapeId;
    private int numClusters;
    private int shapesSaved;

    public static final class Cluster {
        public int drawingGroupId;
        public int shapeIdsUsed;

        public Cluster(int i2, int i3) {
            this.drawingGroupId = i2;
            this.shapeIdsUsed = i3;
        }
    }

    static {
        Class clsClass$ = class$jxl$biff$drawing$Dgg;
        if (clsClass$ == null) {
            clsClass$ = class$("jxl.biff.drawing.Dgg");
            class$jxl$biff$drawing$Dgg = clsClass$;
        }
        logger = Logger.getLogger(clsClass$);
    }

    public Dgg(EscherRecordData escherRecordData) {
        super(escherRecordData);
        this.clusters = new ArrayList();
        byte[] bytes = getBytes();
        this.maxShapeId = IntegerHelper.getInt(bytes[0], bytes[1], bytes[2], bytes[3]);
        this.numClusters = IntegerHelper.getInt(bytes[4], bytes[5], bytes[6], bytes[7]);
        this.shapesSaved = IntegerHelper.getInt(bytes[8], bytes[9], bytes[10], bytes[11]);
        this.drawingsSaved = IntegerHelper.getInt(bytes[12], bytes[13], bytes[14], bytes[15]);
        int i2 = 16;
        for (int i3 = 0; i3 < this.numClusters; i3++) {
            this.clusters.add(new Cluster(IntegerHelper.getInt(bytes[i2], bytes[i2 + 1]), IntegerHelper.getInt(bytes[i2 + 2], bytes[i2 + 3])));
            i2 += 4;
        }
    }

    public static /* synthetic */ Class class$(String str) {
        try {
            return Class.forName(str);
        } catch (ClassNotFoundException e2) {
            throw new NoClassDefFoundError(e2.getMessage());
        }
    }

    public void addCluster(int i2, int i3) {
        this.clusters.add(new Cluster(i2, i3));
    }

    public Cluster getCluster(int i2) {
        return (Cluster) this.clusters.get(i2);
    }

    @Override // jxl.biff.drawing.EscherAtom, jxl.biff.drawing.EscherRecord
    public byte[] getData() {
        int size = this.clusters.size();
        this.numClusters = size;
        int i2 = 16;
        byte[] bArr = new byte[(size * 4) + 16];
        this.data = bArr;
        IntegerHelper.getFourBytes(this.shapesSaved + 1024, bArr, 0);
        IntegerHelper.getFourBytes(this.numClusters, this.data, 4);
        IntegerHelper.getFourBytes(this.shapesSaved, this.data, 8);
        IntegerHelper.getFourBytes(1, this.data, 12);
        for (int i3 = 0; i3 < this.numClusters; i3++) {
            Cluster cluster = (Cluster) this.clusters.get(i3);
            IntegerHelper.getTwoBytes(cluster.drawingGroupId, this.data, i2);
            IntegerHelper.getTwoBytes(cluster.shapeIdsUsed, this.data, i2 + 2);
            i2 += 4;
        }
        return setHeaderData(this.data);
    }

    public int getDrawingsSaved() {
        return this.drawingsSaved;
    }

    public int getShapesSaved() {
        return this.shapesSaved;
    }

    public Dgg(int i2, int i3) {
        super(EscherRecordType.DGG);
        this.shapesSaved = i2;
        this.drawingsSaved = i3;
        this.clusters = new ArrayList();
    }
}
