diff options
author | Jeremias Maerki <jeremias@apache.org> | 2006-01-25 13:48:32 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2006-01-25 13:48:32 +0000 |
commit | 3d1baf5455c62ebca26b523176690d304b637bec (patch) | |
tree | 004df2e41d09d47b2e53363f85ffb8ae9e3938b0 | |
parent | 5bf86498b12319459fdfc24c47e6a4ef8731b046 (diff) | |
download | xmlgraphics-fop-3d1baf5455c62ebca26b523176690d304b637bec.tar.gz xmlgraphics-fop-3d1baf5455c62ebca26b523176690d304b637bec.zip |
Bugfix: Regions with non-standard names got ignored in RTF output leading to missing headers and footers.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@372214 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/fop/render/rtf/RTFHandler.java | 56 | ||||
-rw-r--r-- | status.xml | 4 |
2 files changed, 46 insertions, 14 deletions
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java index 68addd742..3161c0ce1 100644 --- a/src/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java @@ -32,6 +32,9 @@ import org.xml.sax.SAXException; // 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; @@ -57,6 +60,7 @@ import org.apache.fop.fo.flow.TableHeader; 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; @@ -121,6 +125,7 @@ public class RTFHandler extends FOEventHandler { //in current page-sequence private BuilderContext builderContext = new BuilderContext(null); + private SimplePageMaster pagemaster; /** * Creates a new RTF structure handler. @@ -179,7 +184,7 @@ public class RTFHandler extends FOEventHandler { String reference = pageSeq.getMasterReference(); - SimplePageMaster pagemaster + this.pagemaster = pageSeq.getRoot().getLayoutMasterSet().getSimplePageMaster(reference); //only simple-page-master supported, so pagemaster may be null @@ -232,7 +237,11 @@ public class RTFHandler extends FOEventHandler { 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) { @@ -256,8 +265,9 @@ public class RTFHandler extends FOEventHandler { (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; @@ -274,7 +284,9 @@ public class RTFHandler extends FOEventHandler { 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; @@ -292,6 +304,10 @@ public class RTFHandler extends FOEventHandler { 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()); @@ -312,11 +328,16 @@ public class RTFHandler extends FOEventHandler { } 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) { @@ -1421,17 +1442,24 @@ public class RTFHandler extends FOEventHandler { 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; diff --git a/status.xml b/status.xml index 1991f3bf8..f8f2acdb7 100644 --- a/status.xml +++ b/status.xml @@ -28,6 +28,10 @@ <changes> <release version="FOP Trunk"> <action context="Code" dev="JM" type="fix"> + Bugfix: Regions with non-standard names got ignored in RTF output leading to + missing headers and footers. + </action> + <action context="Code" dev="JM" type="fix"> The RTF output now properly generates the "\landscape" flag for documents in landscape orientation. </action> |