/** * 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.getColumns(); 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); } }
/** * Imports the rows and settings from the Table into this * RtfTable. * * @param table The source Table */ private void importTable(Table table) { this.rows = new ArrayList(); this.tableWidthPercent = table.getWidth(); this.proportionalWidths = table.getProportionalWidths(); this.cellPadding = (float) (table.getPadding() * TWIPS_FACTOR); this.cellSpacing = (float) (table.getSpacing() * TWIPS_FACTOR); this.borders = new RtfBorderGroup(this.document, RtfBorder.ROW_BORDER, table.getBorder(), table.getBorderWidth(), table.getBorderColor()); this.alignment = table.getAlignment(); int i = 0; Iterator rowIterator = table.iterator(); while(rowIterator.hasNext()) { this.rows.add(new RtfRow(this.document, this, (Row) rowIterator.next(), i)); i++; } for(i = 0; i < this.rows.size(); i++) { ((RtfRow) this.rows.get(i)).handleCellSpanning(); ((RtfRow) this.rows.get(i)).cleanRow(); } this.headerRows = table.getLastHeaderRow(); this.cellsFitToPage = table.isCellsFitPage(); this.tableFitToPage = table.isTableFitsPage(); if(!Float.isNaN(table.getOffset())) { this.offset = (int) (table.getOffset() * 2); } }
/** * 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 RtfRow(RtfDocument doc, RtfTable rtfTable, Row row, int rowNumber) { super(doc); this.parentTable = rtfTable; this.rowNumber = rowNumber; importRow(row); }