public static LayoutController skipInvisibleElement(final LayoutController layoutController)
throws ReportProcessingException, ReportDataFactoryException, DataSourceException
{
final FlowController fc = layoutController.getFlowController();
final ReportTarget target = new EmptyReportTarget(fc.getReportJob(), fc.getExportDescriptor());
final LayoutController rootParent = layoutController.getParent();
// Now start to iterate until the derived layout controller 'lc' that has this given parent
// wants to join.
LayoutController lc = layoutController;
while (lc.isAdvanceable())
{
lc = lc.advance(target);
while (lc.isAdvanceable() == false && lc.getParent() != null)
{
final LayoutController parent = lc.getParent();
lc = parent.join(lc.getFlowController());
if (parent == rootParent)
{
target.commit();
return lc;
}
}
}
target.commit();
throw new IllegalStateException
("Ups - we did not get to the root parent again. This is awful and we cannot continue.");
// return lc;
}