public ValueEval evaluate(ValueEval[] args, int srcCellRow, int srcCellCol) {if(args.length < 1 || args.length > 5) {return ErrorEval.VALUE_INVALID;}try {BaseRef baseRef = evaluateBaseRef(args[0]);int rowOffset = (args[1] instanceof MissingArgEval) ? 0 : evaluateIntArg(args[1], srcCellRow, srcCellCol);int columnOffset = (args[2] instanceof MissingArgEval) ? 0 : evaluateIntArg(args[2], srcCellRow, srcCellCol);int height = baseRef.getHeight();int width = baseRef.getWidth();switch(args.length) {case 5:if(!(args[4] instanceof MissingArgEval)) {width = evaluateIntArg(args[4], srcCellRow, srcCellCol);}case 4:if(!(args[3] instanceof MissingArgEval)) {height = evaluateIntArg(args[3], srcCellRow, srcCellCol);}break;default:break;}if(height == 0 || width == 0) {return ErrorEval.REF_INVALID;}LinearOffsetRange rowOffsetRange = new LinearOffsetRange(rowOffset, height);LinearOffsetRange colOffsetRange = new LinearOffsetRange(columnOffset, width);return createOffset(baseRef, rowOffsetRange, colOffsetRange);} catch (EvaluationException e) {return e.getErrorEval();}}
public ValueEval Evaluate(ValueEval[] args, int srcCellRow, int srcCellCol){if (args.Length < 3 || args.Length > 5){return ErrorEval.VALUE_INVALID;}try{BaseRef baseRef = EvaluateBaseRef(args[0]);int rowOffset = EvaluateIntArg(args[1], srcCellRow, srcCellCol);int columnOffset = EvaluateIntArg(args[2], srcCellRow, srcCellCol);int height = baseRef.Height;int width = baseRef.Width;switch (args.Length){case 5:width = EvaluateIntArg(args[4], srcCellRow, srcCellCol);break;case 4:height = EvaluateIntArg(args[3], srcCellRow, srcCellCol);break;}if (height == 0 || width == 0){return ErrorEval.REF_INVALID;}LinearOffsetRange rowOffsetRange = new LinearOffsetRange(rowOffset, height);LinearOffsetRange colOffsetRange = new LinearOffsetRange(columnOffset, width);return CreateOffset(baseRef, rowOffsetRange, colOffsetRange);}catch (EvaluationException e){return e.GetErrorEval();}}