aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/fo/flow
diff options
context:
space:
mode:
authorfotis <fotis@unknown>2000-11-15 10:26:24 +0000
committerfotis <fotis@unknown>2000-11-15 10:26:24 +0000
commiteb0e581ad71052c6afa1afdba6b576f2b9414a65 (patch)
tree6efd52bfe8aa12055e1a6fccb3b907f83e8eef27 /src/org/apache/fop/fo/flow
parentd03ee13a49a09d14710c8d00cf861062cfc5fc86 (diff)
downloadxmlgraphics-fop-eb0e581ad71052c6afa1afdba6b576f2b9414a65.tar.gz
xmlgraphics-fop-eb0e581ad71052c6afa1afdba6b576f2b9414a65.zip
region-name support, refactoring of region, PageSequence, PageMasterReference, flow/static [Kelly Campbell, Arved Sandstrom]
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193805 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/fo/flow')
-rw-r--r--src/org/apache/fop/fo/flow/Flow.java74
-rw-r--r--src/org/apache/fop/fo/flow/StaticContent.java67
2 files changed, 104 insertions, 37 deletions
diff --git a/src/org/apache/fop/fo/flow/Flow.java b/src/org/apache/fop/fo/flow/Flow.java
index 58ddefa9d..70b677979 100644
--- a/src/org/apache/fop/fo/flow/Flow.java
+++ b/src/org/apache/fop/fo/flow/Flow.java
@@ -54,9 +54,10 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
-import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.pagination.*;
import org.apache.fop.layout.Area;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.messaging.MessageHandler;
// Java
import java.util.Hashtable;
@@ -75,13 +76,22 @@ public class Flow extends FObj {
return new Flow.Maker();
}
- PageSequence pageSequence;
- private Area area; // Area in which we lay out our kids
+ /** PageSequence container */
+ private PageSequence pageSequence;
+
+ /** Area in which we lay out our kids */
+ private Area area;
+
+ /** flow-name attribute */
+ private String _flowName;
+
+ private Status _status = new Status(Status.AREA_FULL_NONE);
+
protected Flow(FObj parent, PropertyList propertyList)
throws FOPException {
super(parent, propertyList);
- this.name = "fo:flow";
+ this.name = getElementName();
if (parent.getName().equals("fo:page-sequence")) {
this.pageSequence = (PageSequence) parent;
@@ -89,11 +99,35 @@ public class Flow extends FObj {
throw new FOPException("flow must be child of "
+ "page-sequence, not "
+ parent.getName());
- }
- pageSequence.setFlow(this);
+ }
+ setFlowName(getProperty("flow-name").getString());
+ pageSequence.addFlow(this);
}
+
+ protected void setFlowName(String name)
+ throws FOPException
+ {
+ if (name == null || name.equals("")) {
+ MessageHandler.errorln("WARNING: A 'flow-name' is required for "+getElementName()+". This constraint will be enforced in future versions of FOP");
+ _flowName = "xsl-region-body";
+ }
+ else {
+ _flowName = name;
+ }
+ }
+
+ public String getFlowName()
+ {
+ return _flowName;
+ }
+
public Status layout(Area area) throws FOPException {
+ return layout(area, null);
+
+ }
+
+ public Status layout(Area area, Region region) throws FOPException {
if (this.marker == START) {
this.marker = 0;
}
@@ -103,23 +137,23 @@ public class Flow extends FObj {
int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
FObj fo = (FObj) children.elementAt(i);
- Status status;
- if ((status = fo.layout(area)).isIncomplete()) {
- if ((prevChildMustKeepWithNext) && (status.laidOutNone())) {
+ if ((_status = fo.layout(area)).isIncomplete()) {
+ if ((prevChildMustKeepWithNext) && (_status.laidOutNone())) {
this.marker = i - 1;
FObj prevChild = (FObj) children.elementAt(this.marker);
prevChild.removeAreas();
prevChild.resetMarker();
prevChild.removeID(area.getIDReferences());
- return new Status(Status.AREA_FULL_SOME);
+ _status = new Status(Status.AREA_FULL_SOME);
+ return _status;
// should probably return AREA_FULL_NONE if first
// or perhaps an entirely new status code
} else {
this.marker = i;
- return status;
+ return _status;
}
}
- if (status.getCode() == Status.KEEP_WITH_NEXT) {
+ if (_status.getCode() == Status.KEEP_WITH_NEXT) {
prevChildMustKeepWithNext = true;
}
else {
@@ -127,7 +161,8 @@ public class Flow extends FObj {
}
}
- return new Status(Status.OK);
+ _status = new Status(Status.OK);
+ return _status;
}
/**
@@ -139,4 +174,17 @@ public class Flow extends FObj {
return area.getContentWidth(); //getAllocationWidth()??
else return 0; // not laid out yet
}
+
+ protected String getElementName()
+ {
+ return "fo:flow";
+ }
+
+ public Status getStatus()
+ {
+ return _status;
+ }
+
+
+
}
diff --git a/src/org/apache/fop/fo/flow/StaticContent.java b/src/org/apache/fop/fo/flow/StaticContent.java
index 9394c21d7..f9ea28ecc 100644
--- a/src/org/apache/fop/fo/flow/StaticContent.java
+++ b/src/org/apache/fop/fo/flow/StaticContent.java
@@ -53,14 +53,14 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
-import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.pagination.*;
import org.apache.fop.layout.Area;
import org.apache.fop.apps.FOPException;
// Java
import java.util.Enumeration;
-public class StaticContent extends FObj {
+public class StaticContent extends Flow {
public static class Maker extends FObj.Maker {
public FObj make(FObj parent, PropertyList propertyList)
@@ -73,37 +73,39 @@ public class StaticContent extends FObj {
return new StaticContent.Maker();
}
- PageSequence pageSequence;
-
protected StaticContent(FObj parent, PropertyList propertyList)
throws FOPException {
super(parent, propertyList);
- this.name = "fo:static-content";
-
- if (parent.getName().equals("fo:page-sequence")) {
- this.pageSequence = (PageSequence) parent;
- } else {
- throw new FOPException("static-content must be child of "
- + "fo:page-sequence, not "
- + parent.getName());
- }
- String flowName = this.properties.get("flow-name").getString();
-
- pageSequence.setStaticContent(flowName, this);
}
public Status layout(Area area) throws FOPException {
+ return layout(area, null);
+ }
+
+
+ public Status layout(Area area, Region region) throws FOPException {
int numChildren = this.children.size();
// Set area absolute height so that link rectangles will be drawn correctly in xsl-before and xsl-after
- String flowName = this.properties.get("flow-name").getString();
- if(flowName.equals("xsl-region-before"))
- {
- area.setAbsoluteHeight(-area.getMaxHeight());
+ String regionClass = "none";
+ if (region != null) {
+ regionClass = region.getRegionClass();
}
- else if(flowName.equals("xsl-region-after"))
- {
- area.setAbsoluteHeight(area.getPage().getBody().getMaxHeight());
+ else {
+ if(getFlowName().equals("xsl-region-before")) {
+ regionClass = RegionBefore.REGION_CLASS;
+ }
+ else if(getFlowName().equals("xsl-region-after")) {
+ regionClass = RegionAfter.REGION_CLASS;
+ }
+
+ }
+
+ if(regionClass.equals(RegionBefore.REGION_CLASS)) {
+ area.setAbsoluteHeight(-area.getMaxHeight());
+ }
+ else if(regionClass.equals(RegionAfter.REGION_CLASS)) {
+ area.setAbsoluteHeight(area.getPage().getBody().getMaxHeight());
}
for (int i = 0; i < numChildren; i++) {
@@ -117,9 +119,26 @@ public class StaticContent extends FObj {
}
return(status);
}
-// fo.layout(area);
}
resetMarker();
return new Status(Status.OK);
}
+
+ protected String getElementName()
+ {
+ return "fo:static-content";
+ }
+
+ // flowname checking is more stringient for static content currently
+ protected void setFlowName(String name)
+ throws FOPException
+ {
+ if (name == null || name.equals("")) {
+ throw new FOPException("A 'flow-name' is required for "+getElementName()+".");
+ }
+ else {
+ super.setFlowName(name);
+ }
+
+ }
}