void RunRowHeaders(Report rpt, WorkClass wc, MatrixEntry m, MatrixCellEntry[,] matrix, Rows _Data, ref int iRow, int iColumn, int level) { foreach (MatrixEntry ame in m.GetSortedData(rpt)) { matrix[iRow, iColumn] = RunGetRowHeader(rpt, ame, _Data); matrix[iRow, iColumn].Height = RunRowHeight(iRow); matrix[iRow, iColumn].Width = ame.RowGroup.Width == null? 0: ame.RowGroup.Width.Points; if (ame.GetSortedData(rpt) != null) { RunRowHeaders(rpt, wc, ame, matrix, _Data, ref iRow, iColumn+1, level+1); } else iRow++; } RowGrouping rg = (RowGrouping) (_RowGroupings.Items[level]); // do we need to subtotal this if (rg.DynamicRows != null && rg.DynamicRows.Subtotal != null) { // TODO need to loop thru static?? ReportItem ri = rg.DynamicRows.Subtotal.ReportItems.Items[0]; matrix[iRow, iColumn] = new MatrixCellEntry(_Data, ri); matrix[iRow, iColumn].Width = rg.Width.Points; matrix[iRow, iColumn].Height = RunRowHeight(iRow); RunRowStaticHeaders(rpt, wc, matrix, _Data, iRow, level); iRow += Math.Max(1,this.RowGroupings.StaticCount); } }
void RunDataRow(Report rpt, WorkClass wc, MatrixEntry rm, MatrixEntry cm, MatrixCellEntry[,] matrix, Rows _Data, ref int iRow, int iColumn, int level) { int saveColumn; int headerRows = _ColumnGroupings.Items.Count; // number of column headers we have int rgsCount = this.RowGroupings.StaticCount; // count of static row groups foreach (MatrixEntry ame in rm.GetSortedData(rpt)) { if (ame.RowGroup != LastRg) { RunDataRow(rpt, wc, ame, cm, matrix, _Data, ref iRow, iColumn, level+1); continue; } saveColumn = iColumn; int rowcell = rgsCount == 0? 0: (iRow - headerRows) % rgsCount; RunDataColumn(rpt, wc, ame, cm, matrix, _Data, iRow, ref saveColumn, 0, rowcell); iRow++; } // do we need to subtotal this? RowGrouping rg = (RowGrouping) (_RowGroupings.Items[level]); if (rg.DynamicRows != null && rg.DynamicRows.Subtotal != null) { for (int i=0; i < this.CountMatrixRows; i++) { saveColumn = iColumn; RunDataColumn(rpt, wc, rm, cm, matrix, _Data, iRow, ref saveColumn, 0, i); iRow++; } } }
void RunColumnHeaders(Report rpt, WorkClass wc, MatrixEntry m, MatrixCellEntry[,] matrix, Rows _Data, int iRow, ref int iColumn, int level) { foreach (MatrixEntry ame in m.GetSortedData(rpt)) { matrix[iRow, iColumn] = RunGetColumnHeader(rpt, ame, _Data); matrix[iRow, iColumn].Width = RunGetColumnWidth(matrix[iRow, iColumn]); matrix[iRow, iColumn].Height = ame.ColumnGroup.Height == null? 0: ame.ColumnGroup.Height.Points; if (ame.GetSortedData(rpt) != null) { RunColumnHeaders(rpt, wc, ame, matrix, _Data, iRow+1, ref iColumn, level+1); } else iColumn++; } ColumnGrouping cg = (ColumnGrouping) (_ColumnGroupings.Items[level]); // if we need subtotal on the group if (cg.DynamicColumns != null && cg.DynamicColumns.Subtotal != null) { ReportItem ri = cg.DynamicColumns.Subtotal.ReportItems.Items[0]; matrix[iRow, iColumn] = new MatrixCellEntry(_Data, ri); matrix[iRow, iColumn].Height = cg.Height.Points; matrix[iRow, iColumn].Width = RunGetColumnWidth(matrix[iRow, iColumn]); RunColumnStaticHeaders(rpt, wc, matrix, _Data, iRow, iColumn, level); iColumn += this.CountMatrixCells; } }
void RunDataColumn(Report rpt, WorkClass wc, MatrixEntry rm, MatrixEntry cm, MatrixCellEntry[,] matrix, Rows _Data, int iRow, ref int iColumn, int level, int rowcell) { BitArray andData; MatrixRow mr = this.MatrixRows.Items[rowcell] as MatrixRow; float height = mr.Height == null? 0: mr.Height.Points; foreach (MatrixEntry ame in cm.GetSortedData(rpt)) { if (ame.ColumnGroup != LastCg) { RunDataColumn(rpt, wc, rm, ame, matrix, _Data, iRow, ref iColumn, level+1, rowcell); continue; } andData = new BitArray(ame.Rows); // copy the data andData.And(rm.Rows); // because And is destructive matrix[iRow, iColumn] = RunGetMatrixCell(rpt, ame, iRow, _Data, andData, Math.Max(rm.FirstRow, ame.FirstRow), Math.Min(rm.LastRow, ame.LastRow)); matrix[iRow, iColumn].Height = height; matrix[iRow, iColumn].Width = RunGetColumnWidth(matrix[iRow, iColumn]); matrix[iRow, iColumn].ColumnME = ame; matrix[iRow, iColumn].RowME = rm; iColumn++; } // do we need to subtotal this? ColumnGrouping cg = (ColumnGrouping) (_ColumnGroupings.Items[level]); if (cg.DynamicColumns != null && cg.DynamicColumns.Subtotal != null) { andData = new BitArray(cm.Rows); // copy the data andData.And(rm.Rows); // because And is destructive for (int i=0; i < this.CountMatrixCells; i++) { matrix[iRow, iColumn] = RunGetMatrixCell(rpt, cm, rowcell, i, _Data, andData, Math.Max(rm.FirstRow, cm.FirstRow), Math.Min(rm.LastRow, cm.LastRow)); matrix[iRow, iColumn].Height = height; matrix[iRow, iColumn].Width = RunGetColumnWidth(matrix[iRow, iColumn]); matrix[iRow, iColumn].ColumnME = cm; matrix[iRow, iColumn].RowME = rm; iColumn++; } } }
int RunCountSubtotalRows(Report rpt, WorkClass wc, MatrixEntry m, int level) { // Get the number of static columns int srCount = Math.Max(1, this._RowGroupings.StaticCount); int count = 0; // Increase the row count when subtotal is requested at this level RowGrouping rg = (RowGrouping) (_RowGroupings.Items[level]); if (rg.DynamicRows != null && rg.DynamicRows.Subtotal != null) count = srCount; if (m.GetSortedData(rpt) == null || level+1 >= _RowGroupings.Items.Count) return count; // Now dive into the data foreach (MatrixEntry ame in m.GetSortedData(rpt)) { count += RunCountSubtotalRows(rpt, wc, ame, level+1); } return count; }