using System; using System.Collections.Generic; using FastReport.Table; namespace FastReport.AdvMatrix { internal enum CellContentType { MixedText, SingleExpression, Aggregate } internal class CellDescriptor { public TableCell TemplateCell { get; private set; } public List Expressions { get; private set; } public AggregateExpressionPairList Aggregates { get; private set; } public List SpecialFunctions { get; private set; } public string Text { get; set; } public int ColumnIndex { get; set; } public int RowIndex { get; set; } public CellContentType ContentType { get; private set; } public bool HasRowTotal { get; private set; } public bool HasColumnTotal { get; private set; } public bool HasGrandTotal { get; private set; } public CellDescriptor(AdvMatrixObject matrix, TableCell templateCell) { TemplateCell = templateCell; Expressions = new List(); Aggregates = new AggregateExpressionPairList(matrix); SpecialFunctions = new List(); Text = ""; templateCell.SetDescriptor(this); } public void ClearData() { foreach (AggregateExpressionPair ae in Aggregates) { ae.ClearData(); } } public void GetExpressions(List expressions) { expressions.AddRange(Expressions); foreach (AggregateExpressionPair ae in Aggregates) { expressions.Add(ae.Expression); } } public void UpdateContentType() { foreach (string ident in SpecialFunctions) { if (ident.Contains("ColumnTotal")) HasColumnTotal = true; if (ident.Contains("RowTotal")) HasRowTotal = true; if (ident.Contains("GrandTotal")) HasGrandTotal = true; } if (Expressions.Count == 1) { if (Aggregates.Count == 1 && Expressions[0] == Aggregates[0].ToAggregateCall()) { ContentType = CellContentType.Aggregate; } else { ContentType = CellContentType.SingleExpression; Text = Expressions[0]; } } } } }