示例#1
0
        // Register SDFs (and maybe later: convert DELAY calls to DelayCell).
        private void RegisterSdfs(Sheet sheet, int col, int row)
        {
            Cell cell = sheet[col, row];

            if (cell == null || !(cell is Formula))
            {
                return;
            }
            Expr e = (cell as Formula).Expr;

            if (!(e is FunCall))
            {
                return;
            }
            FunCall funCall = e as FunCall;

            Expr[] es = funCall.es;
            switch (funCall.function.name)
            {
            case "DEFINE":
                if (es.Length >= 2 && es[0] is TextConst && es[1] is CellRef)
                {
                    String         sdfName    = ((TextConst)es[0]).value.value;
                    FullCellAddr   outputCell = ((CellRef)es[1]).GetAbsoluteAddr(sheet, col, row);
                    FullCellAddr[] inputCells = new FullCellAddr[es.Length - 2];
                    bool           ok         = true;
                    for (int i = 2; ok && i < es.Length; i++)
                    {
                        CellRef inputCellRef = es[i] as CellRef;
                        ok = inputCellRef != null;
                        if (ok)
                        {
                            inputCells[i - 2] = inputCellRef.GetAbsoluteAddr(sheet, col, row);
                        }
                    }
                    if (ok)
                    {
                        Funcalc.SdfManager.Register(outputCell, inputCells, sdfName);
                    }
                }
                break;

            case "DELAY":
                break;
            }
        }
示例#2
0
        public void CallVisitor(CellRef cellRef)
        {
            FullCellAddr cellAddr = cellRef.GetAbsoluteAddr(thisFca);

            if (cellAddr.sheet != thisFca.sheet)
            {
                // Reference to other sheet, hopefully a normal sheet
                result = new CGNormalCellRef(cellAddr);
            }
            else if (this.addressToVariable.ContainsKey(cellAddr))
            {
                // Reference to a cell that has already been computed in a local variable
                result = new CGCellRef(cellAddr, this.addressToVariable[cellAddr]);
            }
            else             // Inline the cell's formula's expression
            {
                result = BuildExpression(cellAddr, addressToVariable);
            }
        }
示例#3
0
		public void CallVisitor(CellRef cellRef) {
			FullCellAddr cellAddr = cellRef.GetAbsoluteAddr(thisFca);
			if (cellAddr.sheet != thisFca.sheet) {
				// Reference to other sheet, hopefully a normal sheet
				result = new CGNormalCellRef(cellAddr);
			}
			else if (this.addressToVariable.ContainsKey(cellAddr)) {
				// Reference to a cell that has already been computed in a local variable
				result = new CGCellRef(cellAddr, this.addressToVariable[cellAddr]);
			}
			else // Inline the cell's formula's expression
			{
				result = BuildExpression(cellAddr, addressToVariable);
			}
		}