MarkedContentOperands.java 4.93 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
 *  com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
 *  com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
 *  com.adobe.internal.pdftoolkit.core.types.ASArray
 *  com.adobe.internal.pdftoolkit.core.types.ASDictionary
 *  com.adobe.internal.pdftoolkit.core.types.ASName
 *  com.adobe.internal.pdftoolkit.core.types.ASNumber
 *  com.adobe.internal.pdftoolkit.core.types.ASObject
 *  com.adobe.internal.pdftoolkit.core.types.ASString
 */
package com.adobe.internal.pdftoolkit.pdf.content;

import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASArray;
import com.adobe.internal.pdftoolkit.core.types.ASDictionary;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.core.types.ASNumber;
import com.adobe.internal.pdftoolkit.core.types.ASObject;
import com.adobe.internal.pdftoolkit.core.types.ASString;
import com.adobe.internal.pdftoolkit.pdf.content.Instruction;
import com.adobe.internal.pdftoolkit.pdf.content.InstructionFactory;
import com.adobe.internal.pdftoolkit.pdf.graphics.PDFRectangle;
import com.adobe.internal.pdftoolkit.pdf.interchange.structure.PDFStructureArtifact;
import com.adobe.internal.pdftoolkit.pdf.interchange.structure.PDFStructureElement;

public class MarkedContentOperands {
    public static final ASName k_Artifact = ASName.create((String)"Artifact");
    public static final ASName k_Attached = ASName.create((String)"Attached");
    private PDFStructureElement mElement;
    private int mMCID;
    private PDFStructureArtifact mArtifact;
    private ASName mTag;
    private ASDictionary mParams = null;

    public MarkedContentOperands(PDFStructureElement element, int mcid) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
        this.mElement = element;
        this.mMCID = mcid;
        this.mArtifact = null;
        this.mTag = element.requireStructureType();
        this.mParams = new ASDictionary();
        this.mParams.put(ASName.k_MCID, (ASObject)new ASNumber(mcid));
    }

    public MarkedContentOperands(PDFStructureArtifact artifact) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
        ASString[] batesNumber;
        PDFRectangle bBox;
        ASName[] position;
        ASName subtype;
        this.mArtifact = artifact;
        this.mElement = null;
        this.mMCID = -1;
        this.mTag = k_Artifact;
        this.mParams = new ASDictionary();
        ASName type = artifact.getType();
        this.mParams.put(ASName.k_Type, (ASObject)type);
        if (type.equals((Object)PDFStructureArtifact.k_Pagination) && (subtype = artifact.getSubtype()) != null) {
            this.mParams.put(ASName.k_Subtype, (ASObject)subtype);
        }
        if ((bBox = artifact.getBBox()) != null) {
            ASArray location = new ASArray();
            location.add((ASObject)new ASNumber(bBox.left()));
            location.add((ASObject)new ASNumber(bBox.bottom()));
            location.add((ASObject)new ASNumber(bBox.right()));
            location.add((ASObject)new ASNumber(bBox.top()));
            this.mParams.put(ASName.k_BBox, (ASObject)location);
        }
        if ((position = artifact.getPosition()) != null) {
            ASArray posArray = new ASArray();
            for (int posInd = 0; posInd < position.length; ++posInd) {
                posArray.add((ASObject)position[posInd]);
            }
            this.mParams.put(k_Attached, (ASObject)posArray);
        }
        if ((batesNumber = artifact.getContents()) != null && batesNumber.length > 0) {
            if (batesNumber.length == 1) {
                this.mParams.put(ASName.k_Contents, (ASObject)batesNumber[0]);
            } else {
                ASArray batesArray = new ASArray();
                for (int iBates = 0; iBates < batesNumber.length; ++iBates) {
                    if (batesNumber == null) continue;
                    batesArray.add((ASObject)batesNumber[iBates]);
                }
                this.mParams.put(ASName.k_Contents, (ASObject)batesArray);
            }
        }
    }

    public PDFStructureArtifact getArtifact() {
        return this.mArtifact;
    }

    public ASName getTag() {
        return this.mTag;
    }

    public ASDictionary getParameters() {
        return this.mParams;
    }

    public PDFStructureElement getElement() {
        return this.mElement;
    }

    public int getMCID() {
        return this.mMCID;
    }

    public Instruction startMarkedContent() {
        return this.mParams == null ? InstructionFactory.newBeginMarkedContent(this.getTag()) : InstructionFactory.newBeginMarkedContent(this.getTag(), this.getParameters());
    }
}