A Row is part of a Table and contains some Cells.
All Rows are constructed by a Table-object. You don't have to construct any Row yourself. In fact you can't construct a Row outside the package.

Since a Cell can span several rows and/or columns a row can contain reserved space without any content.

Inheritance: IElement
Exemplo n.º 1
0
 /**
 * 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);
     }
 }
Exemplo n.º 2
0
 /**
 * 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);
 }
Exemplo n.º 3
0
        /// <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, System.Drawing.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);

        }
Exemplo n.º 4
0
        /// <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];
            System.Array.Copy(widths, 0, newWidths, 0, columns);
            for (int j = columns; j < newColumns ; j++) {
                newWidths[j] = 0;
            }
            columns = newColumns;
            widths = newWidths;
            rows = newRows;
        }
Exemplo n.º 5
0
        /**
        * 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 * tableWidth / 100;
            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 * propWidths[i] / 100);
                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;
        }