protected override CalcExpression VisitExternalRangeExpression(CalcExternalRangeExpression expr, int baseRow, int baseColumn) { int num3; int num4; int num6; int num8; if ((base.CurrentCalcSource == null) || (base.CurrentCalcSource != expr.Source)) { return(expr); } if (this._isFullBand && ((this._isRow && expr.StartRowRelative) || (!this._isRow && expr.StartColumnRelative))) { return(expr); } CalcExternalRangeIdentity id = expr.GetId(baseRow, baseColumn) as CalcExternalRangeIdentity; int oldStart = this._isRow ? id.RowIndex : id.ColumnIndex; int oldEnd = this._isRow ? ((id.RowIndex + id.RowCount) - 1) : ((id.ColumnIndex + id.ColumnCount) - 1); this.GetRangeOffset(oldStart, oldEnd, out num3, out num4); int oldIndex = this._isRow ? baseRow : baseColumn; this.GetCellOffset(oldIndex, out num6); int num7 = this._isRow ? (baseRow + id.RowCount) : (baseColumn + id.ColumnCount); this.GetCellOffset(num7, out num8); if ((num3 == -2147483648) && (num4 == -2147483648)) { return(new CalcErrorExpression(CalcErrors.Reference)); } if ((num3 == -2147483648) || (num4 == -2147483648)) { return(expr); } int row = num3 - oldStart; if ((this._isRow && expr.StartRowRelative) || (!this._isRow && expr.StartColumnRelative)) { row -= num6 - oldIndex; } int endRow = num4 - oldEnd; if ((this._isRow && expr.EndRowRelative) || (!this._isRow && expr.EndColumnRelative)) { endRow -= num8 - num7; } if ((row == 0) && (endRow == 0)) { return(base.VisitExternalRangeExpression(expr, baseRow, baseColumn)); } if (this._isRow) { return(expr.Offset(row, 0, endRow, 0, true, !this.OffsetAbsoluteOnly)); } return(expr.Offset(0, row, 0, endRow, true, !this.OffsetAbsoluteOnly)); }
protected override CalcExpression VisitExternalRangeExpression(CalcExternalRangeExpression expr, int baseRow, int baseColumn) { CalcExternalRangeIdentity id = expr.GetId(baseRow, baseColumn) as CalcExternalRangeIdentity; if (this._isCopy && this._offsetForDependency) { return(expr); } if (this._offsetForDependency) { if ((!id.IsFullColumn && (((id.RowIndex + this._rowOffset) < 0) || ((((id.RowIndex + id.RowCount) - 1) + this._rowOffset) >= this._rowCount))) || (!id.IsFullRow && (((id.ColumnIndex + this._columnOffset) < 0) || ((((id.ColumnIndex + id.ColumnCount) - 1) + this._columnOffset) >= this._columnCount)))) { return(new CalcErrorExpression(CalcErrors.Reference)); } if (this.NeedMove(id.RowIndex, id.ColumnIndex, (id.RowIndex + id.RowCount) - 1, (id.ColumnIndex + id.ColumnCount) - 1)) { expr = expr.Offset(this._rowOffset, this._columnOffset, this._offsetForDependency, true) as CalcExternalRangeExpression; } } else if (!this._isCopy) { if (!expr.StartRowRelative && !expr.EndRowRelative) { this._rowOffset = 0; } if (!expr.StartColumnRelative && !expr.EndColumnRelative) { this._columnOffset = 0; } if (this.NeedMove(baseRow, baseColumn, baseRow + id.RowCount, baseColumn + id.ColumnCount)) { expr = expr.Offset(-this._rowOffset, -this._columnOffset, false, true) as CalcExternalRangeExpression; } } if (!this._convertToExternal || (expr.Source == this._extSource)) { return(expr); } if (expr.IsFullRow && expr.IsFullColumn) { return(new CalcExternalRangeExpression(this._extSource)); } if (expr.IsFullRow) { return(new CalcExternalRangeExpression(this._extSource, expr.StartRow, expr.EndRow, expr.StartRowRelative, expr.EndRowRelative, true)); } if (expr.IsFullColumn) { return(new CalcExternalRangeExpression(this._extSource, expr.StartColumn, expr.EndColumn, expr.StartColumnRelative, expr.EndColumnRelative, false)); } return(new CalcExternalRangeExpression(this._extSource, expr.StartRow, expr.StartColumn, expr.EndRow, expr.EndColumn, expr.StartRowRelative, expr.StartColumnRelative, expr.EndRowRelative, expr.EndColumnRelative)); }
protected override CalcExpression VisitExternalRangeExpression(CalcExternalRangeExpression expr, int baseRow, int baseColumn) { bool flag = !expr.IsFullColumn && expr.StartRowRelative; bool flag2 = !expr.IsFullRow && expr.StartColumnRelative; bool flag3 = !expr.IsFullColumn && expr.EndRowRelative; bool flag4 = !expr.IsFullRow && expr.EndColumnRelative; if ((!flag && !flag2) && (!flag3 && !flag4)) { return(expr); } int num = expr.Source.GetRowCount() - 1; int num2 = expr.Source.GetColumnCount() - 1; CalcExternalRangeIdentity identity = this.GetId(expr, baseRow, baseColumn) as CalcExternalRangeIdentity; int num3 = (identity.RowIndex + identity.RowCount) - 1; int num4 = (identity.ColumnIndex + identity.ColumnCount) - 1; if (((!flag || ((identity.RowIndex >= 0) && (identity.RowIndex <= num))) && (!flag2 || ((identity.ColumnIndex >= 0) && (identity.ColumnIndex <= num2)))) && ((!flag3 || ((num3 >= 0) && (num3 <= num))) && (!flag4 || ((num4 >= 0) && (num4 <= num2))))) { return(base.VisitExternalRangeExpression(expr, baseRow, baseColumn)); } return(new CalcErrorExpression(CalcErrors.Reference)); }
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; } }