Exemplo n.º 1
0
 internal static CalcNode CreateTempNode(ICalcSource source, CalcIdentity id)
 {
     return(new CalcNode(source, id)
     {
         _isTempNode = true
     });
 }
Exemplo n.º 2
0
        internal static void Id2Range(ICalcSource source, CalcIdentity Id, out int row, out int col, out int rowCount, out int colCount, out bool searchRange)
        {
            int num;
            int num2;

            colCount    = num = 1;
            rowCount    = num2 = num;
            row         = col = num2;
            searchRange = false;
            CalcCellIdentity  objA      = Id as CalcCellIdentity;
            CalcRangeIdentity identity2 = Id as CalcRangeIdentity;

            if (!object.ReferenceEquals(objA, null))
            {
                row         = objA.RowIndex;
                col         = objA.ColumnIndex;
                rowCount    = colCount = 1;
                searchRange = true;
            }
            else if (!object.ReferenceEquals(identity2, null))
            {
                if (identity2.IsFullColumn || identity2.IsFullRow)
                {
                    CalcReference reference = source.GetReference(identity2) as CalcReference;
                    row      = reference.GetRow(0);
                    col      = reference.GetColumn(0);
                    rowCount = reference.GetRowCount(0);
                    colCount = reference.GetColumnCount(0);
                }
                if (identity2.IsFullRow)
                {
                    row      = identity2.RowIndex;
                    rowCount = identity2.RowCount;
                }
                else if (identity2.IsFullColumn)
                {
                    col      = identity2.ColumnIndex;
                    colCount = identity2.ColumnCount;
                }
                else
                {
                    row      = identity2.RowIndex;
                    rowCount = identity2.RowCount;
                    col      = identity2.ColumnIndex;
                    colCount = identity2.ColumnCount;
                }
                searchRange = true;
            }
            else
            {
                int num5;
                int num6;
                colCount = num5 = 0;
                rowCount = num6 = num5;
                row      = col = num6;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Determines whether the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" /> 
 /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
 /// </summary>
 /// <param name="other">
 /// The <see cref="T:Dt.CalcEngine.CalcCellIdentity" /> to compare with the
 /// current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />. 
 /// </param>
 /// <returns>
 /// <see langword="true" /> if the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" /> 
 /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />; 
 /// otherwise, <see langword="false" />.
 /// </returns>
 protected override bool CompareTo(CalcIdentity other)
 {
     CalcCellIdentity objA = other as CalcCellIdentity;
     if (object.ReferenceEquals(objA, null))
     {
         return false;
     }
     return ((this._rowIndex == objA._rowIndex) && (this._columnIndex == objA._columnIndex));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the value at specified position which indicated by <paramref name="id" />.
 /// </summary>
 /// <param name="id">A <see cref="T:Dt.CalcEngine.CalcIdentity" /> indicates the identity of a address.</param>
 /// <returns>
 /// An <see cref="T:System.Object" /> indicates the value.
 /// If the <paramref name="id" /> is not recognized, return <see cref="F:Dt.CalcEngine.CalcErrors.Reference" />.
 /// </returns>
 public virtual object GetValue(CalcIdentity id)
 {
     if (id is CalcExternalIdentity)
     {
         CalcExternalIdentity identity = id as CalcExternalIdentity;
         ICalcSource          source   = identity.Source;
         if (source != null)
         {
             CalcLocalIdentity identity3;
             CalcLocalIdentity identity2 = identity.ConvertToLocal();
             if ((this.ArrayFormulaMode || (this.RowCount > 1)) || (this.ColumnCount > 1))
             {
                 identity3 = new CalcRangeIdentity(this.Row, this.Column, this.RowCount, this.ColumnCount);
             }
             else
             {
                 identity3 = new CalcCellIdentity(this.Row, this.Column);
             }
             return(source.GetEvaluatorContext(identity3).GetValue(identity2));
         }
     }
     else if ((this.Source != null) && (id is CalcLocalIdentity))
     {
         CalcRangeIdentity objA = id as CalcRangeIdentity;
         if (object.ReferenceEquals(objA, null))
         {
             return(this.Source.GetValue(id as CalcLocalIdentity));
         }
         if (objA._isFullColumn && objA._isFullRow)
         {
             return(this.Source.GetValue(new CalcCellIdentity(this.Row, this.Column)));
         }
         if (objA._isFullColumn)
         {
             return(this.Source.GetValue(new CalcCellIdentity(this.Row, objA._columnIndex)));
         }
         if (objA._isFullRow)
         {
             return(this.Source.GetValue(new CalcCellIdentity(objA._rowIndex, this.Column)));
         }
         if (((objA._rowCount == 1) && (objA._columnIndex <= this.Column)) && (this.Column < (objA._columnIndex + objA._columnCount)))
         {
             return(this.Source.GetValue(new CalcCellIdentity(objA._rowIndex, this.Column)));
         }
         if (((objA._columnCount == 1) && (objA._rowIndex <= this.Row)) && (this.Row < (objA._rowIndex + objA._rowCount)))
         {
             return(this.Source.GetValue(new CalcCellIdentity(this.Row, objA._columnIndex)));
         }
         if ((objA._rowCount == 1) && (objA._columnCount == 1))
         {
             return(this.Source.GetValue(new CalcCellIdentity(objA._rowIndex, objA._columnIndex)));
         }
         return(CalcErrors.Value);
     }
     return(CalcErrors.Reference);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Determines whether the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </summary>
        /// <param name="other">
        /// The <see cref="T:Dt.CalcEngine.CalcCellIdentity" /> to compare with the
        /// current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </param>
        /// <returns>
        /// <see langword="true" /> if the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />;
        /// otherwise, <see langword="false" />.
        /// </returns>
        protected override bool CompareTo(CalcIdentity other)
        {
            CalcRangeIdentity objA = other as CalcRangeIdentity;

            if (object.ReferenceEquals(objA, null))
            {
                return(false);
            }
            return(((((this._isFullRow == objA._isFullRow) && (this._isFullColumn == objA._isFullColumn)) && ((this._rowIndex == objA._rowIndex) && (this._columnIndex == objA._columnIndex))) && (this._rowCount == objA._rowCount)) && (this._columnCount == objA._columnCount));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Determines whether the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </summary>
        /// <param name="other">
        /// The <see cref="T:Dt.CalcEngine.CalcCellIdentity" /> to compare with the
        /// current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </param>
        /// <returns>
        /// <see langword="true" /> if the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />;
        /// otherwise, <see langword="false" />.
        /// </returns>
        protected override bool CompareTo(CalcIdentity other)
        {
            CalcExternalNameIdentity objA = other as CalcExternalNameIdentity;

            if (object.ReferenceEquals(objA, null))
            {
                return(false);
            }
            return(object.ReferenceEquals(base.Source, objA.Source) && (this.Name == objA.Name));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Determines whether the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </summary>
        /// <param name="other">
        /// The <see cref="T:Dt.CalcEngine.CalcCellIdentity" /> to compare with the
        /// current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </param>
        /// <returns>
        /// <see langword="true" /> if the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />;
        /// otherwise, <see langword="false" />.
        /// </returns>
        protected override bool CompareTo(CalcIdentity other)
        {
            CalcSheetRangeIdentity objA = other as CalcSheetRangeIdentity;

            if (object.ReferenceEquals(objA, null))
            {
                return(false);
            }
            return(((((this.StartSource == objA.StartSource) && (this.EndSource == objA.EndSource)) && ((this.IsFullRow == objA.IsFullRow) && (this.IsFullColumn == objA.IsFullColumn))) && (((this.RowIndex == objA.RowIndex) && (this.ColumnIndex == objA.ColumnIndex)) && (this.RowCount == objA.RowCount))) && (this.ColumnCount == objA.ColumnCount));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Determines whether the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </summary>
        /// <param name="other">
        /// The <see cref="T:Dt.CalcEngine.CalcCellIdentity" /> to compare with the
        /// current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </param>
        /// <returns>
        /// <see langword="true" /> if the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />;
        /// otherwise, <see langword="false" />.
        /// </returns>
        protected override bool CompareTo(CalcIdentity other)
        {
            CalcExternalCellIdentity objA = other as CalcExternalCellIdentity;

            if (object.ReferenceEquals(objA, null))
            {
                return(false);
            }
            return(((base._source == objA._source) && (this._rowIndex == objA._rowIndex)) && (this._columnIndex == objA._columnIndex));
        }
Exemplo n.º 9
0
 /// <summary>
 /// Determines whether the specified <see cref="T:Dt.CalcEngine.CalcIdentity" /> is intersected with another one.
 /// </summary>
 /// <param name="srcId">The source identity, intersected this with another one.</param>
 /// <param name="destId">The destination identity,</param>
 /// <returns>
 /// <see langword="true" /> if the specified calc identity is intersected; otherwise, <see langword="false" />.
 /// By default, compare two by <see cref="M:System.Object.ReferenceEquals(System.Object,System.Object)" />.
 /// </returns>
 public virtual bool IsIntersected(CalcIdentity srcId, CalcIdentity destId)
 {
     if (srcId == destId)
     {
         return(true);
     }
     if (srcId is CalcCellIdentity)
     {
         if (destId is CalcRangeIdentity)
         {
             return(IsIntersected(srcId as CalcCellIdentity, destId as CalcRangeIdentity));
         }
     }
     else if (srcId is CalcRangeIdentity)
     {
         if (destId is CalcCellIdentity)
         {
             return(IsIntersected(destId as CalcCellIdentity, srcId as CalcRangeIdentity));
         }
         if (destId is CalcRangeIdentity)
         {
             CalcRangeIdentity identity  = srcId as CalcRangeIdentity;
             CalcRangeIdentity identity2 = destId as CalcRangeIdentity;
             if ((identity._isFullColumn && identity._isFullRow) || (identity2._isFullColumn && identity2._isFullRow))
             {
                 return(true);
             }
             if (identity._isFullColumn || identity2._isFullColumn)
             {
                 if (!InRange(identity._columnIndex, identity2._columnIndex, identity2._columnIndex + identity2._columnCount))
                 {
                     return(InRange(identity2._columnIndex, identity._columnIndex, identity._columnIndex + identity._columnCount));
                 }
                 return(true);
             }
             if (identity._isFullRow || identity2._isFullRow)
             {
                 if (!InRange(identity._rowIndex, identity2._rowIndex, identity2._rowIndex + identity2._rowCount))
                 {
                     return(InRange(identity2._rowIndex, identity._rowIndex, identity._rowIndex + identity._rowCount));
                 }
                 return(true);
             }
             return((InRange(identity._rowIndex, identity2._rowIndex, identity2._rowIndex + identity2._rowCount) && InRange(identity._columnIndex, identity2._columnIndex, identity2._columnIndex + identity2._columnCount)) || (InRange(identity2._rowIndex, identity._rowIndex, identity._rowIndex + identity._rowCount) && InRange(identity2._columnIndex, identity._columnIndex, identity._columnIndex + identity._columnCount)));
         }
     }
     else if ((srcId is CalcExternalIdentity) && (destId is CalcExternalIdentity))
     {
         return(this.IsIntersected((srcId as CalcExternalIdentity).ConvertToLocal(), (destId as CalcExternalIdentity).ConvertToLocal()));
     }
     return(false);
 }
Exemplo n.º 10
0
        private object EvaluateReference(CalcReferenceExpression expr, CalcEvaluatorContext context, bool acceptsReference)
        {
            if (object.ReferenceEquals(context, null))
            {
                return(CalcErrors.Value);
            }
            CalcIdentity id = expr.GetId(context.Row, context.Column);

            if (!acceptsReference && !context.ArrayFormulaMode)
            {
                return(context.GetValue(id));
            }
            return(context.GetReference(id));
        }
Exemplo n.º 11
0
 /// <summary>
 /// Gets the reference at specified position which indicated by <paramref name="id" />.
 /// </summary>
 /// <param name="id">A <see cref="T:Dt.CalcEngine.CalcIdentity" /> indicates the identity of a address.</param>
 /// <returns>
 /// An <see cref="T:System.Object" /> indicates the reference.
 /// If the <paramref name="id" /> is not recognized, return <see cref="F:Dt.CalcEngine.CalcErrors.Reference" />.
 /// </returns>
 public virtual object GetReference(CalcIdentity id)
 {
     if (id is CalcExternalIdentity)
     {
         CalcExternalIdentity identity = id as CalcExternalIdentity;
         ICalcSource          source   = identity.Source;
         if (source != null)
         {
             return(source.GetReference(identity.ConvertToLocal()));
         }
     }
     else
     {
         if (id is CalcSheetRangeIdentity)
         {
             IMultiSourceProvider provider = this.Source as IMultiSourceProvider;
             if (provider == null)
             {
                 return(CalcErrors.Reference);
             }
             try
             {
                 CalcSheetRangeIdentity identity2  = id as CalcSheetRangeIdentity;
                 CalcLocalIdentity      identity3  = identity2.ConvertToLocal();
                 List <CalcReference>   references = new List <CalcReference>();
                 foreach (ICalcSource source2 in provider.GetCalcSources(identity2.StartSource, identity2.EndSource))
                 {
                     CalcReference item = source2.GetReference(identity3) as CalcReference;
                     if (item != null)
                     {
                         references.Add(item);
                     }
                 }
                 return(new SheetRangeReference(references));
             }
             catch
             {
                 return(CalcErrors.Reference);
             }
         }
         if ((this.Source != null) && (id is CalcLocalIdentity))
         {
             return(this.Source.GetReference(id as CalcLocalIdentity));
         }
     }
     return(CalcErrors.Reference);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Returns a <see cref="T:System.String" /> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="T:System.String" /> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return(string.Format("'{0}'!{1}", new object[] { (base.Source != null) ? base.Source.GetParserContext(null).GetExternalSourceToken(base.Source) : CalcErrors.Reference.ToString(), CalcIdentity.GetCoord(this.RowIndex, this.ColumnIndex) }));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Dt.CalcEngine.CalcNode" /> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="id">The id.</param>
 public CalcNode(ICalcSource source, CalcIdentity id)
 {
     this.Source = source;
     this.Id     = id;
 }
Exemplo n.º 14
0
        /// <summary>
        /// Determines whether the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </summary>
        /// <param name="other">
        /// The <see cref="T:Dt.CalcEngine.CalcCellIdentity" /> to compare with the
        /// current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </param>
        /// <returns>
        /// <see langword="true" /> if the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />;
        /// otherwise, <see langword="false" />.
        /// </returns>
        protected override bool CompareTo(CalcIdentity other)
        {
            CalcNameIdentity objA = other as CalcNameIdentity;

            return(!object.ReferenceEquals(objA, null) && (this.Name == objA.Name));
        }
Exemplo n.º 15
0
 bool IEqualityComparer <CalcLocalIdentity> .Equals(CalcLocalIdentity x, CalcLocalIdentity y)
 {
     return(CalcIdentity.Compare(x, y));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Returns a <see cref="T:System.String" /> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="T:System.String" /> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return(string.Format("'{0}:{1}'!{2}", new object[] { (this.StartSource != null) ? this.StartSource.GetParserContext(null).GetExternalSourceToken(this.StartSource) : CalcErrors.Reference.ToString(), (this.StartSource != null) ? this.StartSource.GetParserContext(null).GetExternalSourceToken(this.EndSource) : CalcErrors.Reference.ToString(), CalcIdentity.GetCoord(this.RowIndex, this.ColumnIndex, this.RowCount, this.ColumnCount, this.RangeType) }));
 }
Exemplo n.º 17
0
        /// <summary>
        /// Determines whether the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </summary>
        /// <param name="other">
        /// The <see cref="T:Dt.CalcEngine.CalcCellIdentity" /> to compare with the
        /// current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </param>
        /// <returns>
        /// <see langword="true" /> if the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />;
        /// otherwise, <see langword="false" />.
        /// </returns>
        protected override bool CompareTo(CalcIdentity other)
        {
            CalcStructReferenceIndentity objA = other as CalcStructReferenceIndentity;

            return(!object.ReferenceEquals(objA, null) && (this._structReference == objA._structReference));
        }
Exemplo n.º 18
0
 /// <summary>
 /// Returns a <see cref="T:System.String" /> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="T:System.String" /> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return CalcIdentity.GetCoord(this.RowIndex, this.ColumnIndex);
 }
Exemplo n.º 19
0
        /// <summary>
        /// Determines whether the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </summary>
        /// <param name="other">
        /// The <see cref="T:Dt.CalcEngine.CalcCellIdentity" /> to compare with the
        /// current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />.
        /// </param>
        /// <returns>
        /// <see langword="true" /> if the specified <see cref="T:Dt.CalcEngine.CalcCellIdentity" />
        /// is equal to the current <see cref="T:Dt.CalcEngine.CalcCellIdentity" />;
        /// otherwise, <see langword="false" />.
        /// </returns>
        protected override bool CompareTo(CalcIdentity other)
        {
            CalcFunctionIdentity objA = other as CalcFunctionIdentity;

            return(!object.ReferenceEquals(objA, null) && (string.Compare(this.FunctionName, objA.FunctionName, StringComparison.CurrentCultureIgnoreCase) == 0));
        }
Exemplo n.º 20
0
 /// <summary>
 /// Returns a <see cref="T:System.String" /> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="T:System.String" /> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return(CalcIdentity.GetCoord(this.RowIndex, this.ColumnIndex, this.RowCount, this.ColumnCount, this.RangeType));
 }