Ejemplo n.º 1
0
        /// <summary>
        /// Register a single command
        /// </summary>
        /// <param name="cmdName"></param>
        /// <param name="cmd"></param>
        internal void RegisterErrorCommand(string cmdName, CommandOperand cmd)
        {
            var name = new NameOperand();

            name.Value = cmdName;
            cmd.Name   = $"build-in:{cmdName}"; // this name is for debugging purposes only
            ErrorDict.Add(name, cmd);
        }
Ejemplo n.º 2
0
        // some convenience methods to increase readability of the using code

        /// <summary>
        /// Find a key and return its value
        /// Throw an exception if the key is not found
        /// </summary>
        public Operand Find(string key)
        {
            var keyOp = new NameOperand {
                Value = key
            };

            return(Find(keyOp));
        }
Ejemplo n.º 3
0
        public override void Execute(EpsInterpreter interpreter)
        {
            if (!IsExecutable)
            {
                interpreter.OperandStack.Push(Copy());
            }
            else
            {
                var name = new NameOperand(this.Value);
                var op   = DictionaryStackHelper.FindValue(interpreter.DictionaryStack, name);

                if (op != null)
                {
                    interpreter.Execute(op);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Prepare dictionaries
        /// </summary>
        private void PrepareStandardDictionaries(int postscriptVersion)
        {
            ResourceManager = new ResourceManager();
            ResourceManager.DefineResource("Category", new NameOperand("Generic"), new DictionaryOperand());

            DictionaryStack = new EpsStack <EpsDictionary>();
            SystemDict      = new EpsDictionary {
                IsPermanent = true
            };
            GlobalDict = new EpsDictionary {
                IsPermanent = true
            };
            UserDict = new EpsDictionary {
                IsPermanent = true
            };
            ErrorDict = new EpsDictionary {
                IsPermanent = true
            };
            DollarErrordict = new EpsDictionary {
                IsPermanent = true
            };
            statusDict = new EpsDictionary {
                IsPermanent = true
            };
            fontDict = new EpsDictionary {
                IsPermanent = true
            };

            DictionaryStack.Push(SystemDict);
            DictionaryStack.Push(GlobalDict);
            DictionaryStack.Push(UserDict);

            var systemDict = SystemDict;

            var     name    = new NameOperand("systemdict");
            Operand operand = new DictionaryOperand(SystemDict);

            systemDict.Add(name, operand);

            name    = new NameOperand("userdict");
            operand = new DictionaryOperand(UserDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("globaldict");
            operand = new DictionaryOperand(GlobalDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("statusdict");
            operand = new DictionaryOperand(statusDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("errordict");
            operand = new DictionaryOperand(ErrorDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("$error");
            operand = new DictionaryOperand(DollarErrordict);
            systemDict.Add(name, operand);

            name    = new NameOperand("GlobalFontDirectory");
            operand = new DictionaryOperand(fontDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("SharedFontDirectory");
            operand = new DictionaryOperand(fontDict);
            systemDict.Add(name, operand);

            name    = new NameOperand("true");
            operand = new BooleanOperand(true);
            systemDict.Add(name, operand);

            name    = new NameOperand("false");
            operand = new BooleanOperand(false);
            systemDict.Add(name, operand);

            name    = new NameOperand("null");
            operand = new NullOperand();
            systemDict.Add(name, operand);

            // for level 1 do not create this name, some adobe scripts
            // assume level 2 or higher just based on the existence of the name

            if (postscriptVersion >= 2)
            {
                name    = new NameOperand("languagelevel");
                operand = new IntegerOperand(postscriptVersion);
                systemDict.Add(name, operand);
            }

            name = new NameOperand("newerror");
            var b = new BooleanOperand(false);

            DollarErrordict.Add(name, b);
        }