Exemplo n.º 1
0
        protected override CalcExpression VisitRangeExpression(CalcRangeExpression expr, int baseRow, int baseColumn)
        {
            int num3;
            int num4;
            int num6;

            if (base.OffsetExternalOnly)
            {
                return(expr);
            }
            if (this._isFullBand && ((this._isRow && expr.StartRowRelative) || (!this._isRow && expr.StartColumnRelative)))
            {
                return(expr);
            }
            if ((this._isRow && expr.IsFullColumn) || (!this._isRow && expr.IsFullRow))
            {
                return(expr);
            }
            CalcRangeIdentity id = expr.GetId(baseRow, baseColumn) as CalcRangeIdentity;
            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);
            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 -= num6 - oldIndex;
            }
            if ((row == 0) && (endRow == 0))
            {
                return(base.VisitRangeExpression(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));
        }
Exemplo n.º 2
0
        public static bool ExtractIdentity(this CalcLocalIdentity id, out int row, out int column, out int rowCount, out int columnCount)
        {
            int num7;
            int num8;
            CalcCellIdentity  objA      = id as CalcCellIdentity;
            CalcRangeIdentity identity2 = id as CalcRangeIdentity;

            ConditionalGraph.ConditionalIdentity identity3 = id as ConditionalGraph.ConditionalIdentity;
            if (!object.ReferenceEquals(objA, null))
            {
                row      = objA.RowIndex;
                column   = objA.ColumnIndex;
                rowCount = columnCount = 1;
                return(true);
            }
            if (!object.ReferenceEquals(identity2, null))
            {
                if (identity2.IsFullRow && identity2.IsFullColumn)
                {
                    int num2;
                    int num3;
                    columnCount = num2 = -1;
                    rowCount    = num3 = num2;
                    row         = column = num3;
                }
                else if (identity2.IsFullRow)
                {
                    column   = columnCount = -1;
                    row      = identity2.RowIndex;
                    rowCount = identity2.RowCount;
                }
                else if (identity2.IsFullColumn)
                {
                    row         = rowCount = -1;
                    column      = identity2.ColumnIndex;
                    columnCount = identity2.ColumnCount;
                }
                else
                {
                    row         = identity2.RowIndex;
                    rowCount    = identity2.RowCount;
                    column      = identity2.ColumnIndex;
                    columnCount = identity2.ColumnCount;
                }
                return(true);
            }
            if (!object.ReferenceEquals(identity3, null))
            {
                return(identity3.ActualIdentity.ExtractIdentity(out row, out column, out rowCount, out columnCount));
            }
            columnCount = num7 = -2147483648;
            rowCount    = num8 = num7;
            row         = column = num8;
            return(false);
        }
Exemplo n.º 3
0
 void AddConditionsByRange(CellRange[] ranges, params IConditionalFormula[] conditions)
 {
     if (((ranges != null) && (ranges.Length != 0)) && ((conditions != null) && (conditions.Length != 0)))
     {
         for (int i = 0; i < ranges.Length; i++)
         {
             CalcRangeIdentity actualId = new CalcRangeIdentity(ranges[i].Row, ranges[i].Column, ranges[i].RowCount, ranges[i].ColumnCount);
             base.AddConditionals(actualId, conditions);
         }
     }
 }
Exemplo n.º 4
0
        protected override CalcExpression VisitRangeExpression(CalcRangeExpression expr, int baseRow, int baseColumn)
        {
            CalcRangeIdentity id = expr.GetId(baseRow, baseColumn) as CalcRangeIdentity;

            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.RowCount, id.ColumnCount))
                {
                    expr = expr.Offset(this._rowOffset, this._columnOffset, this._offsetForDependency, true) as CalcRangeExpression;
                }
            }
            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 CalcRangeExpression;
                }
            }
            if (!this._convertToExternal)
            {
                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));
        }
Exemplo n.º 5
0
        static CalcLocalIdentity Offset(CalcLocalIdentity id, int rowOffset, int colOffset)
        {
            CalcCellIdentity  cellIdentity = id as CalcCellIdentity;
            CalcRangeIdentity range        = id as CalcRangeIdentity;

            if (cellIdentity != null)
            {
                return(new CalcCellIdentity(cellIdentity, rowOffset, colOffset));
            }
            if (range != null)
            {
                return(new CalcRangeIdentity(range, rowOffset, colOffset));
            }
            return(id);
        }
