public static void Clear(CalcCalculationManager mgr, CalcLocalIdentity id) { Dictionary <CalcCellIdentity, CalcExpression> dictionary; Dictionary <CalcRangeIdentity, CalcExpression> dictionary2; FormulaOperatorHelper.GetAllContainsIds(mgr, id, out dictionary, out dictionary2); foreach (CalcCellIdentity identity in dictionary.Keys) { mgr.ClearExpression(identity); mgr.Invalidate(identity, false); } foreach (CalcRangeIdentity identity2 in dictionary2.Keys) { mgr.ClearExpression(identity2); mgr.Invalidate(identity2, false); } }
public void Swap(int fromRow, int fromColumn, int toRow, int toColumn, int rowCount, int columnCount) { CalcLocalIdentity id = FormulaOperatorHelper.Indexs2Identity(fromRow, fromColumn, (fromRow + rowCount) - 1, (fromColumn + columnCount) - 1); Dictionary <CalcLocalIdentity, CalcExpression> allContainsIds = FormulaOperatorHelper.GetAllContainsIds(this.Manager, id); CalcLocalIdentity identity2 = FormulaOperatorHelper.Indexs2Identity(toRow, toColumn, (toRow + rowCount) - 1, (toColumn + columnCount) - 1); Dictionary <CalcLocalIdentity, CalcExpression> dictionary2 = FormulaOperatorHelper.GetAllContainsIds(this.Manager, identity2); foreach (KeyValuePair <CalcLocalIdentity, CalcExpression> pair in allContainsIds) { this.Manager.ClearExpression(pair.Key); } foreach (KeyValuePair <CalcLocalIdentity, CalcExpression> pair2 in dictionary2) { this.Manager.ClearExpression(pair2.Key); } int rowOffset = toRow - fromRow; int colOffset = toColumn - fromColumn; ReferenceValidateVisitor visitor = new ReferenceValidateVisitor(new int?(this.RowCount), new int?(this.ColumnCount)); foreach (KeyValuePair <CalcLocalIdentity, CalcExpression> pair3 in allContainsIds) { int num3; int num4; int num5; int num6; FormulaOperatorHelper.Identity2Indexs(pair3.Key, out num3, out num4, out num5, out num6); CalcLocalIdentity identity3 = Offset(pair3.Key, rowOffset, colOffset); bool?isArrayFormula = null; CalcExpressionHelper.SetExpression(this.Manager, identity3, visitor.Visit(pair3.Value, num3 + rowOffset, num4 + colOffset), isArrayFormula); this.Manager.Invalidate(identity3, false); } foreach (KeyValuePair <CalcLocalIdentity, CalcExpression> pair4 in dictionary2) { int num7; int num8; int num9; int num10; FormulaOperatorHelper.Identity2Indexs(pair4.Key, out num7, out num8, out num9, out num10); CalcLocalIdentity identity4 = Offset(pair4.Key, -rowOffset, -colOffset); bool?nullable2 = null; CalcExpressionHelper.SetExpression(this.Manager, identity4, visitor.Visit(pair4.Value, num7 - rowOffset, num8 - colOffset), nullable2); this.Manager.Invalidate(identity4, false); } }
Dictionary <CalcLocalIdentity, CalcExpression> GetFormulaIds(int fromRow, int fromColumn, int rowCount, int columnCount, CalcCalculationManager sourceMgr, ChangingContext context, bool clearSource) { CalcLocalIdentity id = FormulaOperatorHelper.Indexs2Identity(fromRow, fromColumn, (fromRow + rowCount) - 1, (fromColumn + columnCount) - 1); Dictionary <CalcLocalIdentity, CalcExpression> allContainsIds = FormulaOperatorHelper.GetAllContainsIds(sourceMgr, id); if (clearSource) { foreach (CalcLocalIdentity identity2 in allContainsIds.Keys) { if (sourceMgr == this.Manager) { context.ChangedFormulas[identity2] = null; } else { context.AddExtChangedFormula(new FormulaOperatorSource(sourceMgr), identity2, identity2, null); } } } return(allContainsIds); }