/** * Sets the merge type and the <code>RtfCell</code> with which this * <code>RtfCell</code> is to be merged. * * @param mergeType The merge type specifies the kind of merge to be applied * (MERGE_HORIZ_PREV, MERGE_VERT_PREV, MERGE_BOTH_PREV) * @param mergeCell The <code>RtfCell</code> that the cell at x and y is to * be merged with */ public void SetMerge(int mergeType, RtfCell mergeCell) { this.mergeType = mergeType; store = mergeCell.GetStore(); }
/** * Import a <code>Row</code>. * <P> * All the parameters are taken from the <code>RtfTable</code> which contains * this <code>RtfRow</code> and they do exactely what they say * @param row * @param propWidths in percent * @param tableWidth in percent * @param pageWidth * @param cellpadding * @param cellspacing * @param borders * @param borderColor * @param borderWidth * @param y * @return true if importing the row succeeded */ public bool ImportRow(Row row, float[] propWidths, int tableWidth, int pageWidth, int cellpadding, int cellspacing, int borders, Color borderColor, float borderWidth, int y) { // the width of this row is the absolute witdh, calculated from the // proportional with of the table and the total width of the page this.origRow = row; this.width = pageWidth / 100 * tableWidth; this.cellpadding = cellpadding; this.cellspacing = cellspacing; this.borders = borders; this.borderColor = borderColor; this.borderWidth = borderWidth; if (this.borderWidth > 2) { this.borderWidth = 2; } int cellLeft = 0; for (int i = 0; i < row.Columns; i++) { IElement cell = (IElement)row.GetCell(i); // cellWidth is an absolute argument // it's based on the absolute of this row and the proportional // width of this column int cellWidth = (int)(width / 100 * propWidths[i]); if (cell != null) { if (cell.Type == Element.CELL) { RtfCell rtfCell = (RtfCell)cells[i]; cellLeft = rtfCell.ImportCell((Cell)cell, cellLeft, cellWidth, i, y, cellpadding); } } else { RtfCell rtfCell = (RtfCell)cells[i]; cellLeft = rtfCell.ImportCell(null, cellLeft, cellWidth, i, y, cellpadding); } } // recalculate the cell right border and the cumulative width // on col spanning cells. // col + row spanning cells are also handled by this loop, because the real cell of // the upper left corner in such an col, row matrix is copied as first cell // in each row in this matrix int columns = row.Columns; for (int i = 0; i < columns; i++) { RtfCell firstCell = (RtfCell)cells[i]; Cell cell = firstCell.GetStore(); int cols = 0; if (cell != null) { cols = cell.Colspan; } if (cols > 1) { RtfCell lastCell = (RtfCell)cells[i + cols - 1]; firstCell.SetCellRight(lastCell.GetCellRight()); int width = firstCell.GetCellWidth(); for (int j = i + 1; j < i + cols; j++) { RtfCell cCell = (RtfCell)cells[j]; width += cCell.GetCellWidth(); } firstCell.SetCellWidth(width); i += cols - 1; } } return(true); }