protected override CalcExpression VisitSheetRangeExpression(CalcSheetRangeExpression expr, int baseRow, int baseColumn)
        {
            bool flag  = (this._maxRowIndex.HasValue && !expr.IsFullColumn) && expr.StartRowRelative;
            bool flag2 = (this._maxColIndex.HasValue && !expr.IsFullRow) && expr.StartColumnRelative;
            bool flag3 = (this._maxRowIndex.HasValue && !expr.IsFullColumn) && expr.EndRowRelative;
            bool flag4 = (this._maxColIndex.HasValue && !expr.IsFullRow) && expr.EndColumnRelative;

            if ((!flag && !flag2) && (!flag3 && !flag4))
            {
                return(expr);
            }
            int num  = 0x7fffffff;
            int num2 = 0x7fffffff;
            IMultiSourceProvider startSource = expr.StartSource as IMultiSourceProvider;

            if (startSource != null)
            {
                foreach (ICalcSource source in startSource.GetCalcSources(expr.StartSource, expr.EndSource))
                {
                    num  = (num >= source.GetRowCount()) ? (source.GetRowCount() - 1) : num;
                    num2 = (num2 >= source.GetColumnCount()) ? (source.GetColumnCount() - 1) : num2;
                }
            }
            else
            {
                num  = expr.StartSource.GetRowCount() - 1;
                num2 = expr.EndSource.GetRowCount() - 1;
                num  = (num >= expr.EndSource.GetRowCount()) ? (expr.EndSource.GetRowCount() - 1) : num;
                num2 = (num2 >= expr.EndSource.GetColumnCount()) ? (expr.EndSource.GetColumnCount() - 1) : num2;
            }
            CalcSheetRangeIdentity identity = this.GetId(expr, baseRow, baseColumn) as CalcSheetRangeIdentity;
            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.VisitSheetRangeExpression(expr, baseRow, baseColumn));
            }
            return(new CalcErrorExpression(CalcErrors.Reference));
        }
Exemple #2
0
        protected override CalcExpression VisitSheetRangeExpression(CalcSheetRangeExpression expr, int baseRow, int baseColumn)
        {
            CalcSheetRangeIdentity id = expr.GetId(baseRow, baseColumn) as CalcSheetRangeIdentity;

            if (!this._isCopy || !this._offsetForDependency)
            {
                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.RowCount, id.ColumnCount))
                    {
                        expr = expr.Offset(this._rowOffset, this._columnOffset, this._offsetForDependency, true) as CalcSheetRangeExpression;
                    }
                    return(expr);
                }
                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 CalcSheetRangeExpression;
                    }
                }
            }
            return(expr);
        }
Exemple #3
0
 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;
     }
 }