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; } }
/// <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); }