for (int row = startRow; row < finishRow; row++)
{
for (short col = 0; col < columnCount; col++)
{
final RenderBox content = contentProducer.getContent(row, col);
final int sectionType = contentProducer.getSectionType(row, col);
if (content == null)
{
final CellBackground background = cellBackgroundProducer.getBackgroundAt
(logicalPage, sheetLayout, col, row, false, sectionType);
if (background == null)
{
// An empty cell .. ignore
final RtfCell cell = new RtfCell();
cell.setBorderWidth(0);
table.addCell(cell, row, col);
continue;
}
// A empty cell with a defined background ..
final RtfCell cell = new RtfCell();
cell.setBorderWidth(0);
updateCellStyle(cell, background);
table.addCell(cell, row, col);
continue;
}
if (content.isCommited() == false)
{
throw new InvalidReportStateException("Uncommited content encountered");
}
final long contentOffset = contentProducer.getContentOffset(row, col);
final long colPos = sheetLayout.getXPosition(col);
final long rowPos = sheetLayout.getYPosition(row);
if (content.getX() != colPos || (content.getY() + contentOffset) != rowPos)
{
// A spanned cell ..
continue;
}
final int colSpan = sheetLayout.getColSpan(col, content.getX() + content.getWidth());
final int rowSpan = sheetLayout.getRowSpan(row, content.getY() + content.getHeight() + contentOffset);
final CellBackground realBackground = cellBackgroundProducer.getBackgroundAt
(logicalPage, sheetLayout, col, row, colSpan, rowSpan, false, sectionType);
final Cell cell = new Cell();
cell.setRowspan(rowSpan);
cell.setColspan(colSpan);
cell.setBorderWidth(0);
// Sadly RTF-Cell does not provide a setter for the row-span. Therefore we have to "import" a plain cell
// for that. The design of the iText RTF writer seems to be seriously flawed here ..
if (realBackground != null)
{
updateCellStyle(cell, realBackground);
}
computeCellStyle(content, cell);
// export the cell and all content ..
final RTFTextExtractor etx = new RTFTextExtractor(metaData);
etx.compute(content, cell, imageCache);
table.addCell(cell, row, col);
content.setFinished(true);
//logger.debug("set Finished to cell (" + col + ", " + row + "," + content.getName() + ")");
}
}