From 5273e66a656c4e769d0820fabc3dfbc9b35a6c50 Mon Sep 17 00:00:00 2001 From: jtauber Date: Thu, 25 Nov 1999 17:33:16 +0000 Subject: Partial implementation of keep-with-next (doesn't yet remove area from previous page when fo is moved to next page to ensure keep). The layout method on each FO now returns a Status object rather than an int to allow for more information to be passed back in the future. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193240 13f79535-47bb-0310-9956-ffa450edef68 --- STATUS | 4 +- src/codegen/properties.xml | 12 ++ src/org/apache/fop/apps/Version.java | 6 +- src/org/apache/fop/fo/FONode.java | 23 +-- src/org/apache/fop/fo/FOText.java | 13 +- src/org/apache/fop/fo/FObj.java | 7 +- src/org/apache/fop/fo/FObjMixed.java | 11 +- src/org/apache/fop/fo/Makefile | 3 +- src/org/apache/fop/fo/PropertyListBuilder.java | 194 +++++++++++---------- src/org/apache/fop/fo/flow/Block.java | 36 ++-- src/org/apache/fop/fo/flow/DisplayGraphic.java | 7 +- src/org/apache/fop/fo/flow/DisplayRule.java | 6 +- src/org/apache/fop/fo/flow/DisplaySequence.java | 22 +-- src/org/apache/fop/fo/flow/Flow.java | 31 +++- src/org/apache/fop/fo/flow/InlineSequence.java | 3 +- src/org/apache/fop/fo/flow/ListBlock.java | 22 +-- src/org/apache/fop/fo/flow/ListItem.java | 13 +- src/org/apache/fop/fo/flow/ListItemBody.java | 17 +- src/org/apache/fop/fo/flow/ListItemLabel.java | 7 +- src/org/apache/fop/fo/flow/PageNumber.java | 9 +- src/org/apache/fop/fo/flow/StaticContent.java | 6 +- src/org/apache/fop/fo/flow/Table.java | 29 +-- src/org/apache/fop/fo/flow/TableBody.java | 17 +- src/org/apache/fop/fo/flow/TableCell.java | 16 +- src/org/apache/fop/fo/flow/TableColumn.java | 3 +- src/org/apache/fop/fo/flow/TableRow.java | 17 +- src/org/apache/fop/fo/pagination/PageSequence.java | 11 +- src/org/apache/fop/layout/Area.java | 12 +- src/org/apache/fop/svg/Graphic.java | 2 +- src/org/apache/fop/svg/Line.java | 7 +- src/org/apache/fop/svg/LineGraphic.java | 3 +- src/org/apache/fop/svg/Rect.java | 7 +- src/org/apache/fop/svg/SVG.java | 25 +-- src/org/apache/fop/svg/Text.java | 7 +- 34 files changed, 329 insertions(+), 279 deletions(-) diff --git a/STATUS b/STATUS index e12212087..1937a1cfe 100644 --- a/STATUS +++ b/STATUS @@ -7,8 +7,8 @@ Things to do before releasing as 0.12.0: Make sure Makefiles work Get images working [PARTIAL] Incorporate Arved Sandstrom's simple-link implementation -Switch to using Status object as return from layout() -Implement basic keeps +[DONE] Switch to using Status object as return from layout() +[PARTIAL] Implement basic keeps [DONE]Incorporate Eric Schaeffer's fix to tables in static-content [DONE] Incorporate Kelly Campell's fixes to GifJpegImage diff --git a/src/codegen/properties.xml b/src/codegen/properties.xml index cfeb6aac2..3c18505c0 100644 --- a/src/codegen/properties.xml +++ b/src/codegen/properties.xml @@ -311,5 +311,17 @@ Length 0pt + + keep-with-next + KeepWithNext + false + + + true + false + + + false + diff --git a/src/org/apache/fop/apps/Version.java b/src/org/apache/fop/apps/Version.java index a97e23501..0dd7925e3 100644 --- a/src/org/apache/fop/apps/Version.java +++ b/src/org/apache/fop/apps/Version.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -53,7 +53,7 @@ package org.apache.fop.apps; /** * class representing the version of FOP. * - * added at the request of Stefano Mazzocchi for use by Fop. + * added at the request of Stefano Mazzocchi for use by Cocoon. */ public class Version { @@ -63,6 +63,6 @@ public class Version { * @return the version string */ public static String getVersion() { - return "FOP 0.12.0pre5"; + return "FOP 0.11.5"; } } diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java index bad4bfbf2..9e04e66bc 100644 --- a/src/org/apache/fop/fo/FONode.java +++ b/src/org/apache/fop/fo/FONode.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo; // FOP @@ -133,6 +134,10 @@ abstract public class FONode { } } + public void removeAreas() { + // still to do + } + protected void addChild(FONode child) { children.addElement(child); } @@ -141,20 +146,6 @@ abstract public class FONode { return this.parent; } - /* status */ - /* layout was fully completed */ - public final static int OK = 1; - /* none of the formatting object could be laid out because the - containing area was full (end of page) */ - public final static int AREA_FULL_NONE = 2; - /* some of the formatting object could not be laid out because the - containing area was full (end of page) */ - public final static int AREA_FULL_SOME = 3; - /* force page break */ - public final static int FORCE_PAGE_BREAK = 4; - public final static int FORCE_PAGE_BREAK_EVEN = 5; - public final static int FORCE_PAGE_BREAK_ODD = 6; - - abstract public int layout(Area area) + abstract public Status layout(Area area) throws FOPException; } diff --git a/src/org/apache/fop/fo/FOText.java b/src/org/apache/fop/fo/FOText.java index 6da9163a7..ad6703f51 100644 --- a/src/org/apache/fop/fo/FOText.java +++ b/src/org/apache/fop/fo/FOText.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo; // FOP @@ -83,10 +84,10 @@ public class FOText extends FONode { this.length = e - s; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (!(area instanceof BlockArea)) { System.err.println("WARNING: text outside block area" + new String(ca, start, length)); - return OK; + return new Status(Status.OK); } if (this.marker == START) { String fontFamily = @@ -120,11 +121,11 @@ public class FOText extends FONode { whiteSpaceTreatment, ca, this.marker, length); if (this.marker == -1) { - return OK; + return new Status(Status.OK); } else if (this.marker != orig_start) { - return AREA_FULL_SOME; + return new Status(Status.AREA_FULL_SOME); } else { - return AREA_FULL_NONE; + return new Status(Status.AREA_FULL_NONE); } } } diff --git a/src/org/apache/fop/fo/FObj.java b/src/org/apache/fop/fo/FObj.java index 9e48e969d..ec7d6b396 100644 --- a/src/org/apache/fop/fo/FObj.java +++ b/src/org/apache/fop/fo/FObj.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo; // FOP @@ -87,9 +88,9 @@ public class FObj extends FONode { // ignore } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { // should always be overridden - return OK; + return new Status(Status.OK); } public String getName() { diff --git a/src/org/apache/fop/fo/FObjMixed.java b/src/org/apache/fop/fo/FObjMixed.java index a005991ec..d82257770 100644 --- a/src/org/apache/fop/fo/FObjMixed.java +++ b/src/org/apache/fop/fo/FObjMixed.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo; import org.apache.fop.layout.Area; @@ -78,7 +79,7 @@ public class FObjMixed extends FObj { children.addElement(new FOText(data,start,length,this)); } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == START) { this.marker = 0; @@ -87,13 +88,13 @@ public class FObjMixed extends FObj { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { FONode fo = (FONode) children.elementAt(i); - int status; - if ((status = fo.layout(area)) != OK) { + Status status; + if ((status = fo.layout(area)).isIncomplete()) { this.marker = i; return status; } } - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/Makefile b/src/org/apache/fop/fo/Makefile index da4211088..10407ad01 100644 --- a/src/org/apache/fop/fo/Makefile +++ b/src/org/apache/fop/fo/Makefile @@ -15,7 +15,8 @@ SOURCES=FONode.java \ Property.java \ PropertyList.java \ PropertyListBuilder.java \ - StandardElementMapping.java + StandardElementMapping.java \ + Status.java CLASSES=$(SOURCES:.java=.class) diff --git a/src/org/apache/fop/fo/PropertyListBuilder.java b/src/org/apache/fop/fo/PropertyListBuilder.java index 9465cdc53..df31a1767 100644 --- a/src/org/apache/fop/fo/PropertyListBuilder.java +++ b/src/org/apache/fop/fo/PropertyListBuilder.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo; import org.apache.fop.fo.properties.*; @@ -60,111 +61,114 @@ import org.xml.sax.AttributeList; import java.util.Hashtable; public class PropertyListBuilder { - private Hashtable propertyTable; + + private Hashtable propertyTable; - public PropertyListBuilder() { - this.propertyTable = new Hashtable(); + public PropertyListBuilder() { + this.propertyTable = new Hashtable(); - propertyTable.put("end-indent",EndIndent.maker()); - propertyTable.put("page-master-name",PageMasterName.maker()); - propertyTable.put("page-master-first",PageMasterFirst.maker()); - propertyTable.put("page-master-repeating",PageMasterRepeating.maker()); - propertyTable.put("page-master-odd",PageMasterOdd.maker()); - propertyTable.put("page-master-even",PageMasterEven.maker()); - propertyTable.put("margin-top",MarginTop.maker()); - propertyTable.put("margin-bottom",MarginBottom.maker()); - propertyTable.put("margin-left",MarginLeft.maker()); - propertyTable.put("margin-right",MarginRight.maker()); - propertyTable.put("extent",Extent.maker()); - propertyTable.put("page-width",PageWidth.maker()); - propertyTable.put("page-height",PageHeight.maker()); - propertyTable.put("flow-name",FlowName.maker()); - propertyTable.put("font-family",FontFamily.maker()); - propertyTable.put("font-style",FontStyle.maker()); - propertyTable.put("font-weight",FontWeight.maker()); - propertyTable.put("font-size",FontSize.maker()); - propertyTable.put("line-height",LineHeight.maker()); - propertyTable.put("text-align",TextAlign.maker()); - propertyTable.put("text-align-last",TextAlignLast.maker()); - propertyTable.put("space-before.optimum",SpaceBeforeOptimum.maker()); - propertyTable.put("space-after.optimum",SpaceAfterOptimum.maker()); - propertyTable.put("start-indent",StartIndent.maker()); - propertyTable.put("end-indent",EndIndent.maker()); - propertyTable.put("provisional-distance-between-starts",ProvisionalDistanceBetweenStarts.maker()); - propertyTable.put("provisional-label-separation",ProvisionalLabelSeparation.maker()); - propertyTable.put("rule-thickness",RuleThickness.maker()); - propertyTable.put("color",Color.maker()); - propertyTable.put("wrap-option",WrapOption.maker()); - propertyTable.put("white-space-treatment",WhiteSpaceTreatment.maker()); - propertyTable.put("break-before",BreakBefore.maker()); - propertyTable.put("break-after",BreakAfter.maker()); - propertyTable.put("text-indent",TextIndent.maker()); - propertyTable.put("href",HRef.maker()); - propertyTable.put("column-width",ColumnWidth.maker()); - propertyTable.put("height",SVGLength.maker()); - propertyTable.put("width",SVGLength.maker()); - propertyTable.put("x",SVGLength.maker()); - propertyTable.put("y",SVGLength.maker()); - propertyTable.put("x1",SVGLength.maker()); - propertyTable.put("x2",SVGLength.maker()); - propertyTable.put("y1",SVGLength.maker()); - propertyTable.put("y2",SVGLength.maker()); - } + propertyTable.put("end-indent",EndIndent.maker()); + propertyTable.put("page-master-name",PageMasterName.maker()); + propertyTable.put("page-master-first",PageMasterFirst.maker()); + propertyTable.put("page-master-repeating",PageMasterRepeating.maker()); + propertyTable.put("page-master-odd",PageMasterOdd.maker()); + propertyTable.put("page-master-even",PageMasterEven.maker()); + propertyTable.put("margin-top",MarginTop.maker()); + propertyTable.put("margin-bottom",MarginBottom.maker()); + propertyTable.put("margin-left",MarginLeft.maker()); + propertyTable.put("margin-right",MarginRight.maker()); + propertyTable.put("extent",Extent.maker()); + propertyTable.put("page-width",PageWidth.maker()); + propertyTable.put("page-height",PageHeight.maker()); + propertyTable.put("flow-name",FlowName.maker()); + propertyTable.put("font-family",FontFamily.maker()); + propertyTable.put("font-style",FontStyle.maker()); + propertyTable.put("font-weight",FontWeight.maker()); + propertyTable.put("font-size",FontSize.maker()); + propertyTable.put("line-height",LineHeight.maker()); + propertyTable.put("text-align",TextAlign.maker()); + propertyTable.put("text-align-last",TextAlignLast.maker()); + propertyTable.put("space-before.optimum",SpaceBeforeOptimum.maker()); + propertyTable.put("space-after.optimum",SpaceAfterOptimum.maker()); + propertyTable.put("start-indent",StartIndent.maker()); + propertyTable.put("end-indent",EndIndent.maker()); + propertyTable.put("provisional-distance-between-starts",ProvisionalDistanceBetweenStarts.maker()); + propertyTable.put("provisional-label-separation",ProvisionalLabelSeparation.maker()); + propertyTable.put("rule-thickness",RuleThickness.maker()); + propertyTable.put("color",Color.maker()); + propertyTable.put("wrap-option",WrapOption.maker()); + propertyTable.put("white-space-treatment",WhiteSpaceTreatment.maker()); + propertyTable.put("break-before",BreakBefore.maker()); + propertyTable.put("break-after",BreakAfter.maker()); + propertyTable.put("text-indent",TextIndent.maker()); + propertyTable.put("href",HRef.maker()); + propertyTable.put("column-width",ColumnWidth.maker()); + propertyTable.put("keep-with-next",KeepWithNext.maker()); - public Property computeProperty(PropertyList propertyList, String propertyName) { + propertyTable.put("height",SVGLength.maker()); + propertyTable.put("width",SVGLength.maker()); + propertyTable.put("x",SVGLength.maker()); + propertyTable.put("y",SVGLength.maker()); + propertyTable.put("x1",SVGLength.maker()); + propertyTable.put("x2",SVGLength.maker()); + propertyTable.put("y1",SVGLength.maker()); + propertyTable.put("y2",SVGLength.maker()); + } - Property p = null; + public Property computeProperty(PropertyList propertyList, String propertyName) { - Property.Maker propertyMaker = (Property.Maker)propertyTable.get(propertyName); - if (propertyMaker != null) { - p = propertyMaker.compute(propertyList); - } else { - //System.err.println("WARNING: property " + propertyName + " ignored"); + Property p = null; + + Property.Maker propertyMaker = (Property.Maker)propertyTable.get(propertyName); + if (propertyMaker != null) { + p = propertyMaker.compute(propertyList); + } else { + //System.err.println("WARNING: property " + propertyName + " ignored"); + } + return p; } - return p; - } - - public boolean isInherited(String propertyName) { - boolean b; + + public boolean isInherited(String propertyName) { + boolean b; - Property.Maker propertyMaker = (Property.Maker)propertyTable.get(propertyName); - if (propertyMaker != null) { - b = propertyMaker.isInherited(); - } else { - //System.err.println("WARNING: Unknown property " + propertyName); - b = true; + Property.Maker propertyMaker = (Property.Maker)propertyTable.get(propertyName); + if (propertyMaker != null) { + b = propertyMaker.isInherited(); + } else { + //System.err.println("WARNING: Unknown property " + propertyName); + b = true; + } + return b; } - return b; - } - - public PropertyList makeList(AttributeList attributes, PropertyList parentPropertyList) throws FOPException { + + public PropertyList makeList(AttributeList attributes, PropertyList parentPropertyList) throws FOPException { + + PropertyList p = new PropertyList(parentPropertyList); + p.setBuilder(this); - PropertyList p = new PropertyList(parentPropertyList); - p.setBuilder(this); + for (int i = 0; i < attributes.getLength(); i++) { + String attributeName = attributes.getName(i); + Property.Maker propertyMaker = (Property.Maker)propertyTable.get(attributeName); + if (propertyMaker != null) { + p.put(attributeName,propertyMaker.make(p,attributes.getValue(i))); + } else { + //System.err.println("WARNING: property " + attributeName + " ignored"); + } + } - for (int i = 0; i < attributes.getLength(); i++) { - String attributeName = attributes.getName(i); - Property.Maker propertyMaker = (Property.Maker)propertyTable.get(attributeName); - if (propertyMaker != null) { - p.put(attributeName,propertyMaker.make(p,attributes.getValue(i))); - } else { - //System.err.println("WARNING: property " + attributeName + " ignored"); - } + return p; } - - return p; - } - - public Property makeProperty(PropertyList propertyList, String propertyName) throws FOPException { - - Property p = null; + + public Property makeProperty(PropertyList propertyList, String propertyName) throws FOPException { + + Property p = null; - Property.Maker propertyMaker = (Property.Maker)propertyTable.get(propertyName); - if (propertyMaker != null) { - p = propertyMaker.make(propertyList); - } else { - //System.err.println("WARNING: property " + propertyName + " ignored"); + Property.Maker propertyMaker = (Property.Maker)propertyTable.get(propertyName); + if (propertyMaker != null) { + p = propertyMaker.make(propertyList); + } else { + //System.err.println("WARNING: property " + propertyName + " ignored"); + } + return p; } - return p; - } } diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index 113b9eeb3..6b22f17a7 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -80,6 +81,7 @@ public class Block extends FObjMixed { int spaceBefore; int spaceAfter; int textIndent; + int keepWithNext; BlockArea blockArea; @@ -91,11 +93,11 @@ public class Block extends FObjMixed { this.name = "fo:block"; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { // System.err.print(" b:LAY[" + marker + "] "); if (this.marker == BREAK_AFTER) { - return OK; + return new Status(Status.OK); } if (this.marker == START) { @@ -129,6 +131,8 @@ public class Block extends FObjMixed { this.properties.get("space-after.optimum").getLength().mvalue(); this.textIndent = this.properties.get("text-indent").getLength().mvalue(); + this.keepWithNext = + this.properties.get("keep-with-next").getEnum(); if (area instanceof BlockArea) { area.end(); @@ -153,15 +157,15 @@ public class Block extends FObjMixed { this.marker = 0; if (breakBefore == BreakBefore.PAGE) { - return FORCE_PAGE_BREAK; + return new Status(Status.FORCE_PAGE_BREAK); } if (breakBefore == BreakBefore.ODD_PAGE) { - return FORCE_PAGE_BREAK_ODD; + return new Status(Status.FORCE_PAGE_BREAK_ODD); } if (breakBefore == BreakBefore.EVEN_PAGE) { - return FORCE_PAGE_BREAK_EVEN; + return new Status(Status.FORCE_PAGE_BREAK_EVEN); } } @@ -188,11 +192,11 @@ public class Block extends FObjMixed { fo.setDistanceBetweenStarts(this.distanceBetweenStarts); fo.setBodyIndent(this.bodyIndent); } - int status; - if ((status = fo.layout(blockArea)) != OK) { + Status status; + if ((status = fo.layout(blockArea)).isIncomplete()) { this.marker = i; - if ((i != 0) && (status == AREA_FULL_NONE)) { - status = AREA_FULL_SOME; + if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { + status = new Status(Status.AREA_FULL_SOME); } //blockArea.end(); area.addChild(blockArea); @@ -219,21 +223,25 @@ public class Block extends FObjMixed { if (breakAfter == BreakAfter.PAGE) { this.marker = BREAK_AFTER; - return FORCE_PAGE_BREAK; + return new Status(Status.FORCE_PAGE_BREAK); } if (breakAfter == BreakAfter.ODD_PAGE) { this.marker = BREAK_AFTER; - return FORCE_PAGE_BREAK_ODD; + return new Status(Status.FORCE_PAGE_BREAK_ODD); } if (breakAfter == BreakAfter.EVEN_PAGE) { this.marker = BREAK_AFTER; - return FORCE_PAGE_BREAK_EVEN; + return new Status(Status.FORCE_PAGE_BREAK_EVEN); + } + + if (keepWithNext == KeepWithNext.TRUE) { + return new Status(Status.KEEP_WITH_NEXT); } //System.err.print(" b:OK" + marker + " "); - return OK; + return new Status(Status.OK); } public int getAreaHeight() { diff --git a/src/org/apache/fop/fo/flow/DisplayGraphic.java b/src/org/apache/fop/fo/flow/DisplayGraphic.java index 47e360fae..921eb99b3 100644 --- a/src/org/apache/fop/fo/flow/DisplayGraphic.java +++ b/src/org/apache/fop/fo/flow/DisplayGraphic.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -92,7 +93,7 @@ public class DisplayGraphic extends FObj { this.name = "fo:display-graphic"; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == START) { String fontFamily = @@ -177,6 +178,6 @@ public class DisplayGraphic extends FObj { area.start(); } - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/flow/DisplayRule.java b/src/org/apache/fop/fo/flow/DisplayRule.java index 855ec6d8d..fb8467b3c 100644 --- a/src/org/apache/fop/fo/flow/DisplayRule.java +++ b/src/org/apache/fop/fo/flow/DisplayRule.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -78,7 +78,7 @@ public class DisplayRule extends FObj { this.name = "fo:display-rule"; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { // FIXME: doesn't check to see if it will fit String fontFamily = this.properties.get("font-family").getString(); @@ -133,6 +133,6 @@ public class DisplayRule extends FObj { area.start(); } - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/flow/DisplaySequence.java b/src/org/apache/fop/fo/flow/DisplaySequence.java index 35189ebff..05571ffb9 100644 --- a/src/org/apache/fop/fo/flow/DisplaySequence.java +++ b/src/org/apache/fop/fo/flow/DisplaySequence.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -76,7 +77,7 @@ public class DisplaySequence extends FObj { this.name = "fo:display-sequence"; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == START) { this.marker = 0; } @@ -84,19 +85,12 @@ public class DisplaySequence extends FObj { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { FObj fo = (FObj) children.elementAt(i); - int status; - if ((status = fo.layout(area)) != OK) { - /* message from child */ - if (status > OK) { - /* child still successful */ - this.marker = i+1; - } else { - /* child unsucessful */ - this.marker = i; - } - return status; + Status status; + if ((status = fo.layout(area)).isIncomplete()) { + this.marker = i; } + return status; } - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/flow/Flow.java b/src/org/apache/fop/fo/flow/Flow.java index 380af416c..46b70da1c 100644 --- a/src/org/apache/fop/fo/flow/Flow.java +++ b/src/org/apache/fop/fo/flow/Flow.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -91,19 +92,35 @@ public class Flow extends FObj { pageSequence.setFlow(this); } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == START) { this.marker = 0; } + + boolean prevChildMustKeepWithNext = false; + int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { FObj fo = (FObj) children.elementAt(i); - int status; - if ((status = fo.layout(area)) != OK) { - this.marker = i; - return status; + Status status; + 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(); + return new Status(Status.AREA_FULL_SOME); + // should probably return AREA_FULL_NONE if first + // or perhaps an entirely new status code + } else { + this.marker = i; + return status; + } + } + if (status.getCode() == Status.KEEP_WITH_NEXT) { + prevChildMustKeepWithNext = true; } } - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/flow/InlineSequence.java b/src/org/apache/fop/fo/flow/InlineSequence.java index c7965636a..ab7a015d1 100644 --- a/src/org/apache/fop/fo/flow/InlineSequence.java +++ b/src/org/apache/fop/fo/flow/InlineSequence.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP diff --git a/src/org/apache/fop/fo/flow/ListBlock.java b/src/org/apache/fop/fo/flow/ListBlock.java index a3a649719..931251adb 100644 --- a/src/org/apache/fop/fo/flow/ListBlock.java +++ b/src/org/apache/fop/fo/flow/ListBlock.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -93,7 +94,7 @@ public class ListBlock extends FObj { this.name = "fo:list-block"; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == START) { String fontFamily = this.properties.get("font-family").getString(); @@ -153,22 +154,15 @@ public class ListBlock extends FObj { for (int i = this.marker; i < numChildren; i++) { if (!(children.elementAt(i) instanceof ListItem)) { System.err.println("WARNING: This version of FOP requires list-items inside list-blocks"); - return OK; + return new Status(Status.OK); } ListItem listItem = (ListItem) children.elementAt(i); listItem.setDistanceBetweenStarts(this.provisionalDistanceBetweenStarts); listItem.setLabelSeparation(this.provisionalLabelSeparation); listItem.setBodyIndent(this.bodyIndent); - int status; - if ((status = listItem.layout(blockArea)) != OK) { - /* message from child */ - if (status > OK) { - /* child still successful */ - this.marker = i+1; - } else { - /* child unsucessful */ - this.marker = i; - } + Status status; + if ((status = listItem.layout(blockArea)).isIncomplete()) { + this.marker = i; blockArea.end(); area.addChild(blockArea); area.increaseHeight(blockArea.getHeight()); @@ -188,6 +182,6 @@ public class ListBlock extends FObj { area.start(); } - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/flow/ListItem.java b/src/org/apache/fop/fo/flow/ListItem.java index 4ab9a8290..7c7fa49be 100644 --- a/src/org/apache/fop/fo/flow/ListItem.java +++ b/src/org/apache/fop/fo/flow/ListItem.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -90,7 +91,7 @@ public class ListItem extends FObj { this.name = "fo:list-item"; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == START) { String fontFamily = this.properties.get("font-family").getString(); @@ -156,20 +157,20 @@ public class ListItem extends FObj { /* this doesn't actually do anything */ body.setLabelSeparation(this.labelSeparation); - int status; + Status status; // what follows doesn't yet take into account whether the // body failed completely or only got some text in if (this.marker == 0) { status = label.layout(blockArea); - if (status != OK) { + if (status.isIncomplete()) { return status; } } status = body.layout(blockArea); - if (status != OK) { + if (status.isIncomplete()) { blockArea.end(); area.addChild(blockArea); area.increaseHeight(blockArea.getHeight()); @@ -189,6 +190,6 @@ public class ListItem extends FObj { if (area instanceof BlockArea) { area.start(); } - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/flow/ListItemBody.java b/src/org/apache/fop/fo/flow/ListItemBody.java index c3799860e..167b6502e 100644 --- a/src/org/apache/fop/fo/flow/ListItemBody.java +++ b/src/org/apache/fop/fo/flow/ListItemBody.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -78,7 +79,7 @@ public class ListItemBody extends FObj { this.name = "fo:list-item-body"; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == START) { this.marker = 0; } @@ -89,16 +90,16 @@ public class ListItemBody extends FObj { fo.setDistanceBetweenStarts(this.distanceBetweenStarts); fo.setLabelSeparation(this.labelSeparation); fo.setBodyIndent(this.bodyIndent); - int status; - if ((status = fo.layout(area)) != OK) { + Status status; + if ((status = fo.layout(area)).isIncomplete()) { this.marker = i; - if ((i == 0) && (status == AREA_FULL_NONE)) { - return AREA_FULL_NONE; + if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) { + return new Status(Status.AREA_FULL_NONE); } else { - return AREA_FULL_SOME; + return new Status(Status.AREA_FULL_SOME); } } } - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/flow/ListItemLabel.java b/src/org/apache/fop/fo/flow/ListItemLabel.java index 07278de8b..040326fb0 100644 --- a/src/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/org/apache/fop/fo/flow/ListItemLabel.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -78,7 +79,7 @@ public class ListItemLabel extends FObj { this.name = "fo:list-item-label"; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { int numChildren = this.children.size(); if (numChildren != 1) { @@ -91,7 +92,7 @@ public class ListItemLabel extends FObj { block.setLabelSeparation(this.labelSeparation); block.setBodyIndent(this.bodyIndent); - int status; + Status status; status = block.layout(area); area.addDisplaySpace(-block.getAreaHeight()); return status; diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java index e31d7ab62..2844b5d98 100644 --- a/src/org/apache/fop/fo/flow/PageNumber.java +++ b/src/org/apache/fop/fo/flow/PageNumber.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -85,10 +86,10 @@ public class PageNumber extends FObj { this.name = "fo:page-number"; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (!(area instanceof BlockArea)) { System.err.println("WARNING: page-number outside block area"); - return OK; + return new Status(Status.OK); } if (this.marker == START) { String fontFamily = this.properties.get("font-family").getString(); @@ -111,6 +112,6 @@ public class PageNumber extends FObj { } String p = Integer.toString(area.getPage().getNumber()); this.marker = ((BlockArea) area).addText(fs, red, green, blue, wrapOption, whiteSpaceTreatment, p.toCharArray(), 0, p.length()); - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/flow/StaticContent.java b/src/org/apache/fop/fo/flow/StaticContent.java index e62185a4b..5e21aefdc 100644 --- a/src/org/apache/fop/fo/flow/StaticContent.java +++ b/src/org/apache/fop/fo/flow/StaticContent.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -92,13 +92,13 @@ public class StaticContent extends FObj { pageSequence.setStaticContent(flowName, this); } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { int numChildren = this.children.size(); for (int i = 0; i < numChildren; i++) { FObj fo = (FObj) children.elementAt(i); fo.layout(area); } resetMarker(); - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java index a41c938e6..52263f756 100644 --- a/src/org/apache/fop/fo/flow/Table.java +++ b/src/org/apache/fop/fo/flow/Table.java @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -90,9 +91,9 @@ public class Table extends FObj { this.name = "fo:table"; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { - return OK; + return new Status(Status.OK); } if (this.marker == START) { @@ -130,15 +131,15 @@ public class Table extends FObj { this.marker = 0; if (breakBefore == BreakBefore.PAGE) { - return FORCE_PAGE_BREAK; + return new Status(Status.FORCE_PAGE_BREAK); } if (breakBefore == BreakBefore.ODD_PAGE) { - return FORCE_PAGE_BREAK_ODD; + return new Status(Status.FORCE_PAGE_BREAK_ODD); } if (breakBefore == BreakBefore.EVEN_PAGE) { - return FORCE_PAGE_BREAK_EVEN; + return new Status(Status.FORCE_PAGE_BREAK_EVEN); } } @@ -173,7 +174,7 @@ public class Table extends FObj { } else if (fo instanceof TableBody) { if (columns.size() == 0) { System.err.println("WARNING: current implementation of tables requires a table-column for each column, indicating column-width"); - return OK; + return new Status(Status.OK); } //if (this.isInListBody) { @@ -184,11 +185,11 @@ public class Table extends FObj { ((TableBody) fo).setColumns(columns); - int status; - if ((status = fo.layout(blockArea)) != OK) { + Status status; + if ((status = fo.layout(blockArea)).isIncomplete()) { this.marker = i; - if ((i != 0) && (status == AREA_FULL_NONE)) { - status = AREA_FULL_SOME; + if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { + status = new Status(Status.AREA_FULL_SOME); } //blockArea.end(); area.addChild(blockArea); @@ -214,20 +215,20 @@ public class Table extends FObj { if (breakAfter == BreakAfter.PAGE) { this.marker = BREAK_AFTER; - return FORCE_PAGE_BREAK; + return new Status(Status.FORCE_PAGE_BREAK); } if (breakAfter == BreakAfter.ODD_PAGE) { this.marker = BREAK_AFTER; - return FORCE_PAGE_BREAK_ODD; + return new Status(Status.FORCE_PAGE_BREAK_ODD); } if (breakAfter == BreakAfter.EVEN_PAGE) { this.marker = BREAK_AFTER; - return FORCE_PAGE_BREAK_EVEN; + return new Status(Status.FORCE_PAGE_BREAK_EVEN); } - return OK; + return new Status(Status.OK); } public int getAreaHeight() { diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java index c3d5a8c5d..82d72f3c7 100644 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ b/src/org/apache/fop/fo/flow/TableBody.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -91,9 +92,9 @@ public class TableBody extends FObj { this.columns = columns; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { - return OK; + return new Status(Status.OK); } if (this.marker == START) { @@ -151,11 +152,11 @@ public class TableBody extends FObj { row.setColumns(columns); - int status; - if ((status = row.layout(blockArea)) != OK) { + Status status; + if ((status = row.layout(blockArea)).isIncomplete()) { this.marker = i; - if ((i != 0) && (status == AREA_FULL_NONE)) { - status = AREA_FULL_SOME; + if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { + status = new Status(Status.AREA_FULL_SOME); } //blockArea.end(); area.addChild(blockArea); @@ -178,7 +179,7 @@ public class TableBody extends FObj { area.start(); } - return OK; + return new Status(Status.OK); } public int getAreaHeight() { diff --git a/src/org/apache/fop/fo/flow/TableCell.java b/src/org/apache/fop/fo/flow/TableCell.java index f3bc0c063..b40147b72 100644 --- a/src/org/apache/fop/fo/flow/TableCell.java +++ b/src/org/apache/fop/fo/flow/TableCell.java @@ -94,9 +94,9 @@ public class TableCell extends FObj { this.width = width; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { - return OK; + return new Status(Status.OK); } if (this.marker == START) { @@ -151,13 +151,13 @@ public class TableCell extends FObj { fo.setIsInTableCell(); fo.forceStartOffset(startOffset); fo.forceWidth(width); - int status; - if ((status = fo.layout(blockArea)) != OK) { + Status status; + if ((status = fo.layout(blockArea)).isIncomplete()) { this.marker = i; - if ((i == 0) && (status == AREA_FULL_NONE)) { - return AREA_FULL_NONE; + if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) { + return new Status(Status.AREA_FULL_NONE); } else { - return AREA_FULL_SOME; + return new Status(Status.AREA_FULL_SOME); } } height += blockArea.getHeight(); @@ -166,7 +166,7 @@ public class TableCell extends FObj { blockArea.end(); area.addChild(blockArea); - return OK; + return new Status(Status.OK); } public int getHeight() { diff --git a/src/org/apache/fop/fo/flow/TableColumn.java b/src/org/apache/fop/fo/flow/TableColumn.java index 4a1b23bcc..82ba4af6c 100644 --- a/src/org/apache/fop/fo/flow/TableColumn.java +++ b/src/org/apache/fop/fo/flow/TableColumn.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index 8f4549345..401436983 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.flow; // FOP @@ -94,9 +95,9 @@ public class TableRow extends FObj { this.columns = columns; } - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { - return OK; + return new Status(Status.OK); } if (this.marker == START) { @@ -145,7 +146,7 @@ public class TableRow extends FObj { int numChildren = this.children.size(); if (numChildren != columns.size()) { System.err.println("WARNING: Number of children under table-row not equal to number of table-columns"); - return OK; + return new Status(Status.OK); } // added by Eric Schaeffer @@ -167,11 +168,11 @@ public class TableRow extends FObj { cell.setWidth(width); widthOfCellsSoFar += width; - int status; - if ((status = cell.layout(blockArea)) != OK) { + Status status; + if ((status = cell.layout(blockArea)).isIncomplete()) { this.marker = i; - if ((i != 0) && (status == AREA_FULL_NONE)) { - status = AREA_FULL_SOME; + if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { + status = new Status(Status.AREA_FULL_SOME); } //blockArea.end(); area.addChild(blockArea); @@ -200,7 +201,7 @@ public class TableRow extends FObj { area.start(); } - return OK; + return new Status(Status.OK); } public int getAreaHeight() { diff --git a/src/org/apache/fop/fo/pagination/PageSequence.java b/src/org/apache/fop/fo/pagination/PageSequence.java index 47260026d..6e8e34622 100644 --- a/src/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/org/apache/fop/fo/pagination/PageSequence.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.fo.pagination; // FOP @@ -136,7 +137,7 @@ public class PageSequence extends FObj { } public void format(AreaTree areaTree) throws FOPException { - int status = OK; + Status status = new Status(Status.OK); do { currentPage = makePage(areaTree); @@ -152,9 +153,9 @@ public class PageSequence extends FObj { AreaContainer afterArea = currentPage.getAfter(); this.staticAfter.layout(afterArea); } - if ((status == FORCE_PAGE_BREAK_EVEN) && + if ((status.getCode() == Status.FORCE_PAGE_BREAK_EVEN) && ((currentPageNumber % 2) == 1)) { - } else if ((status == FORCE_PAGE_BREAK_ODD) && + } else if ((status.getCode() == Status.FORCE_PAGE_BREAK_ODD) && ((currentPageNumber % 2) == 0)) { } else { AreaContainer bodyArea = currentPage.getBody(); @@ -162,7 +163,7 @@ public class PageSequence extends FObj { } System.err.print("]"); areaTree.addPage(currentPage); - } while (status != OK); + } while (status.isIncomplete()); System.err.println(); } diff --git a/src/org/apache/fop/layout/Area.java b/src/org/apache/fop/layout/Area.java index 0849b2ba4..d76045a42 100644 --- a/src/org/apache/fop/layout/Area.java +++ b/src/org/apache/fop/layout/Area.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.layout; // Java @@ -139,7 +140,16 @@ abstract public class Area extends Box { public void increaseHeight(int amount) { this.currentHeight += amount; } + + protected void removeChild(Area area) { + this.currentHeight -= area.getHeight(); + this.children.removeElement(area); + } + public void remove() { + this.parent.removeChild(this); + } + public void setPage(Page page) { this.page = page; } diff --git a/src/org/apache/fop/svg/Graphic.java b/src/org/apache/fop/svg/Graphic.java index cd223a417..fb0381815 100644 --- a/src/org/apache/fop/svg/Graphic.java +++ b/src/org/apache/fop/svg/Graphic.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. diff --git a/src/org/apache/fop/svg/Line.java b/src/org/apache/fop/svg/Line.java index 27d8f76f8..3deb3a32e 100644 --- a/src/org/apache/fop/svg/Line.java +++ b/src/org/apache/fop/svg/Line.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.svg; // FOP @@ -108,7 +109,7 @@ public class Line extends FObj { * * @return the status of the layout */ - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { /* retrieve properties */ int x1 = this.properties.get("x1").getLength().mvalue(); @@ -126,6 +127,6 @@ public class Line extends FObj { } /* return status */ - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/svg/LineGraphic.java b/src/org/apache/fop/svg/LineGraphic.java index 59ed032d7..c769d05d7 100644 --- a/src/org/apache/fop/svg/LineGraphic.java +++ b/src/org/apache/fop/svg/LineGraphic.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.svg; /** diff --git a/src/org/apache/fop/svg/Rect.java b/src/org/apache/fop/svg/Rect.java index 722b87e28..dcce4145c 100644 --- a/src/org/apache/fop/svg/Rect.java +++ b/src/org/apache/fop/svg/Rect.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.svg; // FOP @@ -108,7 +109,7 @@ public class Rect extends FObj { * * @return the status of the layout */ - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { /* retrieve properties */ int width = this.properties.get("width").getLength().mvalue(); @@ -126,6 +127,6 @@ public class Rect extends FObj { } /* return status */ - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/svg/SVG.java b/src/org/apache/fop/svg/SVG.java index 27042e2b3..1befac887 100644 --- a/src/org/apache/fop/svg/SVG.java +++ b/src/org/apache/fop/svg/SVG.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.svg; // FOP @@ -117,10 +118,10 @@ public class SVG extends FObj { * * @return the status of the layout */ - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { - return OK; + return new Status(Status.OK); } if (this.marker == START) { @@ -151,15 +152,15 @@ public class SVG extends FObj { this.marker = 0; if (breakBefore == BreakBefore.PAGE) { - return FORCE_PAGE_BREAK; + return new Status(Status.FORCE_PAGE_BREAK); } if (breakBefore == BreakBefore.ODD_PAGE) { - return FORCE_PAGE_BREAK_ODD; + return new Status(Status.FORCE_PAGE_BREAK_ODD); } if (breakBefore == BreakBefore.EVEN_PAGE) { - return FORCE_PAGE_BREAK_EVEN; + return new Status(Status.FORCE_PAGE_BREAK_EVEN); } } @@ -181,8 +182,8 @@ public class SVG extends FObj { int numChildren = this.children.size(); for (int i = 0; i < numChildren; i++) { FONode fo = (FONode) children.elementAt(i); - int status; - if ((status = fo.layout(svgArea)) != OK) { + Status status; + if ((status = fo.layout(svgArea)).isIncomplete()) { return status; } } @@ -207,20 +208,20 @@ public class SVG extends FObj { if (breakAfter == BreakAfter.PAGE) { this.marker = BREAK_AFTER; - return FORCE_PAGE_BREAK; + return new Status(Status.FORCE_PAGE_BREAK); } if (breakAfter == BreakAfter.ODD_PAGE) { this.marker = BREAK_AFTER; - return FORCE_PAGE_BREAK_ODD; + return new Status(Status.FORCE_PAGE_BREAK_ODD); } if (breakAfter == BreakAfter.EVEN_PAGE) { this.marker = BREAK_AFTER; - return FORCE_PAGE_BREAK_EVEN; + return new Status(Status.FORCE_PAGE_BREAK_EVEN); } /* return status */ - return OK; + return new Status(Status.OK); } } diff --git a/src/org/apache/fop/svg/Text.java b/src/org/apache/fop/svg/Text.java index 6794ce009..db91846fa 100644 --- a/src/org/apache/fop/svg/Text.java +++ b/src/org/apache/fop/svg/Text.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see . */ + package org.apache.fop.svg; // FOP @@ -124,7 +125,7 @@ public class Text extends FObjMixed { * * @return the status of the layout */ - public int layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { /* retrieve properties */ int x = this.properties.get("x").getLength().mvalue(); @@ -140,6 +141,6 @@ public class Text extends FObjMixed { } /* return status */ - return OK; + return new Status(Status.OK); } } -- cgit v1.2.3