* @throws ReportProcessingException
*/
public final void startElement(final AttributeMap roAttrs)
throws DataSourceException, ReportProcessingException
{
final AttributeMap attrs = new LazyAttributeMap(roAttrs);
// todo
if (DEBUG_ELEMENTS)
{
LOGGER.debug("Starting " + getCurrentState() + '/' + states.size() + ' ' +
ReportTargetUtil.getNamespaceFromAttribute(attrs) + " -> " +
ReportTargetUtil.getElemenTypeFromAttribute(attrs));
}
try
{
switch (getCurrentState())
{
case OfficeDocumentReportTarget.STATE_IN_DOCUMENT:
{
if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OFFICE_NS, "body", attrs))
{
states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_BODY));
startBody(attrs);
}
else
{
states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_OTHER));
if (!isFilteredNamespace(ReportTargetUtil.getNamespaceFromAttribute(attrs)))
{
startOther(attrs);
}
}
break;
}
case OfficeDocumentReportTarget.STATE_IN_BODY:
{
if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OFFICE_NS, "report", attrs))
{
states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_CONTENT));
startContent(attrs);
}
else
{
throw new IllegalStateException("The 'office:body' element must have exactly one child of type 'report'");
}
break;
}
case OfficeDocumentReportTarget.STATE_IN_CONTENT:
{
// Either a ordinary section or a group ..
// A group.
if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, "report-body", attrs))
{
states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_GROUP_BODY));
startGroupBody(attrs);
}
else
{
// Either a template-section, page-header, page-footer, report-header, report-footer
// or variables-section
states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_SECTION));
if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, "template", attrs))
{
currentRole = OfficeDocumentReportTarget.ROLE_TEMPLATE;
}
else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "page-header", attrs))
{
if ("spreadsheet-section".equals(attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, "role")))
{
currentRole = OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_HEADER;
}
else
{
currentRole = OfficeDocumentReportTarget.ROLE_PAGE_HEADER;
}
}
else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "page-footer", attrs))
{
if ("spreadsheet-section".equals(attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, "role")))
{
currentRole = OfficeDocumentReportTarget.ROLE_SPREADSHEET_PAGE_FOOTER;
}
else
{
currentRole = OfficeDocumentReportTarget.ROLE_PAGE_FOOTER;
}
}
else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "report-header", attrs))
{
currentRole = OfficeDocumentReportTarget.ROLE_REPORT_HEADER;
}
else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "report-footer", attrs))
{
currentRole = OfficeDocumentReportTarget.ROLE_REPORT_FOOTER;
}
else if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, "variables-section", attrs))
{
currentRole = OfficeDocumentReportTarget.ROLE_VARIABLES;
}
else
{
throw new IllegalStateException("Expected either 'template', 'report-body', " +
"'report-header', 'report-footer', 'variables-section', 'page-header' or 'page-footer'");
}
startReportSection(attrs, currentRole);
}
break;
}
case OfficeDocumentReportTarget.STATE_IN_GROUP_BODY:
{
// We now expect either an other group or a detail band.
if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "group", attrs))
{
states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_GROUP));
groupContext = new GroupContext(groupContext);
startGroup(attrs);
}
else
{
// Either a variables-section, or a detail-band
states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_SECTION));
if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "detail", attrs))
{
currentRole = OfficeDocumentReportTarget.ROLE_DETAIL;
}
else if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, "variables-section", attrs))
{
currentRole = OfficeDocumentReportTarget.ROLE_VARIABLES;
}
else
{
throw new IllegalStateException("Expected either 'group', 'detail' or 'variables-section'");
}
startReportSection(attrs, currentRole);
}
break;
}
case OfficeDocumentReportTarget.STATE_IN_GROUP:
{
// A group can carry a repeating group header/footer or a group-instance section.
if (ReportTargetUtil.isElementOfType(JFreeReportInfo.REPORT_NAMESPACE, "group-instance", attrs))
{
states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_GROUP_INSTANCE));
startGroupInstance(attrs);
}
else
{
// repeating group header/footer, but *no* variables section
states.push(IntegerCache.getInteger(OfficeDocumentReportTarget.STATE_IN_SECTION));
if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "group-header", attrs) &&
OfficeToken.TRUE.equals(attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, "repeated-section")))
{
currentRole = OfficeDocumentReportTarget.ROLE_REPEATING_GROUP_HEADER;
}
else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.OOREPORT_NS, "group-footer", attrs) &&
OfficeToken.TRUE.equals(attrs.getAttribute(JFreeReportInfo.REPORT_NAMESPACE, "repeated-section")))
{
currentRole = OfficeDocumentReportTarget.ROLE_REPEATING_GROUP_FOOTER;
}
else
{