public int increaseCellPosition(final int colSpan, final int rowSpan) {
      // find insert-position for the cell. This skips cells that block the location via a row-span.
      while (true) {
        // we are past the point of defined cells. Adding new cells is guaranteed to not have
        // row-spans.
        if (tableCellPosition >= rowSpans.size()) {
          break;
        }

        if (isCellAreaClear(tableCellPosition, colSpan)) {
          break;
        }

        tableCellPosition += 1;
      }

      final int retval = tableCellPosition;
      // set the cell...
      for (int i = tableCellPosition; i < tableCellPosition + colSpan; i++) {
        if (i < rowSpans.size()) {
          rowSpans.set(i, Math.max(rowSpan, rowSpans.get(i)));
        } else {
          rowSpans.add(rowSpan);
        }
      }

      tableCellPosition += colSpan;
      return retval;
    }
 private boolean isCellAreaClear(final int pos, final int colSpan) {
   final int maxIdx = Math.min(pos + colSpan, rowSpans.size());
   for (int i = pos; i < maxIdx; i++) {
     if (rowSpans.get(tableCellPosition) > 0) {
       return false;
     }
   }
   return true;
 }
  protected void finishTableSectionBox(final TableSectionRenderBox box) {
    if (currentTable == null) {
      return;
    }
    if (currentTable.getSectionRenderBox() != box) {
      return;
    }

    final IntList rowSpans = currentTable.rowSpans;
    int missingRows = 0;
    for (int i = 0; i < rowSpans.size(); i++) {
      final int value = rowSpans.get(i);
      if (missingRows < value) {
        missingRows = value;
      }
    }

    for (int i = 0; i < missingRows; i += 1) {
      currentTable.rowModel.addRow();
    }

    box.getRowModel().validateSizes(box);
    currentTable.setSectionRenderBox(null);
  }
  protected void finishTableRowBox(final TableRowRenderBox box) {
    if (currentTable == null) {
      return;
    }
    if (currentTable.getSectionRenderBox() == null) {
      return;
    }

    final IntList rowSpans = currentTable.rowSpans;
    int maxRowSpan = 0;
    for (int i = 0; i < rowSpans.size(); i++) {
      final int value = rowSpans.get(i);
      maxRowSpan = Math.max(maxRowSpan, value);
    }

    for (int i = 0; i < rowSpans.size(); i++) {
      final int value = rowSpans.get(i);
      rowSpans.set(i, Math.max(0, value - 1));
    }
  }