// FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.datatypes.LengthBase;
+import org.apache.fop.datatypes.PercentBaseContext;
+import org.apache.fop.datatypes.SimplePercentBaseContext;
import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.TableRow;
import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.pagination.Region;
import org.apache.fop.fo.pagination.SimplePageMaster;
import org.apache.fop.fo.pagination.StaticContent;
import org.apache.fop.fo.Constants;
//in current page-sequence
private BuilderContext builderContext = new BuilderContext(null);
+ private SimplePageMaster pagemaster;
/**
* Creates a new RTF structure handler.
String reference = pageSeq.getMasterReference();
- SimplePageMaster pagemaster
+ this.pagemaster
= pageSeq.getRoot().getLayoutMasterSet().getSimplePageMaster(reference);
//only simple-page-master supported, so pagemaster may be null
try {
log.debug("starting flow: " + fl.getFlowName());
- if (fl.getFlowName().equals("xsl-region-body")) {
+ boolean handled = false;
+ Region regionBody = pagemaster.getRegion(Constants.FO_REGION_BODY);
+ Region regionBefore = pagemaster.getRegion(Constants.FO_REGION_BEFORE);
+ Region regionAfter = pagemaster.getRegion(Constants.FO_REGION_AFTER);
+ if (fl.getFlowName().equals(regionBody.getRegionName())) {
// if there is no header in current page-sequence but there has been
// a header in a previous page-sequence, insert an empty header.
if (bPrevHeaderSpecified && !bHeaderSpecified) {
(IRtfAfterContainer.class, true, this);
contAfter.newAfter(attr);
}
-
- } else if (fl.getFlowName().equals("xsl-region-before")) {
+ handled = true;
+ } else if (regionBefore != null
+ && fl.getFlowName().equals(regionBefore.getRegionName())) {
bHeaderSpecified = true;
bPrevHeaderSpecified = true;
RtfBefore before = c.newBefore(beforeAttributes);
builderContext.pushContainer(before);
- } else if (fl.getFlowName().equals("xsl-region-after")) {
+ handled = true;
+ } else if (regionAfter != null
+ && fl.getFlowName().equals(regionAfter.getRegionName())) {
bFooterSpecified = true;
bPrevFooterSpecified = true;
RtfAfter after = c.newAfter(afterAttributes);
builderContext.pushContainer(after);
+ handled = true;
+ }
+ if (!handled) {
+ log.warn("A " + fl.getLocalName() + " has been skipped: " + fl.getFlowName());
}
} catch (IOException ioe) {
log.error("startFlow: " + ioe.getMessage());
}
try {
- if (fl.getFlowName().equals("xsl-region-body")) {
+ Region regionBody = pagemaster.getRegion(Constants.FO_REGION_BODY);
+ Region regionBefore = pagemaster.getRegion(Constants.FO_REGION_BEFORE);
+ Region regionAfter = pagemaster.getRegion(Constants.FO_REGION_AFTER);
+ if (fl.getFlowName().equals(regionBody.getRegionName())) {
//just do nothing
- } else if (fl.getFlowName().equals("xsl-region-before")) {
+ } else if (regionBefore != null
+ && fl.getFlowName().equals(regionBefore.getRegionName())) {
builderContext.popContainer();
- } else if (fl.getFlowName().equals("xsl-region-after")) {
+ } else if (regionAfter != null
+ && fl.getFlowName().equals(regionAfter.getRegionName())) {
builderContext.popContainer();
}
} catch (Exception e) {
if (foNode instanceof PageSequence) {
PageSequence pageSequence = (PageSequence) foNode;
- FONode regionBefore = (FONode) pageSequence.flowMap.get("xsl-region-before");
- FONode regionAfter = (FONode) pageSequence.flowMap.get("xsl-region-after");
-
+ Region regionBefore = pagemaster.getRegion(Constants.FO_REGION_BEFORE);
if (regionBefore != null) {
- recurseFONode(regionBefore);
+ FONode staticBefore = (FONode) pageSequence.flowMap.get(
+ regionBefore.getRegionName());
+ if (staticBefore != null) {
+ recurseFONode(staticBefore);
+ }
}
-
+ Region regionAfter = pagemaster.getRegion(Constants.FO_REGION_AFTER);
if (regionAfter != null) {
- recurseFONode(regionAfter);
+ FONode staticAfter = (FONode) pageSequence.flowMap.get(
+ regionAfter.getRegionName());
+ if (staticAfter != null) {
+ recurseFONode(staticAfter);
+ }
}
+
recurseFONode( pageSequence.getMainFlow() );
} else if (foNode instanceof Table) {
Table table = (Table) foNode;