FormInstanceManagerScript.java 3.68 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xfa.form;

import com.adobe.xfa.Arg;
import com.adobe.xfa.Node;
import com.adobe.xfa.Obj;
import com.adobe.xfa.ProtoableNodeScript;
import com.adobe.xfa.ScriptFuncObj;
import com.adobe.xfa.ScriptPropObj;
import com.adobe.xfa.ScriptTable;
import com.adobe.xfa.form.FormInstanceManager;

public class FormInstanceManagerScript
extends ProtoableNodeScript {
    protected static final ScriptTable moScriptTable = new ScriptTable(ProtoableNodeScript.moScriptTable, "instanceManager", new ScriptPropObj[]{new ScriptPropObj(FormInstanceManagerScript.class, "min", "getMin", null, 4, 21, 9, 0), new ScriptPropObj(FormInstanceManagerScript.class, "max", "getMax", null, 4, 21, 9, 0), new ScriptPropObj(FormInstanceManagerScript.class, "count", "getCount", "setCount", 4, 21, 9, 0)}, new ScriptFuncObj[]{new ScriptFuncObj(FormInstanceManagerScript.class, "setInstances", "setInstances", 1, new int[]{4}, 1, 21, 9, "instanceManagerPermsCheck", 0), new ScriptFuncObj(FormInstanceManagerScript.class, "addInstance", "addInstance", 7, new int[]{3}, 0, 21, 9, "instanceManagerPermsCheck", 0), new ScriptFuncObj(FormInstanceManagerScript.class, "insertInstance", "insertInstance", 7, new int[]{4, 3}, 1, 25, 9, "instanceManagerPermsCheck", 0), new ScriptFuncObj(FormInstanceManagerScript.class, "removeInstance", "removeInstance", 1, new int[]{4}, 1, 21, 9, "instanceManagerPermsCheck", 0), new ScriptFuncObj(FormInstanceManagerScript.class, "moveInstance", "moveInstance", 1, new int[]{4, 4}, 2, 21, 9, "instanceManagerPermsCheck", 0)});

    public static ScriptTable getScriptTable() {
        return moScriptTable;
    }

    public static void getMin(Obj obj, Arg retVal) {
        retVal.setInteger(((FormInstanceManager)obj).getMin());
    }

    public static void getMax(Obj obj, Arg retVal) {
        retVal.setInteger(((FormInstanceManager)obj).getMax());
    }

    public static void getCount(Obj obj, Arg retVal) {
        retVal.setInteger(((FormInstanceManager)obj).getCount());
    }

    public static void setCount(Obj obj, Arg arg) {
        if (arg.getArgType() != 2) {
            ((FormInstanceManager)obj).setInstances(arg.getInteger(), true);
        }
    }

    public static void setInstances(Obj obj, Arg retVal, Arg[] args) {
        ((FormInstanceManager)obj).setInstances(args[0].getInteger(), true);
    }

    public static void addInstance(Obj obj, Arg retVal, Arg[] args) {
        FormInstanceManager manager = (FormInstanceManager)obj;
        if (args.length == 0) {
            retVal.setObject(manager.addInstance(manager.getCount(), true));
        } else if (args.length == 1) {
            retVal.setObject(manager.addInstance(manager.getCount(), (boolean)args[0].getBool()));
        }
    }

    public static void insertInstance(Obj obj, Arg retVal, Arg[] args) {
        FormInstanceManager manager = (FormInstanceManager)obj;
        if (args.length == 1) {
            retVal.setObject(manager.addInstance(args[0].getInteger(), true));
        } else if (args.length == 2) {
            retVal.setObject(manager.addInstance(args[0].getInteger(), (boolean)args[1].getBool()));
        }
    }

    public static void removeInstance(Obj obj, Arg retVal, Arg[] args) {
        ((FormInstanceManager)obj).removeInstance(args[0].getInteger(), true);
    }

    public static void moveInstance(Obj obj, Arg retVal, Arg[] args) {
        ((FormInstanceManager)obj).moveInstance(args[0].getInteger(), args[1].getInteger(), true);
    }

    public static boolean instanceManagerPermsCheck(Obj obj, Arg[] args) {
        if (obj instanceof FormInstanceManager && !((FormInstanceManager)obj).instanceManagerPermsCheck()) {
            return false;
        }
        return true;
    }
}