protected override CalcExpression VisitExternalCellExpression(CalcExternalCellExpression expr, int baseRow, int baseColumn) { int num2; int num4; int oldIndex = this._isRow ? baseRow : baseColumn; this.GetCellOffset(oldIndex, out num2); if ((base.CurrentCalcSource == null) || (base.CurrentCalcSource != expr.Source)) { if (oldIndex == num2) { return(expr); } if (this._isRow) { return(expr.Offset(oldIndex - num2, 0, false, true)); } return(expr.Offset(0, oldIndex - num2, false, true)); } if (this._isFullBand && ((this._isRow && expr.RowRelative) || (!this._isRow && expr.ColumnRelative))) { return(expr); } CalcExternalCellIdentity id = expr.GetId(baseRow, baseColumn) as CalcExternalCellIdentity; int num3 = this._isRow ? id.RowIndex : id.ColumnIndex; this.GetCellOffset(num3, out num4); if (num4 == -2147483648) { return(new CalcErrorExpression(CalcErrors.Reference)); } int row = num4 - num3; if ((this._isRow && expr.RowRelative) || (!this._isRow && expr.ColumnRelative)) { row -= num2 - oldIndex; } if (row == 0) { return(base.VisitExternalCellExpression(expr, baseRow, baseColumn)); } if (this._isRow) { return(expr.Offset(row, 0, true, !this.OffsetAbsoluteOnly)); } return(expr.Offset(0, row, true, !this.OffsetAbsoluteOnly)); }
protected override CalcExpression VisitExternalCellExpression(CalcExternalCellExpression expr, int baseRow, int baseColumn) { bool rowRelative = expr.RowRelative; bool columnRelative = expr.ColumnRelative; if (!rowRelative && !columnRelative) { return(expr); } int num = expr.Source.GetRowCount() - 1; int num2 = expr.Source.GetColumnCount() - 1; CalcExternalCellIdentity identity = this.GetId(expr, baseRow, baseColumn) as CalcExternalCellIdentity; if ((!rowRelative || ((identity.RowIndex >= 0) && (identity.RowIndex <= num))) && (!columnRelative || ((identity.ColumnIndex >= 0) && (identity.ColumnIndex <= num2)))) { return(expr); } return(new CalcErrorExpression(CalcErrors.Reference)); }
protected override CalcExpression VisitExternalCellExpression(CalcExternalCellExpression expr, int baseRow, int baseColumn) { CalcExternalCellIdentity id = expr.GetId(baseRow, baseColumn) as CalcExternalCellIdentity; if (!this._isCopy || !this._offsetForDependency) { if (this._offsetForDependency) { if ((((id.RowIndex + this._rowOffset) < 0) || ((id.ColumnIndex + this._columnOffset) < 0)) || (((id.RowIndex + this._rowOffset) >= this._rowCount) || ((id.ColumnIndex + this._columnOffset) >= this._columnCount))) { return(new CalcErrorExpression(CalcErrors.Reference)); } if (this.NeedMove(id.RowIndex, id.ColumnIndex, -1, -1)) { expr = expr.Offset(this._rowOffset, this._columnOffset, this._offsetForDependency, true) as CalcExternalCellExpression; } } else if (!this._isCopy) { if (!expr.RowRelative) { this._rowOffset = 0; } if (!expr.ColumnRelative) { this._columnOffset = 0; } if (this.NeedMove(baseRow, baseColumn, -1, -1)) { expr = expr.Offset(-this._rowOffset, -this._columnOffset, false, true) as CalcExternalCellExpression; } } if (this._convertToExternal && (expr.Source != this._extSource)) { return(new CalcExternalCellExpression(this._extSource, expr.Row, expr.Column, expr.RowRelative, expr.ColumnRelative)); } } return(expr); }
public static void Identity2Indexs(CalcIdentity id, out int startRow, out int startColumn, out int lastRow, out int lastColumn) { if (id is CalcCellIdentity) { CalcCellIdentity identity = id as CalcCellIdentity; startRow = identity.RowIndex; startColumn = identity.ColumnIndex; lastRow = identity.RowIndex; lastColumn = identity.ColumnIndex; } else if (id is CalcExternalCellIdentity) { CalcExternalCellIdentity identity2 = id as CalcExternalCellIdentity; startRow = identity2.RowIndex; startColumn = identity2.ColumnIndex; lastRow = identity2.RowIndex; lastColumn = identity2.ColumnIndex; } else if (id is CalcRangeIdentity) { CalcRangeIdentity identity3 = id as CalcRangeIdentity; if (identity3.IsFullRow) { startColumn = -1; lastColumn = -1; } else { startColumn = identity3.ColumnIndex; lastColumn = (identity3.ColumnIndex + identity3.ColumnCount) - 1; } if (identity3.IsFullColumn) { startRow = -1; lastRow = -1; } else { startRow = identity3.RowIndex; lastRow = (identity3.RowIndex + identity3.RowCount) - 1; } } else if (id is CalcExternalRangeIdentity) { CalcExternalRangeIdentity identity4 = id as CalcExternalRangeIdentity; if (identity4.IsFullRow) { startColumn = -1; lastColumn = -1; } else { startColumn = identity4.ColumnIndex; lastColumn = (identity4.ColumnIndex + identity4.ColumnCount) - 1; } if (identity4.IsFullColumn) { startRow = -1; lastRow = -1; } else { startRow = identity4.RowIndex; lastRow = (identity4.RowIndex + identity4.RowCount) - 1; } } else if (id is CalcSheetRangeIdentity) { CalcSheetRangeIdentity identity5 = id as CalcSheetRangeIdentity; if (identity5.IsFullRow) { startColumn = -1; lastColumn = -1; } else { startColumn = identity5.ColumnIndex; lastColumn = (identity5.ColumnIndex + identity5.ColumnCount) - 1; } if (identity5.IsFullColumn) { startRow = -1; lastRow = -1; } else { startRow = identity5.RowIndex; lastRow = (identity5.RowIndex + identity5.RowCount) - 1; } } else { startRow = -1; startColumn = -1; lastRow = -1; lastColumn = -1; } }