Border.java 3.04 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xfa.template.formatting;

import com.adobe.xfa.AppModel;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.EnumAttr;
import com.adobe.xfa.EnumValue;
import com.adobe.xfa.Model;
import com.adobe.xfa.Node;
import com.adobe.xfa.ProtoableNode;
import com.adobe.xfa.XFA;
import org.xml.sax.Attributes;

public final class Border
extends ProtoableNode {
    public Border(Element parent, Node prevSibling) {
        super(parent, prevSibling, null, "border", "border", null, XFA.BORDERTAG, "border");
    }

    @Override
    public Attribute defaultAttribute(int eTag) {
        if (eTag == XFA.PRESENCETAG && this.isDefault(true)) {
            return EnumValue.getEnum(XFA.PRESENCETAG, EnumAttr.getEnum(1076494338));
        }
        return super.defaultAttribute(eTag);
    }

    @Override
    protected Node defaultElementImpl(int eTag, int nOccurrence, boolean bAppend) {
        if (eTag == XFA.SCHEMA_DEFAULTTAG) {
            eTag = this.defaultElement();
        }
        if (eTag == XFA.SCHEMA_DEFAULTTAG) {
            return null;
        }
        Element e = null;
        if (nOccurrence == 0) {
            String className = XFA.getString(eTag);
            Border parent = bAppend ? this : null;
            e = this.getModel().createElement(parent, this.getLastXMLChild(), null, className, className, null, 0, null);
        } else if (nOccurrence == 1) {
            Element source;
            e = bAppend ? this.getElement(eTag, false, 0, false, false).clone(this, true) : ((source = this.getElement(eTag, true, 0, false, false)) != null ? source.clone(null, true) : this.getModel().createElement(eTag, null));
        } else if (nOccurrence == 2) {
            if (bAppend) {
                this.getElement(eTag, false, 1, false, false);
                e = this.getElement(eTag, false, 0, false, false).clone(this, true);
            } else {
                Element source = this.getElement(eTag, true, 0, false, false);
                e = source != null ? source.clone(null, true) : this.getModel().createElement(eTag, null);
            }
        } else if (nOccurrence == 3 || this.getAppModel().getLegacySetting(AppModel.XFA_LEGACY_V27_SCRIPTING)) {
            if (bAppend) {
                this.getElement(eTag, false, 2, false, false);
                e = this.getElement(eTag, false, 1, false, false).clone(this, true);
            } else {
                Element source = this.getElement(eTag, true, 0, false, false);
                if (source != null) {
                    e = source.clone(null, true);
                } else {
                    this.getElement(eTag, false, 1, false, false);
                    e = this.getElement(eTag, false, 1, false, false).clone(null, true);
                }
            }
        }
        if (e != null) {
            e.isTransient(true, false);
        }
        return e;
    }

    @Override
    public boolean isContextSensitiveAttribute(int eTag) {
        return eTag == XFA.PRESENCETAG || super.isContextSensitiveAttribute(eTag);
    }
}