/** * Imports a Row and copies all settings * * @param row The Row to import */ private void ImportRow(Row row) { this.cells = new ArrayList(); this.width = this.document.GetDocumentHeader().GetPageSetting().GetPageWidth() - this.document.GetDocumentHeader().GetPageSetting().GetMarginLeft() - this.document.GetDocumentHeader().GetPageSetting().GetMarginRight(); this.width = (int) (this.width * this.parentTable.GetTableWidthPercent() / 100); int cellRight = 0; int cellWidth = 0; for (int i = 0; i < row.Columns; i++) { cellWidth = (int) (this.width * this.parentTable.GetProportionalWidths()[i] / 100); cellRight = cellRight + cellWidth; Cell cell = (Cell) row.GetCell(i); RtfCell rtfCell = new RtfCell(this.document, this, cell); rtfCell.SetCellRight(cellRight); rtfCell.SetCellWidth(cellWidth); this.cells.Add(rtfCell); } }
/// <summary> /// Gives you the posibility to add columns. /// </summary> /// <param name="aColumns">the number of columns to add</param> public void AddColumns(int aColumns) { ArrayList newRows = new ArrayList(rows.Count); int newColumns = columns + aColumns; Row row; for (int i = 0; i < rows.Count; i++) { row = new Row(newColumns); for (int j = 0; j < columns; j++) { row.SetElement(((Row) rows[i]).GetCell(j) ,j); } for (int j = columns; j < newColumns && i < curPosition.X; j++) { row.SetElement(null, j); } newRows.Add(row); } // applied 1 column-fix; last column needs to have a width of 0 float [] newWidths = new float[newColumns]; Array.Copy(widths, 0, newWidths, 0, columns); for (int j = columns; j < newColumns ; j++) { newWidths[j] = 0; } columns = newColumns; widths = newWidths; rows = newRows; }
/** * Constructs a RtfRow for a Row. * * @param doc The RtfDocument this RtfRow belongs to * @param rtfTable The RtfTable this RtfRow belongs to * @param row The Row this RtfRow is based on * @param rowNumber The number of this row */ protected internal RtfRow(RtfDocument doc, RtfTable rtfTable, Row row, int rowNumber) : base(doc) { this.parentTable = rtfTable; this.rowNumber = rowNumber; ImportRow(row); }
/// <summary> /// Inserts a Cell in a cell-array and reserves cells defined by row-/colspan. /// </summary> /// <param name="someRows">some rows</param> /// <param name="aCell">the cell that has to be inserted</param> /// <param name="aPosition">the position where the cell has to be placed</param> private void PlaceCell(ArrayList someRows, Cell aCell, Point aPosition) { int i; Row row = null; int rowCount = aPosition.X + aCell.Rowspan - someRows.Count; AssumeTableDefaults(aCell); if ( (aPosition.X + aCell.Rowspan) > someRows.Count ) { //create new rows ? for (i = 0; i < rowCount; i++) { row = new Row(columns); someRows.Add(row); } } // reserve cell in rows below for (i = aPosition.X + 1; i < (aPosition.X + aCell.Rowspan); i++) { if ( !((Row) someRows[i]).Reserve(aPosition.Y, aCell.Colspan)) { // should be impossible to come here :-) throw new Exception("addCell - error in reserve"); } } row = (Row) someRows[aPosition.X]; row.AddElement(aCell, aPosition.Y); }