Пример #1
0
        static void UpdataCustomnNames(IFormulaOperatorSource mgr, Dt.Cells.Data.ExpressionVisitor visitor)
        {
            ICustomNameSupport         source   = mgr.Source as ICustomNameSupport;
            OperatorExpressionVisistor visistor = visitor as OperatorExpressionVisistor;

            if ((source != null) && (visistor != null))
            {
                Dictionary <string, CalcExpression> dictionary;
                Dictionary <ICustomNameSupport, Dictionary <string, CalcExpression> > dictionary2;
                CalcExpression expression;
                source.EnumerateAllNames(out dictionary, out dictionary2);
                visistor.OffsetAbsoluteOnly = true;
                visistor.CurrentCalcSource  = mgr.Source;
                foreach (KeyValuePair <string, CalcExpression> pair in dictionary)
                {
                    expression = visitor.Visit(pair.Value, 0, 0);
                    if (expression != pair.Value)
                    {
                        source.SetDefinedName(pair.Key, expression, true);
                    }
                }
                foreach (KeyValuePair <ICustomNameSupport, Dictionary <string, CalcExpression> > pair2 in dictionary2)
                {
                    source = pair2.Key;
                    foreach (KeyValuePair <string, CalcExpression> pair3 in pair2.Value)
                    {
                        expression = visitor.Visit(pair3.Value, 0, 0);
                        if (expression != pair3.Value)
                        {
                            source.SetDefinedName(pair3.Key, expression, false);
                        }
                    }
                }
                if (visistor != null)
                {
                    visistor.OffsetAbsoluteOnly = false;
                    visistor.CurrentCalcSource  = null;
                }
            }
        }
Пример #2
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);
                 }
             }
         }
     }
 }