if (foNode instanceof PageSequence) {
PageSequence pageSequence = (PageSequence) foNode;
Region regionBefore = pagemaster.getRegion(Constants.FO_REGION_BEFORE);
if (regionBefore != null) {
FONode staticBefore = (FONode) pageSequence.getFlowMap().get(
regionBefore.getRegionName());
if (staticBefore != null) {
recurseFONode(staticBefore);
}
}
Region regionAfter = pagemaster.getRegion(Constants.FO_REGION_AFTER);
if (regionAfter != null) {
FONode staticAfter = (FONode) pageSequence.getFlowMap().get(
regionAfter.getRegionName());
if (staticAfter != null) {
recurseFONode(staticAfter);
}
}
recurseFONode( pageSequence.getMainFlow() );
} else if (foNode instanceof Table) {
Table table = (Table) foNode;
//recurse all table-columns
if (table.getColumns() != null) {
for (Iterator it = table.getColumns().iterator(); it.hasNext();) {
recurseFONode( (FONode) it.next() );
}
} else {
//TODO Implement implicit column setup handling!
log.warn("No table-columns found on table. RTF output requires that all"
+ " table-columns for a table are defined. Output will be incorrect.");
}
//recurse table-header
if (table.getTableHeader() != null) {
recurseFONode( table.getTableHeader() );
}
//recurse table-footer
if (table.getTableFooter() != null) {
recurseFONode( table.getTableFooter() );
}
if (foNode.getChildNodes() != null) {
for (Iterator it = foNode.getChildNodes(); it.hasNext();) {
recurseFONode( (FONode) it.next() );
}
}
} else if (foNode instanceof ListItem) {
ListItem item = (ListItem) foNode;
recurseFONode(item.getLabel());
recurseFONode(item.getBody());
} else if (foNode instanceof Footnote) {
Footnote fn = (Footnote)foNode;
recurseFONode(fn.getFootnoteCitation());
recurseFONode(fn.getFootnoteBody());
} else {
//Any other FO-Object: Simply recurse through all childNodes.
if (foNode.getChildNodes() != null) {
for (Iterator it = foNode.getChildNodes(); it.hasNext();) {
FONode fn = (FONode)it.next();
if (log.isTraceEnabled()) {
log.trace(" ChildNode for " + fn + " (" + fn.getName() + ")");
}
recurseFONode(fn);
}
}
}