/** * private consturctor */ private VerticalArea(Area[] areas, int baseline, Area source) : base(areas, source) { this.baseline = baseline; BoundingBox bbox = content[baseline].BoundingBox; for (int i = 0; i < content.Length; i++) { if (i < baseline) { bbox.Over(content[i].BoundingBox); } else if (i > baseline) { bbox.Under(content[i].BoundingBox); } } this.box = bbox; }
private static void CreateCellSizesAndShifts(MathMLTableCellElement[][] cells, Row[] rows, Column[] columns, ref BoundingBox[][] sizes, ref PointF[][] shifts) { sizes = new BoundingBox[cells.Length][]; shifts = new PointF[cells.Length][]; // init to 1 to skip over first spacing row for frame int rowIndex = 1; // y shift, start with upper frame space float y = rows[0].VerticalExtent; // outer loop - rows for (int i = 0; i < cells.Length; i++) { // init to 1 to skip over first spacing column for frame int colIndex = 1; // start x shift with frame space float x = columns[0].Width; sizes[i] = new BoundingBox[cells[i].Length]; shifts[i] = new PointF[cells[i].Length]; // inner loop - columns for (int j = 0; j < cells[i].Length; j++) { if (cells[i][j] != null) { BoundingBox box = BoundingBox.New(); for (int k = 0, k2 = 0; k < cells[i][j].ColumnSpan; k++, k2 += 2) { if (colIndex + k2 < columns.Length) { if (k2 == 0) { box.Width = columns[colIndex].Width; } else { // add content column box.Append(BoundingBox.New(columns[colIndex + k].Width, 0, 0)); // add space column box.Append(BoundingBox.New(columns[colIndex + k + 1].Width, 0, 0)); } } else { Debug.WriteLine("warning, insuffcient columns for spanning"); } } for (int k = 0, k2 = 0; k < cells[i][j].RowSpan; k++, k2 += 2) { if (rowIndex + k2 < rows.Length) { if (k2 == 0) { box.Height = rows[rowIndex].Height; box.Depth = rows[rowIndex].Depth; } else { // add content row box.Over(BoundingBox.New(0, rows[rowIndex + k2].Height, rows[rowIndex + k].Depth)); // add space row box.Over(BoundingBox.New(0, rows[rowIndex + k2 + 1].Height, rows[rowIndex + k + 1].Depth)); } } } Debug.Assert(box.Height == rows[rowIndex].Height); sizes[i][j] = box; shifts[i][j] = new PointF(x, y + box.Height); } // add width of current column and next column which is a spaceing column // and set index to next non space column x += columns[colIndex++].Width; x += columns[colIndex++].Width; } // add vertical extent of current row and next row which is a spaceing row // and set index to next non space row y += rows[rowIndex++].VerticalExtent; y += rows[rowIndex++].VerticalExtent; } }