applyStyleToElement(sr.getStyle(), subreport);
//adding to the band
if (sr.isStartInNewPage()) {
JRDesignGroup jrgroup = getJRGroupFromDJGroup(columnsGroup);
JRDesignBand targetBand = null;
int idx = getDesign().getGroupsList().indexOf(jrgroup);
if (DJConstants.HEADER.equals(position)) {
// if (idx == 0){
// if (getDesign().getColumnHeader() != null)
// targetBand = (JRDesignBand) getDesign().getColumnHeader();
// else if (getDesign().getPageHeader() != null)
// targetBand = (JRDesignBand) getDesign().getPageHeader();
// else
// targetBand = band;
// }
// else
// targetBand = (JRDesignBand) ((JRDesignGroup) getDesign().getGroupsList().get(idx-1)).getGroupHeader();
}
else { //footer subreport (and concatenated report)
if (idx+1 < getDesign().getGroupsList().size())
idx++;
targetBand = (JRDesignBand) ((JRDesignGroup) getDesign().getGroupsList().get(idx)).getGroupFooter();
}
/**
* There is no meaning in adding a page-break in header sub reports since
* they will be placed right after the group header
*/
if (DJConstants.FOOTER.equals(position)){
JRDesignBreak pageBreak = new JRDesignBreak(new JRDesignStyle().getDefaultStyleProvider());
pageBreak.setKey(PAGE_BREAK_FOR_ + jrgroup.toString()); //set up a name to recognize the item later
pageBreak.setY(0);
targetBand.addElement(pageBreak);
}
}
band.addElement(subreport);