/// <summary> /// Calculates width of the table cell. /// </summary> /// <returns>The value of the table cell width.</returns> public float CalcWidth() { TableCell cell = Cell; cell.SetReport(Table.Report); return(cell.CalcWidth()); }
private bool CanBreakRow(int rowIndex, float rowHeight) { if (!Rows[rowIndex].CanBreak) { return(false); } // check each cell in the row for (int i = 0; i < ColumnCount; i++) { TableCell breakable = this[i, rowIndex]; // use clone object because Break method will modify the Text property using (TableCell clone = new TableCell()) { clone.AssignAll(breakable); clone.Height = rowHeight; clone.SetReport(Report); if (!clone.Break(null)) { return(false); } } } return(true); }
/// <summary> /// Calculates height of the table cell. /// </summary> /// <param name="width">The width of the table cell.</param> /// <returns>The value of the table cell height.</returns> public float CalcHeight(float width) { TableCell cell = Cell; cell.SetReport(Table.Report); cell.Width = width; float cellHeight = cell.CalcHeight(); if (objects != null) { // pasted from BandBase.cs // sort objects by Top ReportComponentCollection sortedObjects = objects.SortByTop(); // calc height of each object float[] heights = new float[sortedObjects.Count]; for (int i = 0; i < sortedObjects.Count; i++) { ReportComponentBase obj = sortedObjects[i]; float height = obj.Height; if (obj.CanGrow || obj.CanShrink) { float height1 = obj.CalcHeight(); if ((obj.CanGrow && height1 > height) || (obj.CanShrink && height1 < height)) { height = height1; } } heights[i] = height; } // calc shift amounts float[] shifts = new float[sortedObjects.Count]; for (int i = 0; i < sortedObjects.Count; i++) { ReportComponentBase parent = sortedObjects[i]; float shift = heights[i] - parent.Height; if (shift == 0) { continue; } for (int j = i + 1; j < sortedObjects.Count; j++) { ReportComponentBase child = sortedObjects[j]; if (child.ShiftMode == ShiftMode.Never) { continue; } if (child.Top >= parent.Bottom - 1e-4) { if (child.ShiftMode == ShiftMode.WhenOverlapped && (child.Left > parent.Right - 1e-4 || parent.Left > child.Right - 1e-4)) { continue; } float parentShift = shifts[i]; float childShift = shifts[j]; if (shift > 0) { childShift = Math.Max(shift + parentShift, childShift); } else { childShift = Math.Min(shift + parentShift, childShift); } shifts[j] = childShift; } } } // update location and size of each component, calc max height float maxHeight = 0; for (int i = 0; i < sortedObjects.Count; i++) { ReportComponentBase obj = sortedObjects[i]; obj.Height = heights[i]; obj.Top += shifts[i]; if (obj.Bottom > maxHeight) { maxHeight = obj.Bottom; } } if (cellHeight < maxHeight) { cellHeight = maxHeight; } // perform grow to bottom foreach (ReportComponentBase obj in objects) { if (obj.GrowToBottom) { obj.Height = cellHeight - obj.Top; } } // ----------------------- } return(cellHeight); }