internal ChartBase(Report r, Row row, Chart c, MatrixCellEntry[,] m, Expression showTooltips, Expression showTooltipsX, Expression _ToolTipYFormat, Expression _ToolTipXFormat) { _ChartDefn = c; _row = row; _DataDefn = m; _bm = null; int width = _ChartDefn.WidthCalc(r, null); int height = RSize.PixelsFromPoints(_ChartDefn.HeightOrOwnerHeight); Layout = new ChartLayout(width, height); _SeriesBrush = null; _SeriesMarker = null; _showToolTips = showTooltips.EvaluateBoolean(r, row); _showToolTipsX = showTooltipsX.EvaluateBoolean(r, row); _tooltipYFormat = _ToolTipYFormat.EvaluateString(r, row); _tooltipXFormat = _ToolTipXFormat.EvaluateString(r, row); }
Rows GetNestedData(Report rpt, Row row) { if (row == null) { return(null); } ReportLink rl = this.Parent; while (rl != null) { if (rl is TableGroup || rl is List || rl is MatrixCell) { break; } rl = rl.Parent; } if (rl == null) { return(null); // should have been caught as an error } Grouping g = null; if (rl is TableGroup) { TableGroup tg = rl as TableGroup; g = tg.Grouping; } else if (rl is List) { List l = rl as List; g = l.Grouping; } else if (rl is MatrixCell) { MatrixCellEntry mce = this.GetMC(rpt); return(new Rows(rpt, mce.Data)); } if (g == null) { return(null); } GroupEntry ge = row.R.CurrentGroups[g.GetIndex(rpt)]; return(new Rows(rpt, row.R, ge.StartRow, ge.EndRow, null)); }
MatrixCellEntry RunGetRowHeader(Report rpt, MatrixEntry me, Rows _Data) { ReportItem ri; if (me.RowGroup.StaticRows != null) { // Handle static row reference StaticRow sr = me.RowGroup.StaticRows.Items[me.StaticRow] as StaticRow; ri = sr.ReportItems.Items[0]; } else // handle dynamic row reference ri = me.RowGroup.DynamicRows.ReportItems.Items[0]; Rows subData = new Rows(rpt, _Data, me.FirstRow, me.LastRow, me.Rows); MatrixCellEntry mce = new MatrixCellEntry(subData, ri); return mce; }
// called first public bool MatrixStart(Matrix m, MatrixCellEntry[,] matrix, Row r, int headerRows, int maxRows, int maxCols) { return true; }
internal MatrixCellEntry MC; // matrix cell entry #endregion Fields #region Constructors internal WorkClass() { MC=null; BottomPosition=float.NaN; CurrentPage=null; }
// called first public bool MatrixStart(Matrix m, MatrixCellEntry[,] matrix, Row r, int headerRows, int maxRows, int maxCols) { _Excel.AddSheet(m.Name.Nm); _ExcelRow = -1; // set the widths of the columns float[] widths = m.ColumnWidths(matrix, maxCols); for (int i = 0; i < maxCols; i++) { _Excel.SetColumnWidth(i, widths[i]); } return true; }
// called first public bool MatrixStart(Matrix m, MatrixCellEntry[,] matrix, Row r, int headerRows, int maxRows, int maxCols) { if (m.DataElementOutput != DataElementOutputEnum.Output) return false; tw.WriteLine("<" + (m.DataElementName == null? "Matrix": m.DataElementName) + ">"); return true; }
internal Page CurrentPage; // the page this reportitem was last put on; internal WorkClass() { MC = null; BottomPosition = float.NaN; CurrentPage = null; }
internal float[] ColumnWidths(MatrixCellEntry[,] matrix, int maxColumns) { float[] widths= new float[maxColumns]; for (int iColumn = 0; iColumn < maxColumns; iColumn++) { widths[iColumn] = WidthOfColumn(matrix, iColumn); } return widths; }
float WidthOfColumn(MatrixCellEntry[,] matrix, int iCol) { int maxRows = matrix.GetLength(0); for (int iRow=0; iRow < maxRows; iRow++) { if (matrix[iRow, iCol] != null && matrix[iRow, iCol].ColSpan == 1) return matrix[iRow, iCol].Width; } return 0; }
private void SetGroupingValues(Report rpt, MatrixCellEntry mce) { WorkClass wc = GetValue(rpt); Rows data = wc.FullData; SetGroupingValuesInit(rpt, data, mce.RowME, mce.ColumnME); SetGroupingValuesMe(rpt, data, mce.RowME); SetGroupingValuesMe(rpt, data, mce.ColumnME); return; }
void RunRowStaticHeaders(Report rpt, WorkClass wc, MatrixCellEntry[,] matrix, Rows _Data, int iRow, int level) { RowGrouping rg=null; int i; int iColumn=0; for (i=level+1; i < _RowGroupings.Items.Count; i++) { iColumn++; // Column for the row static headers rg = (RowGrouping) (_RowGroupings.Items[i]); if (rg.StaticRows != null) break; } if (rg == null || rg.StaticRows == null) return; i=0; foreach (StaticRow sr in rg.StaticRows.Items) { ReportItem ri = sr.ReportItems.Items[0]; matrix[iRow, iColumn] = new MatrixCellEntry(_Data, ri); matrix[iRow, iColumn].Width = rg.Width.Points; MatrixRow mr = this.MatrixRows.Items[i++] as MatrixRow; float height = mr.Height == null? 0: mr.Height.Points; matrix[iRow, iColumn].Height = height; iRow++; } return; }
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 RunPageColumns(Pages pgs, WorkClass wc, MatrixCellEntry[,] matrix, int iRow, int maxColumns) { Report rpt = pgs.Report; float xpos = GetOffsetCalc(pgs.Report) + LeftCalc(rpt); for (int iColumn = 0; iColumn < maxColumns; iColumn++) { MatrixCellEntry mce = matrix[iRow, iColumn]; if (mce == null) { // have a null column but we need to fill column space xpos += WidthOfColumn(matrix, iColumn); continue; } wc.Data = mce.Data; // Must set this for evaluation Row lrow = wc.Data.Data.Count > 0? wc.Data.Data[0]:null; SetGroupingValues(rpt, mce); mce.DisplayItem.SetMC(rpt, mce); // set for use by the display item mce.XPosition = xpos; mce.DisplayItem.RunPage(pgs, lrow); xpos += mce.Width; iColumn += (mce.ColSpan-1); // skip columns already accounted for } }
MatrixCellEntry RunGetColumnHeader(Report rpt, MatrixEntry me, Rows _Data) { ReportItem ri; if (me.ColumnGroup.StaticColumns != null) { // Handle static column reference StaticColumn sc = me.ColumnGroup.StaticColumns.Items[me.StaticColumn] as StaticColumn; ri = sc.ReportItems.Items[0]; } else ri = me.ColumnGroup.DynamicColumns.ReportItems.Items[0]; // dynamic column Rows subData = new Rows(rpt, _Data, me.FirstRow, me.LastRow, me.Rows); MatrixCellEntry mce = new MatrixCellEntry(subData, ri); return mce; }
float RunGetColumnWidth(MatrixCellEntry mce) { if (this.MatrixColumns == null) return 0; // We use this routine for chart(s) and they don't build the matrix columns MatrixColumn mcol; // work variable to hold a MatrixColumn mcol = this.MatrixColumns.Items[0] as MatrixColumn; float defWidth = mcol.Width.Points; if (CountMatrixColumns == 1) // if only one column width is easy return defWidth; // find out which static column it is. ColumnGrouping cg=null; MatrixCells mcells=null; ReportItem ri = mce.DisplayItem; for (ReportLink rl= ri.Parent; rl != null; rl = rl.Parent) { if (rl is ColumnGrouping) { cg = rl as ColumnGrouping; break; } if (rl is MatrixCells) { mcells = rl as MatrixCells; break; } if (rl is Matrix) break; } int offset = 0; // If the item is one of the MatrixCell; then use same offset if (mcells != null) { foreach (MatrixCell mcell in mcells.Items) { ReportItem ric = mcell.ReportItems.Items[0] as ReportItem; if (ric == ri) { mcol = this.MatrixColumns.Items[offset] as MatrixColumn; return mcol.Width.Points; } offset++; } return defWidth; } if (cg == null || cg.StaticColumns == null) return defWidth; // Otherwise find the same relative Matrix Column from the static columns mcol=null; foreach (StaticColumn sc in cg.StaticColumns.Items) { ReportItem cri = sc.ReportItems.Items[0] as ReportItem; if (ri == cri) { mcol = this.MatrixColumns.Items[offset] as MatrixColumn; break; } offset++; } return mcol == null? defWidth: mcol.Width.Points; }
// RunBuild is used by both Matrix.Run and Chart.Run to obtain the necessary data // used by their respective rendering interfaces internal MatrixCellEntry[,] RunBuild(Report rpt, out int numRows, out int numCols) { WorkClass wc = GetValue(rpt); Rows _Data = wc.Data; // loop thru all the data; // form bitmap arrays for each unique data value of each grouping (row and column) value int maxColumns = _RowGroupings.Items.Count; // maximum # of columns in matrix // at top we need a row per column grouping int maxRows = _ColumnGroupings.Items.Count; // maximum # of rows in matrix // at left we need a column per row grouping MatrixEntry mcg = new MatrixEntry(null, "", null, _Data.Data.Count); _ColumnGroupings.SetME(rpt, mcg); mcg.FirstRow=0; mcg.LastRow=_Data.Data.Count-1; mcg.Rows = new BitArray(_Data.Data.Count, true); // all data MatrixEntry mrg = new MatrixEntry(null, "", null, _Data.Data.Count); _RowGroupings.SetME(rpt, mrg); mrg.FirstRow=0; mrg.LastRow=_Data.Data.Count-1; mrg.Rows = new BitArray(_Data.Data.Count, true); // all data int iRow=0; // row counter foreach (Row r in _Data.Data) { // Handle the column values HandleColumnGrouping(rpt, wc, _Data, r, mcg, 0, iRow, ref maxColumns); // Handle the row values HandleRowGrouping(rpt, wc, _Data, r, mrg, 0, iRow, ref maxRows); iRow++; } // Determine how many subtotal columns are needed maxColumns += RunCountSubtotalColumns(rpt, wc, mcg, 0); // Determine how many subtotal rows are needed maxRows += RunCountSubtotalRows(rpt, wc, mrg, 0); ///// // Build and populate the 2 dimensional table of MatrixCellEntry // that constitute the matrix ///// MatrixCellEntry[,] matrix = new MatrixCellEntry[maxRows, maxColumns]; // Do the column headings int iColumn = _RowGroupings.Items.Count; RunColumnHeaders(rpt, wc, mcg, matrix, _Data, 0, ref iColumn, 0); // Do the row headings iRow = _ColumnGroupings.Items.Count; RunRowHeaders(rpt, wc, mrg, matrix, _Data, ref iRow, 0, 0); // Do the row/column data iRow = _ColumnGroupings.Items.Count; RunDataRow(rpt, wc, mrg, mcg, matrix, _Data, ref iRow, _RowGroupings.Items.Count, 0); // Do the corner matrix[0, 0] = RunCorner(_Data); // now return the matrix data numRows = maxRows; numCols = maxColumns; return matrix; }
internal void SetMC(Report rpt, MatrixCellEntry mce) { WorkClass wc = GetWC(rpt); wc.MC = mce; }
float HeightOfRow(Pages pgs, MatrixCellEntry[,] matrix, int iRow) { Report rpt = pgs.Report; WorkClass wc = GetValue(rpt); int maxColumns = matrix.GetLength(1); float height=0; bool bResetAllHeights=false; // Handle the corner; it might span rows & columns bool bCorner = false; float cornerHeight=0; if (iRow == 0 && matrix[0, 0] != null && (this.ColumnGroupings.Items.Count > 1 || this.RowGroupings.Items.Count > 1)) { bCorner = true; } for (int iCol=0; iCol < maxColumns; iCol++) { MatrixCellEntry mce = matrix[iRow, iCol]; if (mce == null) continue; if (mce.DisplayItem is Textbox) { Textbox tb = mce.DisplayItem as Textbox; if (tb.CanGrow) { wc.Data = mce.Data; // Must set this for evaluation Row lrow = wc.Data.Data.Count > 0? wc.Data.Data[0]:null; mce.DisplayItem.SetMC(rpt, mce); // set for use by the display item SetGroupingValues(rpt, mce); float tbh = tb.RunTextCalcHeight(rpt, pgs.G, lrow); if (height < tbh) { if (bCorner && iCol == 0) { cornerHeight = tbh; } else { bResetAllHeights = true; height = tbh; } } } } if (bCorner && iCol == 0) continue; if (height < mce.Height) height = mce.Height; } if (bResetAllHeights) // If any text forces the row to grow; all heights must be fixed { for (int iCol=0; iCol < maxColumns; iCol++) { if (bCorner && iCol == 0) continue; MatrixCellEntry mce = matrix[iRow, iCol]; if (mce != null) mce.Height = height; } } // Even with expansion room; we might need more space for the corner if (bCorner && cornerHeight > matrix[0,0].Height) { // add the additional space needed to the first row's height float newRow0Height; if (ColumnGroupings.Items.Count == 1) newRow0Height = cornerHeight; else if (matrix[0,1] != null) newRow0Height = matrix[0,1].Height + (cornerHeight - matrix[0,0].Height); else newRow0Height = (cornerHeight - matrix[0,0].Height); height = newRow0Height; matrix[0,0].Height = cornerHeight; for (int iCol=1; iCol < maxColumns; iCol++) { MatrixCellEntry mce = matrix[0, iCol]; if (mce != null) mce.Height = newRow0Height; } } return height; }
// called first public bool MatrixStart(Matrix m, MatrixCellEntry[,] matrix, Row r, int headerRows, int maxRows, int maxCols) { _MatrixCellSpan = 0; _MatrixCols = maxCols; _MatrixRows = maxRows; _MatrixHeaderRows = headerRows; _MatrixData = matrix; float[] widths = m.ColumnWidths(this._MatrixData, maxCols); _MatrixColumnWidths = new int[maxCols]; for (int i = 0; i < maxCols; i++) _MatrixColumnWidths[i] = RSize.TwipsFromPoints(widths[i]); tw.Write(@"\par{"); return true; }
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; } }
// called first public bool MatrixStart(Matrix m, MatrixCellEntry[,] matrix, Row r, int headerRows, int maxRows, int maxCols) { string bookmark = m.BookmarkValue(this.r, r); if (bookmark != null) tw.WriteLine("<div id=\"{0}\">", bookmark); // can't use the table id since we're using for css style // output some of the table styles string cssName = CssAdd(m.Style, m, r); // get the style name for this item tw.WriteLine("<table id='{0}'>", cssName); return true; }
void RunColumnStaticHeaders(Report rpt, WorkClass wc, MatrixCellEntry[,] matrix, Rows _Data, int iRow, int iColumn, int level) { ColumnGrouping cg=null; for (int i=level+1; i < _ColumnGroupings.Items.Count; i++) { iRow++; // the row will below the headers cg = (ColumnGrouping) (_ColumnGroupings.Items[i]); if (cg.StaticColumns != null) break; } if (cg == null || cg.StaticColumns == null) return; foreach (StaticColumn sc in cg.StaticColumns.Items) { ReportItem ri = sc.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]); iColumn++; } return; }
internal void SetMC(Report rpt, MatrixCellEntry mce) { WorkClass wc = GetWC(rpt); wc.MC = mce; }
MatrixCellEntry RunCorner(Rows d) { if (_Corner == null) return null; ReportItem ri = _Corner.ReportItems.Items[0]; MatrixCellEntry mce = new MatrixCellEntry(d, ri); float height=0; foreach (ColumnGrouping cg in this.ColumnGroupings.Items) { height += cg.Height.Points; } mce.Height = height; float width=0; foreach (RowGrouping rg in this.RowGroupings.Items) { width += rg.Width.Points; } mce.Width = width; mce.ColSpan = RowGroupings.Items.Count; return mce; }
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++; } } }
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++; } } }
internal ChartPie(Report r, Row row, Chart c, MatrixCellEntry[,] m, Expression showTooltips, Expression showTooltipsX,Expression _ToolTipYFormat, Expression _ToolTipXFormat) : base(r, row, c, m, showTooltips, showTooltipsX, _ToolTipYFormat, _ToolTipXFormat) { }
MatrixCellEntry RunGetMatrixCell(Report rpt, MatrixEntry me, int rcell, int ccell, Rows _Data, BitArray rows, int firstRow, int lastRow) { MatrixRow mr = this._MatrixRows.Items[rcell]; MatrixCell mc = mr.MatrixCells.Items[ccell]; ReportItem ri = mc.ReportItems.Items[0]; Rows subData = new Rows(rpt, _Data, firstRow, lastRow, rows); MatrixCellEntry mce = new MatrixCellEntry(subData, ri); return mce; }