Example #1
0
        private static List <CalcLocalIdentity> GetDepIdsInSharedFormulaRange(CalcCalculationManager mgr, CalcRangeIdentity sharedFormulaRange, CalcLocalIdentity dityId)
        {
            int num;
            int num2;
            int num3;
            int num4;
            int num5;
            int num6;
            int num7;
            int num8;
            List <CalcLocalIdentity> list = new List <CalcLocalIdentity>();

            LocalId2Index(sharedFormulaRange, out num, out num2, out num3, out num4);
            ReferencePredenceVisitor visitor = new ReferencePredenceVisitor(mgr.Source, num, num2);

            visitor.Visit(mgr.GetExpression(sharedFormulaRange), num, num2);
            Dictionary <CalcLocalIdentity, bool> predenceIds = visitor.PredenceIds;

            LocalId2Index(dityId, out num5, out num6, out num7, out num8);
            foreach (KeyValuePair <CalcLocalIdentity, bool> pair in predenceIds)
            {
                int num9;
                int num10;
                int num11;
                int num12;
                CalcRangeIdentity key = pair.Key as CalcRangeIdentity;
                if ((key != null) && (key.IsFullRow || key.IsFullColumn))
                {
                    list.Clear();
                    list.Add(sharedFormulaRange);
                    return(list);
                }
                LocalId2Index(pair.Key, out num9, out num10, out num11, out num12);
                int rowIndex    = (num5 > num11) ? ((num + num5) - num11) : num;
                int columnIndex = (num6 > num12) ? ((num2 + num6) - num12) : num2;
                int num15       = (num + num7) - num9;
                num15 = (num15 > num3) ? num3 : num15;
                int num16 = (num2 + num8) - num10;
                num16 = (num16 > num4) ? num4 : num16;
                if (((rowIndex <= num3) && (num15 >= num)) && ((columnIndex <= num4) && (num16 >= num2)))
                {
                    if (!pair.Value)
                    {
                        list.Clear();
                        list.Add(sharedFormulaRange);
                        return(list);
                    }
                    CalcRangeIdentity item = new CalcRangeIdentity(rowIndex, columnIndex, (num15 - rowIndex) + 1, (num16 - columnIndex) + 1);
                    if (!list.Contains(item))
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Example #2
0
        internal bool EvaluateFormula(CalcCalculationManager mgr, DirtyItem dirtyItem)
        {
            CalcLocalIdentity id = dirtyItem.Id as CalcLocalIdentity;

            if (object.ReferenceEquals(id, null))
            {
                return(false);
            }
            CalcExpression objA = mgr.GetExpression(id);

            if (object.ReferenceEquals(objA, null))
            {
                return(false);
            }
            ICalcSource source = mgr.Source;
            Dictionary <CalcLocalIdentity, CalcExpression> dictionary = new Dictionary <CalcLocalIdentity, CalcExpression>();

            if ((id is CalcRangeIdentity) && mgr.Graph.IsSharedFormula(id as CalcRangeIdentity))
            {
                List <CalcLocalIdentity> dirtySubIds = new List <CalcLocalIdentity>();
                SharedFormulaDirtyItem   item        = dirtyItem as SharedFormulaDirtyItem;
                if ((item != null) && !item.IsFullRangeDirty)
                {
                    dirtySubIds = (dirtyItem as SharedFormulaDirtyItem).DirtySubIds;
                }
                else
                {
                    dirtySubIds.Add(id);
                }
                foreach (CalcLocalIdentity identity3 in dirtySubIds)
                {
                    int  num;
                    int  num2;
                    int  num3;
                    int  num4;
                    bool flag;
                    CalcRangeIdentity identity4 = identity3 as CalcRangeIdentity;
                    CalcReferenceHelper.Id2Range(source, identity3, out num, out num2, out num3, out num4, out flag);
                    for (int i = num; i < (num + num3); i++)
                    {
                        for (int j = num2; j < (num2 + num4); j++)
                        {
                            if ((identity4 != null) && (identity4.IsFullRow || identity4.IsFullColumn))
                            {
                                new FullBandMappingVisitor(identity4.IsFullRow, identity4.IsFullRow ? i : j).Visit(objA, 0, 0);
                            }
                            CalcCellIdentity identity5  = new CalcCellIdentity(i, j);
                            CalcExpression   expression = mgr.GetExpression(identity5);
                            if (((expression != null) && (expression == objA)) && !mgr.Graph.IsIsIntersectantWithArrayFormula(identity5))
                            {
                                dictionary[identity5] = objA;
                            }
                        }
                    }
                }
            }
            else
            {
                dictionary.Add(id, objA);
            }
            foreach (KeyValuePair <CalcLocalIdentity, CalcExpression> pair in dictionary)
            {
                id = pair.Key;
                object obj2 = mgr.Evaluator.Evaluate(pair.Value, source.GetEvaluatorContext(id));
                while (!(id is CalcRangeIdentity) && ((obj2 is CalcReference) || (obj2 is CalcArray)))
                {
                    if (obj2 is CalcReference)
                    {
                        obj2 = ExtractValueFromReference(id, obj2);
                    }
                    if (obj2 is CalcArray)
                    {
                        obj2 = (obj2 as CalcArray).GetValue(0);
                    }
                }
                source.SetValue(id, obj2);
            }
            return(true);
        }