{
final MasterReport report = (MasterReport)
getRootHandler().getHelperObject(ReportParserUtil.HELPER_OBJ_REPORT_NAME);
// grab the default page definition ...
PageFormat format = report.getPageDefinition().getPageFormat(0);
float defTopMargin = (float) format.getImageableY();
float defBottomMargin = (float) (format.getHeight() - format.getImageableHeight()
- format.getImageableY());
float defLeftMargin = (float) format.getImageableX();
float defRightMargin = (float) (format.getWidth() - format.getImageableWidth()
- format.getImageableX());
format = createPageFormat(format, atts);
defTopMargin = ParserUtil.parseFloat(atts.getValue(getUri(), PageReadHandler.TOPMARGIN_ATT), defTopMargin);
defBottomMargin = ParserUtil.parseFloat(atts.getValue(getUri(), PageReadHandler.BOTTOMMARGIN_ATT), defBottomMargin);
defLeftMargin = ParserUtil.parseFloat(atts.getValue(getUri(), PageReadHandler.LEFTMARGIN_ATT), defLeftMargin);
defRightMargin = ParserUtil.parseFloat(atts.getValue(getUri(), PageReadHandler.RIGHTMARGIN_ATT), defRightMargin);
final Paper p = format.getPaper();
switch (format.getOrientation())
{
case PageFormat.PORTRAIT:
PageFormatFactory.getInstance().setBorders(p, defTopMargin, defLeftMargin,
defBottomMargin, defRightMargin);
break;
case PageFormat.LANDSCAPE:
// right, top, left, bottom
PageFormatFactory.getInstance().setBorders(p, defRightMargin, defTopMargin,
defLeftMargin, defBottomMargin);
break;
case PageFormat.REVERSE_LANDSCAPE:
PageFormatFactory.getInstance().setBorders(p, defLeftMargin, defBottomMargin,
defRightMargin, defTopMargin);
break;
default:
// will not happen..
throw new IllegalArgumentException("Unexpected paper orientation.");
}
format.setPaper(p);
pageFormat = format;
}