Exemplo n.º 6
0
 public override bool IsIntersected(CalcIdentity srcId, CalcIdentity destId)
 {
     if (!object.ReferenceEquals(srcId, destId))
     {
         int num;
         int num2;
         CalcStructReferenceIndentity indentity = srcId as CalcStructReferenceIndentity;
         if ((indentity != null) && this.TryParseColumnIndex(indentity.ToString(), out num))
         {
             srcId = new CalcRangeIdentity(this.table.DataRange.Row, this.table.DataRange.Column + num, this.table.DataRange.RowCount, 1);
         }
         CalcStructReferenceIndentity indentity2 = destId as CalcStructReferenceIndentity;
         if ((indentity2 != null) && this.TryParseColumnIndex(indentity2.ToString(), out num2))
         {
             destId = new CalcRangeIdentity(this.table.DataRange.Row, this.table.DataRange.Column + num2, this.table.DataRange.RowCount, 1);
         }
     }
     return(base.IsIntersected(srcId, destId));
 }
Exemplo n.º 7
0
        internal static Dictionary <CalcLocalIdentity, CalcExpression> GetAllContainsIds(CalcCalculationManager mgr, CalcLocalIdentity id)
        {
            Dictionary <CalcCellIdentity, CalcExpression>  dictionary2;
            Dictionary <CalcRangeIdentity, CalcExpression> dictionary3;
            Dictionary <CalcLocalIdentity, CalcExpression> dictionary = new Dictionary <CalcLocalIdentity, CalcExpression>();

            GetAllContainsIds(mgr, id, out dictionary2, out dictionary3);
            foreach (KeyValuePair <CalcCellIdentity, CalcExpression> pair in dictionary2)
            {
                CalcCellIdentity introduced7 = pair.Key;
                dictionary[introduced7] = pair.Value;
            }
            foreach (KeyValuePair <CalcRangeIdentity, CalcExpression> pair2 in dictionary3)
            {
                CalcRangeIdentity introduced8 = pair2.Key;
                dictionary[introduced8] = pair2.Value;
            }
            return(dictionary);
        }
Exemplo n.º 8
0
        protected override CalcExpression VisitRangeExpression(CalcRangeExpression 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);
            }
            CalcRangeIdentity identity = this.GetId(expr, baseRow, baseColumn) as CalcRangeIdentity;
            int num  = (identity.RowIndex + identity.RowCount) - 1;
            int num2 = (identity.ColumnIndex + identity.ColumnCount) - 1;

            if (((!flag || ((identity.RowIndex >= 0) && (identity.RowIndex <= this._maxRowIndex.Value))) && (!flag2 || ((identity.ColumnIndex >= 0) && (identity.ColumnIndex <= this._maxColIndex.Value)))) && ((!flag3 || ((num >= 0) && (num <= this._maxRowIndex.Value))) && (!flag4 || ((num2 >= 0) && (num2 <= this._maxColIndex.Value)))))
            {
                return(base.VisitRangeExpression(expr, baseRow, baseColumn));
            }
            return(new CalcErrorExpression(CalcErrors.Reference));
        }
Exemplo n.º 9
0
        public static void ValidateIntersectedArrayFormula(CalcCalculationManager mgr, int row, int column, int rowCount, int columnCount, bool isInsertRowOrColumn)
        {
            List <CalcRangeIdentity> list;
            List <CalcRangeIdentity> list2;
            CalcRangeIdentity        objA = FormulaOperatorHelper.Indexs2Identity(row, column, (row + rowCount) - 1, (column + columnCount) - 1) as CalcRangeIdentity;

            if (object.ReferenceEquals(objA, null))
            {
                objA = new CalcRangeIdentity(row, column, 1, 1);
            }
            mgr.GetArrayFormulaByRange(objA, out list, out list2);
            if ((list2 != null) && (list2.Count > 0))
            {
                foreach (CalcRangeIdentity identity2 in list2)
                {
                    if (!isInsertRowOrColumn || (((!identity2.IsFullRow && !objA.IsFullRow) || (identity2.RowIndex < row)) && ((!identity2.IsFullColumn && !objA.IsFullColumn) || (identity2.ColumnIndex < column))))
                    {
                        throw new InvalidOperationException(ResourceStrings.FormulaChangePartOfArrayFormulaError);
                    }
                }
            }
        }
