{
throw new IllegalStateException("Event Order Error: A summary row cannot be printed while a row is still open.");
}
final int gidx = event.getState().getCurrentGroupIndex() + 1;
final CrosstabRowGroup group = (CrosstabRowGroup) event.getReport().getGroup(gidx);
if (group.isPrintSummary() == false)
{
crosstabLayout.startSummaryRowProcessing(false, gidx, null);
return;
}
if (group.getField() == null)
{
crosstabLayout.startSummaryRowProcessing(false, gidx, null);
return;
}
final CrosstabCellBody dataBody = event.getReport().getCrosstabCellBody();
final CrosstabCell element = dataBody.findElement(group.getField(), null);
if (element == null)
{
crosstabLayout.startSummaryRowProcessing(false, gidx, null);
return;
}
if (crosstabLayout.isCrosstabRowOpen() == false)
{
// start a new row if needed ..
layoutModelBuilder.startBox(CrosstabOutputHelper.createTableRow());
crosstabLayout.setCrosstabRowOpen(true);
// flag not empty is needed to connect the new node with the rest of the layout model.
layoutModelBuilder.legacyFlagNotEmpty();
final TableSectionRenderBox rowRenderNode = CrosstabOutputHelper.findTableSection(layoutModelBuilder.dangerousRawAccess());
for (int i = crosstabLayout.getFirstRowGroupIndex(), count = 0; i < gidx; i += 1, count += 1)
{
final InstanceID rowHeader = crosstabLayout.getRowHeader(i - crosstabLayout.getFirstRowGroupIndex());
final RenderNode cell = CrosstabOutputHelper.findNode(rowRenderNode, rowHeader);
if (cell instanceof TableCellRenderBox)
{
final TableCellRenderBox cellBox = (TableCellRenderBox) cell;
cellBox.update(cellBox.getRowSpan() + 1, cellBox.getColSpan());
}
else
{
throw new IllegalStateException("Unable to find previously defined row header. Aborting report processing.");
}
}
}
// An outer row-group's summary cell spans across all inner row-group header-columns up to the start
// of the data area.
final int colSpan = crosstabLayout.getFirstColGroupIndex() - gidx;
CrosstabOutputHelper.createAutomaticCell(layoutModelBuilder, colSpan, 1, group.getSummaryHeader());
crosstabLayout.setRowHeader(gidx - crosstabLayout.getFirstRowGroupIndex(), layoutModelBuilder.dangerousRawAccess().getInstanceId());
outputFunction.getRenderer().add(group.getSummaryHeader(), outputFunction.getRuntime());
layoutModelBuilder.finishBox();
crosstabLayout.startSummaryRowProcessing(true, gidx, group.getField());
crosstabLayout.setDetailsRendered(false);
crosstabLayout.setProcessingCrosstabHeader(false);
}