Exemplo n.º 10
0
        static void GetTargetFormulas(CalcCalculationManager sourceMgr, CalcCalculationManager targetMgr, int sourceRowCount, int sourceColumnCount, int fromRow, int fromColumn, int toRow, int toColumn, int fromRowCount, int fromColumnCount, int toRowCount, int toColumnCount, Dictionary <CalcCellIdentity, CalcExpression> cellFormulas, Dictionary <CalcRangeIdentity, CalcExpression> rangeFormulas, bool offsetSelf, out Dictionary <CalcLocalIdentity, CalcExpression> newExpressions)
        {
            MoveVisitor visitor;
            int         rowOffset    = toRow - fromRow;
            int         columnOffset = toColumn - fromColumn;
            CellRange   fromRange    = new CellRange(fromRow, fromColumn, fromRowCount, fromColumnCount);
            MoveVisitor visitor2     = new MoveVisitor(fromRange, rowOffset, columnOffset, sourceRowCount, sourceColumnCount, false, sourceMgr.Source, sourceMgr != targetMgr, null, !offsetSelf);

            newExpressions = new Dictionary <CalcLocalIdentity, CalcExpression>();
            if ((cellFormulas != null) && (cellFormulas.Count > 0))
            {
                for (int i = toRow; i < (toRow + toRowCount); i++)
                {
                    int rowIndex = ((i - toRow) % fromRowCount) + fromRow;
                    for (int j = toColumn; j < (toColumn + toColumnCount); j++)
                    {
                        int columnIndex           = ((j - toColumn) % fromColumnCount) + fromColumn;
                        CalcCellIdentity identity = new CalcCellIdentity(rowIndex, columnIndex);
                        CalcCellIdentity id       = new CalcCellIdentity(i, j);
                        if (cellFormulas.ContainsKey(identity))
                        {
                            CalcExpression expr = cellFormulas[identity];
                            if (!offsetSelf)
                            {
                                visitor = new MoveVisitor(fromRange, rowOffset, columnOffset, sourceRowCount, sourceColumnCount, false, sourceMgr.Source, false, null, true);
                                expr    = visitor.FirstVisit(expr, identity.RowIndex, identity.ColumnIndex);
                            }
                            else
                            {
                                expr = visitor2.Visit(expr, identity.RowIndex, identity.ColumnIndex);
                            }
                            newExpressions[id] = expr;
                        }
                        else if (targetMgr.GetExpression(id) != null)
                        {
                            newExpressions[id] = null;
                        }
                    }
                }
            }
            int num7 = (toRow + toRowCount) - 1;
            int num8 = (toColumn + toColumnCount) - 1;

            if ((rangeFormulas != null) && (rangeFormulas.Count > 0))
            {
                foreach (KeyValuePair <CalcRangeIdentity, CalcExpression> pair in rangeFormulas)
                {
                    int baseRow    = (pair.Key.RowIndex < 0) ? 0 : pair.Key.RowIndex;
                    int baseColumn = (pair.Key.ColumnIndex < 0) ? 0 : pair.Key.ColumnIndex;
                    if (!pair.Key.IsFullRow || !pair.Key.IsFullColumn)
                    {
                        if (pair.Key.IsFullColumn)
                        {
                            for (int k = toColumn; k <= num8; k += fromColumnCount)
                            {
                                int num12 = (k + pair.Key.ColumnCount) - 1;
                                num12 = (num12 > num8) ? (num8 - k) : num12;
                                CalcRangeIdentity identity3   = new CalcRangeIdentity((k + pair.Key.ColumnIndex) - fromColumn, (num12 - k) + 1, false);
                                CalcExpression    expression2 = pair.Value;
                                if (!offsetSelf)
                                {
                                    visitor     = new MoveVisitor(fromRange, 0, columnOffset, sourceRowCount, sourceColumnCount, false, sourceMgr.Source, sourceMgr != targetMgr, null, true);
                                    expression2 = visitor.Visit(expression2, baseRow, baseColumn);
                                }
                                else
                                {
                                    expression2 = visitor2.Visit(expression2, baseRow, baseColumn);
                                }
                                newExpressions[identity3] = expression2;
                            }
                        }
                        else if (pair.Key.IsFullRow)
                        {
                            for (int m = toRow; m <= num7; m += fromRowCount)
                            {
                                int num14 = (m + pair.Key.RowCount) - 1;
                                num14 = (num14 > num7) ? (num7 - m) : num14;
                                CalcRangeIdentity identity4   = new CalcRangeIdentity((m + pair.Key.RowIndex) - fromRow, (num14 - m) + 1, true);
                                CalcExpression    expression3 = pair.Value;
                                if (!offsetSelf)
                                {
                                    visitor     = new MoveVisitor(fromRange, rowOffset, 0, sourceRowCount, sourceColumnCount, false, sourceMgr.Source, sourceMgr != targetMgr, null, true);
                                    expression3 = visitor.Visit(expression3, baseRow, baseColumn);
                                }
                                else
                                {
                                    expression3 = visitor2.Visit(expression3, baseRow, baseColumn);
                                }
                                newExpressions[identity4] = expression3;
                            }
                        }
                        else
                        {
                            for (int n = toRow; n <= num7; n += fromRowCount)
                            {
                                int num16 = (n + pair.Key.RowCount) - 1;
                                num16 = (num16 > num7) ? (num7 - n) : num16;
                                for (int num17 = toColumn; num17 <= num8; num17 += fromColumnCount)
                                {
                                    int num18 = (num17 + pair.Key.ColumnCount) - 1;
                                    num18 = (num18 > num8) ? (num8 - num17) : num18;
                                    CalcRangeIdentity identity5   = new CalcRangeIdentity((n + pair.Key.RowIndex) - fromRow, (num17 + pair.Key.ColumnIndex) - fromColumn, (num16 - n) + 1, (num18 - num17) + 1);
                                    CalcExpression    expression4 = pair.Value;
                                    if (!offsetSelf)
                                    {
                                        expression4 = new MoveVisitor(fromRange, rowOffset, columnOffset, sourceRowCount, sourceColumnCount, false, sourceMgr.Source, sourceMgr != targetMgr, null, true).Visit(expression4, baseRow, baseColumn);
                                    }
                                    else
                                    {
                                        expression4 = visitor2.Visit(expression4, baseRow, baseColumn);
                                    }
                                    newExpressions[identity5] = expression4;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 11
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;
     }
 }
Exemplo n.º 12
0
 static void GetChangingIds(IFormulaOperatorSource mgr, bool row, ChangingContext context, OperatorExpressionVisistor visitor, bool updateDependents)
 {
     foreach (CalcLocalIdentity identity in mgr.GetAllLocalIdentities())
     {
         CalcIdentity id = identity;
         if (identity is ConditionalGraph.ConditionalIdentity)
         {
             ConditionalGraph.ConditionalIdentity identity3 = identity as ConditionalGraph.ConditionalIdentity;
             id = (identity3.OldActualIdentity != null) ? identity3.OldActualIdentity : identity3.ActualIdentity;
         }
         CalcNode node = mgr.GetNode(id);
         if ((node == null) || (node.OwnerNode == null))
         {
             CalcCellIdentity  identity4  = id as CalcCellIdentity;
             CalcRangeIdentity identity5  = id as CalcRangeIdentity;
             CalcExpression    expression = mgr.GetExpression(identity);
             CalcLocalIdentity identity6  = null;
             int oldStart = -2147483648;
             int oldEnd   = -2147483648;
             int newEnd   = -2147483648;
             if (identity4 != null)
             {
                 oldStart = row ? identity4.RowIndex : identity4.ColumnIndex;
             }
             else if (identity5 != null)
             {
                 if (identity5.IsFullRow && identity5.IsFullColumn)
                 {
                     identity6 = identity;
                     oldStart  = 0;
                 }
                 else if ((identity5.IsFullRow && !row) || (identity5.IsFullColumn && row))
                 {
                     if (node != null)
                     {
                         context.InvalidateFormula(mgr, identity5);
                     }
                     if (((node == null) || (node.Dependents == null)) || ((node.Dependents.Count == 0) || !updateDependents))
                     {
                         continue;
                     }
                     InvalidateNode(mgr, context, node);
                 }
                 else
                 {
                     oldStart = row ? identity5.RowIndex : identity5.ColumnIndex;
                     oldEnd   = row ? ((identity5.RowIndex + identity5.RowCount) - 1) : ((identity5.ColumnIndex + identity5.ColumnCount) - 1);
                 }
             }
             if (oldStart != -2147483648)
             {
                 if (identity6 == null)
                 {
                     int num2;
                     if (identity5 != null)
                     {
                         visitor.GetRangeOffset(oldStart, oldEnd, out num2, out newEnd);
                         if ((num2 == oldStart) && (newEnd == oldEnd))
                         {
                             continue;
                         }
                         if ((num2 == -2147483648) || (newEnd == -2147483648))
                         {
                             expression = null;
                         }
                         else if (identity5.IsFullRow && row)
                         {
                             identity6 = new CalcRangeIdentity(num2, (newEnd - num2) + 1, true);
                         }
                         else if (identity5.IsFullColumn && !row)
                         {
                             identity6 = new CalcRangeIdentity(num2, (newEnd - num2) + 1, false);
                         }
                         else if (row)
                         {
                             identity6 = new CalcRangeIdentity(num2, identity5.ColumnIndex, (newEnd - num2) + 1, identity5.ColumnCount);
                         }
                         else
                         {
                             identity6 = new CalcRangeIdentity(identity5.RowIndex, num2, identity5.RowCount, (newEnd - num2) + 1);
                         }
                     }
                     else if (identity4 != null)
                     {
                         visitor.GetCellOffset(oldStart, out num2);
                         if (num2 == oldStart)
                         {
                             continue;
                         }
                         if (num2 == -2147483648)
                         {
                             expression = null;
                         }
                         else if (identity4 != null)
                         {
                             identity6 = row ? new CalcCellIdentity(num2, identity4.ColumnIndex) : new CalcCellIdentity(identity4.RowIndex, num2);
                         }
                     }
                 }
                 context.ChangingIdentities[identity] = identity;
                 if (expression != null)
                 {
                     identity6 = (identity is ConditionalGraph.ConditionalIdentity) ? identity : identity6;
                     context.ChangedFormulas[identity6] = new Tuple <CalcLocalIdentity, CalcExpression>(identity, expression);
                 }
             }
         }
     }
 }
Exemplo n.º 13
0
        internal static void GetAllContainsIds(CalcCalculationManager mgr, CalcLocalIdentity id, out Dictionary <CalcCellIdentity, CalcExpression> cellFromulas, out Dictionary <CalcRangeIdentity, CalcExpression> arrayFormulas)
        {
            cellFromulas  = new Dictionary <CalcCellIdentity, CalcExpression>();
            arrayFormulas = new Dictionary <CalcRangeIdentity, CalcExpression>();
            CalcLocalIdentity identity   = id;
            CalcExpression    expression = mgr.GetExpression(identity);

            if ((expression == null) && (id is CalcCellIdentity))
            {
                int rowIndex                = (id as CalcCellIdentity).RowIndex;
                int columnIndex             = (id as CalcCellIdentity).ColumnIndex;
                CalcRangeIdentity identity2 = new CalcRangeIdentity(rowIndex, columnIndex, 1, 1);
                expression = mgr.GetExpression(identity2);
                identity   = identity2;
            }
            bool flag = false;

            if (expression == null)
            {
                flag = mgr.IsIsIntersectantWithArrayFormula(identity);
            }
            if (expression != null)
            {
                if (identity is CalcCellIdentity)
                {
                    cellFromulas.Add(identity as CalcCellIdentity, expression);
                }
                else if (identity is CalcRangeIdentity)
                {
                    arrayFormulas.Add(identity as CalcRangeIdentity, expression);
                }
            }
            else
            {
                if ((id is CalcCellIdentity) && flag)
                {
                    throw new InvalidOperationException(ResourceStrings.FormulaChangePartOfArrayFormulaError);
                }
                if (id is CalcRangeIdentity)
                {
                    CalcRangeIdentity identity3 = id as CalcRangeIdentity;
                    if ((identity3.RowCount != 1) || (identity3.ColumnCount != 1))
                    {
                        foreach (CalcLocalIdentity identity4 in mgr.Graph.GetAllLocalIdentities())
                        {
                            if (ContainsOrEqual(mgr, id, identity4))
                            {
                                expression = mgr.GetExpression(identity4);
                                if (expression != null)
                                {
                                    if (identity4 is CalcCellIdentity)
                                    {
                                        cellFromulas[identity4 as CalcCellIdentity] = expression;
                                    }
                                    else if (identity4 is CalcRangeIdentity)
                                    {
                                        arrayFormulas.Add(identity4 as CalcRangeIdentity, expression);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }