diff options
author | Keiron Liddle <keiron@apache.org> | 2002-06-20 09:14:16 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2002-06-20 09:14:16 +0000 |
commit | 7043c9829a66de30102b9a4ea839cc1633aa1db1 (patch) | |
tree | 24f214834a225c5b33e385391b306c0cc17c96dc /src/org/apache/fop/fo | |
parent | 64c1fb1421bb717edda576a916dc7a566967169c (diff) | |
download | xmlgraphics-fop-7043c9829a66de30102b9a4ea839cc1633aa1db1.tar.gz xmlgraphics-fop-7043c9829a66de30102b9a4ea839cc1633aa1db1.zip |
removed old area tree
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194902 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/fo')
49 files changed, 60 insertions, 2551 deletions
diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java index ee0b6ad6a..aa4b601fa 100644 --- a/src/org/apache/fop/fo/FONode.java +++ b/src/org/apache/fop/fo/FONode.java @@ -10,7 +10,6 @@ package org.apache.fop.fo; // FOP import org.apache.fop.apps.FOPException; import org.apache.fop.apps.StructureHandler; -import org.apache.fop.layout.Area; import org.apache.fop.util.CharUtilities; // Avalon @@ -73,18 +72,6 @@ abstract public class FONode { } /** - * generates the area or areas for this formatting object - * and adds these to the area. This method should always be - * overridden by all sub classes - * - * @param area - */ - public Status layout(Area area) throws FOPException { - // should always be overridden - return new Status(Status.OK); - } - - /** * */ protected void start() { diff --git a/src/org/apache/fop/fo/FOText.java b/src/org/apache/fop/fo/FOText.java index 9a54ddf36..16de7a9f9 100644 --- a/src/org/apache/fop/fo/FOText.java +++ b/src/org/apache/fop/fo/FOText.java @@ -8,8 +8,6 @@ package org.apache.fop.fo; // FOP -import org.apache.fop.layout.Area; -import org.apache.fop.layout.BlockArea; import org.apache.fop.layout.FontState; import org.apache.fop.layout.*; import org.apache.fop.datatypes.*; @@ -70,16 +68,6 @@ public class FOText extends FObj { return false; } - // Just to keep PageNumber and PageNumber citation happy for now. - // The real code is moved to TextLayoutManager! - - public static int addText(BlockArea ba, FontState fontState, - float red, float green, float blue, int wrapOption, - LinkSet ls, int whiteSpaceCollapse, char data[], - int start, int end, TextState textState, int vAlign) { - return 0; - } - public void addLayoutManager(List list) { // if nothing left (length=0)? if(length == 0) return; diff --git a/src/org/apache/fop/fo/FOTreeBuilder.java b/src/org/apache/fop/fo/FOTreeBuilder.java index 946007d32..cb8e3ecca 100644 --- a/src/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/org/apache/fop/fo/FOTreeBuilder.java @@ -8,7 +8,6 @@ package org.apache.fop.fo; // FOP -import org.apache.fop.layout.AreaTree; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.StructureHandler; import org.apache.fop.fo.pagination.Root; diff --git a/src/org/apache/fop/fo/FObj.java b/src/org/apache/fop/fo/FObj.java index 7be9fb522..223db278e 100644 --- a/src/org/apache/fop/fo/FObj.java +++ b/src/org/apache/fop/fo/FObj.java @@ -8,15 +8,11 @@ package org.apache.fop.fo; // FOP -import org.apache.fop.layout.Area; import org.apache.fop.layout.AreaClass; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.StructureHandler; import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.fo.properties.FOPropertyMapping; -import org.apache.fop.layout.Area; -import org.apache.fop.layout.AreaClass; -import org.apache.fop.layout.LinkSet; import org.apache.fop.fo.flow.Marker; // Java @@ -67,8 +63,6 @@ public class FObj extends FONode { protected int widows = 0; protected int orphans = 0; - protected LinkSet linkSet; - // count of areas generated-by/returned-by public int areasGenerated = 0; @@ -295,21 +289,6 @@ public class FObj extends FONode { // still to do } - public void setLinkSet(LinkSet linkSet) { - this.linkSet = linkSet; - for (int i = 0; i < this.children.size(); i++) { - Object obj = this.children.get(i); - if (obj instanceof FObj) { - FObj child = (FObj) obj; - child.setLinkSet(linkSet); - } - } - } - - public LinkSet getLinkSet() { - return this.linkSet; - } - /** * At the start of a new span area layout may be partway through a * nested FO, and balancing requires rollback to this known point. diff --git a/src/org/apache/fop/fo/FObjMixed.java b/src/org/apache/fop/fo/FObjMixed.java index a5c136dd6..79fc437ef 100644 --- a/src/org/apache/fop/fo/FObjMixed.java +++ b/src/org/apache/fop/fo/FObjMixed.java @@ -7,7 +7,6 @@ package org.apache.fop.fo; -import org.apache.fop.layout.Area; import org.apache.fop.layout.FontState; import org.apache.fop.layout.FontInfo; import org.apache.fop.apps.FOPException; @@ -63,34 +62,11 @@ public class FObjMixed extends FObj { addChild(ft); } - public Status layout(Area area) throws FOPException { + public void setup() { if (this.properties != null) { setupID(); - if (id != null) { - if (this.marker == START) { - if (area.getIDReferences() != null) - area.getIDReferences().createID(id); - this.marker = 0; - } - - if (this.marker == 0) { - if (area.getIDReferences() != null) - area.getIDReferences().configureID(id, area); - } - } - } - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode) children.get(i); - Status status; - if ((status = fo.layout(area)).isIncomplete()) { - this.marker = i; - return status; - } } - return new Status(Status.OK); } public CharIterator charIterator() { diff --git a/src/org/apache/fop/fo/PropertyManager.java b/src/org/apache/fop/fo/PropertyManager.java index 7a720ff35..71a902539 100644 --- a/src/org/apache/fop/fo/PropertyManager.java +++ b/src/org/apache/fop/fo/PropertyManager.java @@ -35,8 +35,6 @@ import org.apache.fop.layout.HyphenationProps; import org.apache.fop.apps.FOPException; import java.text.MessageFormat; import java.text.FieldPosition; -import org.apache.fop.layout.Area; -import org.apache.fop.layout.ColumnArea; public class PropertyManager { @@ -133,7 +131,7 @@ public class PropertyManager { return hyphProps; } - public int checkBreakBefore(Area area) { + /*public int checkBreakBefore(Area area) { if (!(area instanceof ColumnArea)) { switch (properties.get("break-before").getEnum()) { case BreakBefore.PAGE: @@ -197,7 +195,7 @@ public class PropertyManager { default: return Status.OK; } - } + }*/ public MarginProps getMarginProps() { diff --git a/src/org/apache/fop/fo/Title.java b/src/org/apache/fop/fo/Title.java index b394d84e3..f099fa29f 100644 --- a/src/org/apache/fop/fo/Title.java +++ b/src/org/apache/fop/fo/Title.java @@ -13,7 +13,6 @@ import org.apache.fop.datatypes.*; import org.apache.fop.layout.*; import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.AreaTree; import org.apache.fop.apps.FOPException; /** @@ -24,7 +23,7 @@ public class Title extends ToBeImplementedElement { super(parent); } - public Status layout(Area area) throws FOPException { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -37,7 +36,7 @@ public class Title extends ToBeImplementedElement { BackgroundProps bProps = propMgr.getBackgroundProps(); // Common Font Properties - FontState fontState = propMgr.getFontState(area.getFontInfo()); + //FontState fontState = propMgr.getFontState(structHandler.getFontInfo()); // Common Margin Properties-Inline MarginInlineProps mProps = propMgr.getMarginInlineProps(); @@ -56,6 +55,5 @@ public class Title extends ToBeImplementedElement { int vis = this.properties.get("visibility").getEnum(); Length zIndex = this.properties.get("z-index").getLength(); - return super.layout(area); } } diff --git a/src/org/apache/fop/fo/ToBeImplementedElement.java b/src/org/apache/fop/fo/ToBeImplementedElement.java index d214af8e0..12d83a969 100644 --- a/src/org/apache/fop/fo/ToBeImplementedElement.java +++ b/src/org/apache/fop/fo/ToBeImplementedElement.java @@ -11,7 +11,6 @@ package org.apache.fop.fo; import org.apache.fop.fo.*; import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.Area; import org.apache.fop.apps.FOPException; /** @@ -22,10 +21,9 @@ public class ToBeImplementedElement extends FObj { super(parent); } - public Status layout(Area area) throws FOPException { + public void setup() { log.debug("This element \"" + this.name + "\" is not yet implemented."); - return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/Unknown.java b/src/org/apache/fop/fo/Unknown.java index 9d7c819d6..edaf630a5 100644 --- a/src/org/apache/fop/fo/Unknown.java +++ b/src/org/apache/fop/fo/Unknown.java @@ -12,7 +12,6 @@ import org.apache.fop.fo.*; import org.apache.fop.layout.*; import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.AreaTree; import org.apache.fop.apps.FOPException; /** @@ -33,8 +32,7 @@ public class Unknown extends FONode { super(parent); } - public Status layout(Area area) throws FOPException { + public void setup() { log.debug("Layout Unknown element"); - return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/UnknownXMLObj.java b/src/org/apache/fop/fo/UnknownXMLObj.java index b3ba56a53..abd662910 100644 --- a/src/org/apache/fop/fo/UnknownXMLObj.java +++ b/src/org/apache/fop/fo/UnknownXMLObj.java @@ -8,7 +8,6 @@ package org.apache.fop.fo; import org.apache.fop.fo.*; -import org.apache.fop.layout.Area; import org.apache.fop.layout.FontState; import org.apache.fop.layout.inline.*; import org.apache.fop.apps.FOPException; @@ -59,15 +58,5 @@ public class UnknownXMLObj extends XMLObj { super.addCharacters(data, start, length); } - public Status layout(Area area) throws FOPException { - if(!"".equals(this.namespace)) { - log.error("no handler defined for " + this.namespace + ":" + this.name + " foreign xml"); - } else { - log.error("no handler defined for (none):" + this.name + " foreign xml"); - } - - /* return status */ - return new Status(Status.OK); - } } diff --git a/src/org/apache/fop/fo/XMLElement.java b/src/org/apache/fop/fo/XMLElement.java index f852601c8..47ba344cf 100644 --- a/src/org/apache/fop/fo/XMLElement.java +++ b/src/org/apache/fop/fo/XMLElement.java @@ -9,8 +9,6 @@ package org.apache.fop.fo; // FOP import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.Area; -import org.apache.fop.layout.inline.*; import org.apache.fop.apps.FOPException; import org.xml.sax.Attributes; @@ -36,24 +34,6 @@ public class XMLElement extends XMLObj { init(); } - /** - * layout this formatting object. - * - * @param area the area to layout the object into - * - * @return the status of the layout - */ - public Status layout(final Area area) throws FOPException { - - if (!(area instanceof ForeignObjectArea)) { - // this is an error - throw new FOPException("XML not in fo:instream-foreign-object"); - } - - /* return status */ - return new Status(Status.OK); - } - private void init() { createBasicDocument(); } diff --git a/src/org/apache/fop/fo/XMLObj.java b/src/org/apache/fop/fo/XMLObj.java index 17cf7dfbe..b356d6849 100644 --- a/src/org/apache/fop/fo/XMLObj.java +++ b/src/org/apache/fop/fo/XMLObj.java @@ -9,10 +9,8 @@ package org.apache.fop.fo; // FOP import org.apache.fop.fo.*; -import org.apache.fop.layout.Area; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; -import org.apache.fop.layout.LinkSet; import org.apache.fop.datatypes.IDReferences; import org.w3c.dom.*; @@ -151,18 +149,5 @@ public abstract class XMLObj extends FONode { element.appendChild(text); } - /** - * layout this formatting object. - * - * @param area the area to layout the object into - * @return the status of the layout - */ - public Status layout(Area area) throws FOPException { - /* generate a warning */ - log.warn("" + this.name + " outside foreign xml"); - - /* return status */ - return new Status(Status.OK); - } } diff --git a/src/org/apache/fop/fo/flow/BasicLink.java b/src/org/apache/fop/fo/flow/BasicLink.java index d929a85e1..fb66c9733 100644 --- a/src/org/apache/fop/fo/flow/BasicLink.java +++ b/src/org/apache/fop/fo/flow/BasicLink.java @@ -30,7 +30,7 @@ public class BasicLink extends Inline { super.addLayoutManager(lms); } - public Status layout(Area area) throws FOPException { + public void setup() { String destination; int linkType; @@ -69,56 +69,6 @@ public class BasicLink extends Inline { // this.properties.get("target-presentation-context"); // this.properties.get("target-stylesheet"); - if (!(destination = - this.properties.get("internal-destination").getString()).equals("")) { - linkType = LinkSet.INTERNAL; - } else if (!(destination = - this.properties.get("external-destination").getString()).equals("")) { - linkType = LinkSet.EXTERNAL; - } else { - throw new FOPException("internal-destination or external-destination must be specified in basic-link"); - } - - if (this.marker == START) { - // initialize id - area.getIDReferences().initializeID(id, area); - this.marker = 0; - } - - // new LinkedArea to gather up inlines - LinkSet ls = new LinkSet(destination, area, linkType); - - Page p = area.getPage(); - - AreaContainer ac = p.getBody().getCurrentColumnArea(); - if (ac == null) { - throw new FOPException("Couldn't get ancestor AreaContainer when processing basic-link"); - } - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.get(i); - if(fo instanceof FObj) - ((FObj)fo).setLinkSet(ls); - - Status status; - if ((status = fo.layout(area)).isIncomplete()) { - this.marker = i; - return status; - } - } - - ls.applyAreaContainerOffsets(ac, area); - - // pass on command line - String mergeLinks = System.getProperty("links.merge"); - if ((null != mergeLinks) &&!mergeLinks.equalsIgnoreCase("no")) { - ls.mergeLinks(); - } - - p.addLinkSet(ls); - - return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/flow/BidiOverride.java b/src/org/apache/fop/fo/flow/BidiOverride.java index 7df4552d3..f9a8b661b 100644 --- a/src/org/apache/fop/fo/flow/BidiOverride.java +++ b/src/org/apache/fop/fo/flow/BidiOverride.java @@ -13,7 +13,6 @@ import org.apache.fop.layout.AuralProps; import org.apache.fop.layout.RelativePositionProps; import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.AreaTree; import org.apache.fop.apps.FOPException; import org.apache.fop.layoutmgr.LeafNodeLayoutManager; diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index b4aedb727..208b0f6d8 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -90,17 +90,7 @@ public class Block extends FObjMixed { structHandler.startBlock(this); } - public Status layout(Area area) throws FOPException { - BlockArea blockArea; - - // log.error(" b:LAY[" + marker + "] "); - - - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -132,7 +122,7 @@ public class Block extends FObjMixed { // this.properties.get("text-altitude"); // this.properties.get("hyphenation-keep"); // this.properties.get("hyphenation-ladder-count"); - // this.properties.get("id"); + setupID(); // this.properties.get("keep-together"); // this.properties.get("keep-with-next"); // this.properties.get("keep-with-previous"); @@ -179,185 +169,6 @@ public class Block extends FObjMixed { this.blockOrphans = this.properties.get("orphans").getNumber().intValue(); - this.id = this.properties.get("id").getString(); - - if (area instanceof BlockArea) { - area.end(); - } - - if (area.getIDReferences() != null) - area.getIDReferences().createID(id); - - this.marker = 0; - - // no break if first in area tree, or leading in context - // area - int breakBeforeStatus = propMgr.checkBreakBefore(area); - if (breakBeforeStatus != Status.OK) { - return new Status(breakBeforeStatus); - } - - int numChildren = this.children.size(); - for (int i = 0; i < numChildren; i++) { - FONode fo = (FONode) children.get(i); - if (fo instanceof FOText) { - if (((FOText) fo).willCreateArea()) { - //fo.setWidows(blockWidows); - break; - } else { - children.remove(i); - numChildren = this.children.size(); - i--; - } - } else { - //fo.setWidows(blockWidows); - break; - } - } - - for (int i = numChildren - 1; i >= 0; i--) { - FONode fo = (FONode) children.get(i); - if (fo instanceof FOText) { - if (((FOText) fo).willCreateArea()) { - //fo.setOrphans(blockOrphans); - break; - } - } else { - //fo.setOrphans(blockOrphans); - break; - } - } - } - - if ((spaceBefore != 0) && (this.marker == 0)) { - area.addDisplaySpace(spaceBefore); - } - - if (anythingLaidOut) { - this.textIndent = 0; - } - - if (marker == 0 && area.getIDReferences() != null) { - area.getIDReferences().configureID(id, area); - } - - int spaceLeft = area.spaceLeft(); - blockArea = new BlockArea( propMgr.getFontState(area.getFontInfo()), - area.getAllocationWidth(), area.spaceLeft(), - startIndent, endIndent, textIndent, align, alignLast, - lineHeight); - blockArea.setGeneratedBy(this); - this.areasGenerated++; - if (this.areasGenerated == 1) - blockArea.isFirst(true); - // for normal areas this should be the only pair - blockArea.addLineagePair(this, this.areasGenerated); - - // markers - //if (this.hasMarkers()) - //blockArea.addMarkers(this.getMarkers()); - - blockArea.setParent(area); // BasicLink needs it - blockArea.setPage(area.getPage()); - blockArea.setBackgroundColor(backgroundColor); - blockArea.setBorderAndPadding(propMgr.getBorderAndPadding()); - blockArea.setHyphenation(propMgr.getHyphenationProps()); - blockArea.start(); - - blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); - blockArea.setIDReferences(area.getIDReferences()); - - blockArea.setTableCellXOffset(area.getTableCellXOffset()); - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode) children.get(i); - Status status; - if ((status = fo.layout(blockArea)).isIncomplete()) { - this.marker = i; - // this block was modified by - // Hani Elabed 11/27/2000 - // if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) - // { - // status = new Status(Status.AREA_FULL_SOME); - // } - - // new block to replace the one above - // Hani Elabed 11/27/2000 - if (status.getCode() == Status.AREA_FULL_NONE) { - // something has already been laid out - if ((i != 0)) { - status = new Status(Status.AREA_FULL_SOME); - area.addChild(blockArea); - area.setMaxHeight(area.getMaxHeight() - - spaceLeft + blockArea.getMaxHeight()); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight( - blockArea.getAbsoluteHeight()); - anythingLaidOut = true; - - return status; - } else // i == 0 nothing was laid out.. - { - anythingLaidOut = false; - return status; - } - } - - // blockArea.end(); - area.addChild(blockArea); - area.setMaxHeight(area.getMaxHeight() - spaceLeft + - blockArea.getMaxHeight()); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - anythingLaidOut = true; - return status; - } - anythingLaidOut = true; - } - - blockArea.end(); - - area.setMaxHeight(area.getMaxHeight() - spaceLeft + - blockArea.getMaxHeight()); - - area.addChild(blockArea); - - /* should this be combined into above? */ - area.increaseHeight(blockArea.getHeight()); - - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - - if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); - } - - if (area instanceof BlockArea) { - area.start(); - } - // This is not needed any more and it consumes a LOT - // of memory. So we release it for the GC. - areaHeight = blockArea.getHeight(); - contentWidth = blockArea.getContentWidth(); - - // no break if last in area tree, or trailing in context - // area - int breakAfterStatus = propMgr.checkBreakAfter(area); - if (breakAfterStatus != Status.OK) { - this.marker = BREAK_AFTER; - blockArea = null; //Faster GC - BlockArea is big - return new Status(breakAfterStatus); - } - - if (keepWithNext != 0) { - blockArea = null; // Faster GC - BlockArea is big - return new Status(Status.KEEP_WITH_NEXT); - } - - // log.error(" b:OK" + marker + " "); - blockArea.isLast(true); - blockArea = null; // Faster GC - BlockArea is big - return new Status(Status.OK); } public int getAreaHeight() { diff --git a/src/org/apache/fop/fo/flow/BlockContainer.java b/src/org/apache/fop/fo/flow/BlockContainer.java index 054f848da..6bd81f1e0 100644 --- a/src/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/org/apache/fop/fo/flow/BlockContainer.java @@ -32,10 +32,6 @@ public class BlockContainer extends FObj { int span; - AreaContainer areaContainer; - - PageSequence pageSequence; - public BlockContainer(FONode parent) { super(parent); } @@ -46,8 +42,7 @@ public class BlockContainer extends FObj { setupID(); } - public Status layout(Area area) throws FOPException { - if (this.marker == START) { + public void setup() { // Common Accessibility Properties AbsolutePositionProps mAbsProps = propMgr.getAbsolutePositionProps(); @@ -65,7 +60,7 @@ public class BlockContainer extends FObj { // this.properties.get("clip"); // this.properties.get("display-align"); // this.properties.get("height"); - // this.properties.get("id"); + setupID(); // this.properties.get("keep-together"); // this.properties.get("keep-with-next"); // this.properties.get("keep-with-previous"); @@ -89,76 +84,6 @@ public class BlockContainer extends FObj { this.height = this.properties.get("height").getLength().mvalue(); span = this.properties.get("span").getEnum(); - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id, area); - } - - boolean prevChildMustKeepWithNext = false; - - AreaContainer container = (AreaContainer)area; - if ((this.width == 0) && (this.height == 0)) { - width = right - left; - height = bottom - top; - } - - this.areaContainer = - new AreaContainer(propMgr.getFontState(container.getFontInfo()), - container.getXPosition() + left, - container.getYPosition() - top, width, height, - position); - - areaContainer.setPage(area.getPage()); - areaContainer.setBackgroundColor(backgroundColor); - areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding()); - areaContainer.start(); - - areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); - areaContainer.setIDReferences(area.getIDReferences()); - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FObj fo = (FObj)children.get(i); - Status status; - if ((status = fo.layout(areaContainer)).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; - } - } - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - - areaContainer.end(); - if (position == Position.ABSOLUTE) - areaContainer.setHeight(height); - area.addChild(areaContainer); - - return new Status(Status.OK); - } - - /** - * Return the content width of the boxes generated by this block - * container FO. - */ - public int getContentWidth() { - if (areaContainer != null) - return areaContainer.getContentWidth(); // getAllocationWidth()?? - else - return 0; // not laid out yet } public boolean generatesReferenceAreas() { diff --git a/src/org/apache/fop/fo/flow/ExternalGraphic.java b/src/org/apache/fop/fo/flow/ExternalGraphic.java index ca8fe5edc..7ba5e05d6 100644 --- a/src/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/org/apache/fop/fo/flow/ExternalGraphic.java @@ -16,6 +16,7 @@ import org.apache.fop.image.*; import org.apache.fop.area.inline.InlineArea; import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.LeafNodeLayoutManager; +import org.apache.fop.layoutmgr.LayoutInfo; import org.apache.fop.area.inline.Image; import org.apache.fop.area.inline.Viewport; @@ -36,7 +37,6 @@ public class ExternalGraphic extends FObj { String src; int height; int width; - String id; public ExternalGraphic(FONode parent) { super(parent); @@ -57,14 +57,24 @@ public class ExternalGraphic extends FObj { // if we need to load this image to get its size ImageFactory fact = ImageFactory.getInstance(); FopImage fopimage = fact.getImage(url, userAgent); - // if(fopimage == null) { - // error - // } - // if(!fopimage.load(FopImage.DIMENSIONS)) { - // error - // } + if(fopimage == null) { + // error + return null; + } + // load dimensions + if(!fopimage.load(FopImage.DIMENSIONS, userAgent)) { + // error + return null; + } Image imArea = new Image(url); Viewport vp = new Viewport(imArea); + vp.setWidth((int)fopimage.getWidth() * 1000); + vp.setHeight((int)fopimage.getHeight() * 1000); + vp.setOffset(0); + vp.info = new LayoutInfo(); + vp.info.alignment = properties.get("vertical-align").getEnum(); + vp.info.lead = vp.getHeight(); + return vp; } diff --git a/src/org/apache/fop/fo/flow/Float.java b/src/org/apache/fop/fo/flow/Float.java index fd85bcc3f..7b48cc16b 100644 --- a/src/org/apache/fop/fo/flow/Float.java +++ b/src/org/apache/fop/fo/flow/Float.java @@ -23,11 +23,10 @@ public class Float extends ToBeImplementedElement { this.name = "fo:float"; } - public Status layout(Area area) throws FOPException { + public void setup() { // this.properties.get("float"); // this.properties.get("clear"); - return super.layout(area); } } diff --git a/src/org/apache/fop/fo/flow/Flow.java b/src/org/apache/fop/fo/flow/Flow.java index b2583c0a8..50ea4c2da 100644 --- a/src/org/apache/fop/fo/flow/Flow.java +++ b/src/org/apache/fop/fo/flow/Flow.java @@ -11,8 +11,6 @@ package org.apache.fop.fo.flow; import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.fo.pagination.*; -import org.apache.fop.layout.Area; -import org.apache.fop.layout.BodyAreaContainer; import org.apache.fop.apps.FOPException; import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.FlowLayoutManager; @@ -31,11 +29,6 @@ public class Flow extends FObj { private PageSequence pageSequence; /** - * Area in which we lay out our kids - */ - private Area area; - - /** * ArrayList to store snapshot */ private ArrayList markerSnapshot; @@ -50,8 +43,6 @@ public class Flow extends FObj { */ private int contentWidth; - private Status _status = new Status(Status.AREA_FULL_NONE); - public Flow(FONode parent) { super(parent); @@ -104,105 +95,6 @@ public class Flow extends FObj { 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; - } - - // flow is *always* laid out into a BodyAreaContainer - BodyAreaContainer bac = (BodyAreaContainer) area; - - boolean prevChildMustKeepWithNext = false; - ArrayList pageMarker = this.getMarkerSnapshot(new ArrayList()); - - int numChildren = this.children.size(); - if (numChildren == 0) { - throw new FOPException("fo:flow must contain block-level children"); - } - for (int i = this.marker; i < numChildren; i++) { - FObj fo = (FObj) children.get(i); - - if (bac.isBalancingRequired(fo)) { - // reset the the just-done span area in preparation - // for a backtrack for balancing - bac.resetSpanArea(); - - this.rollback(markerSnapshot); - // one less because of the "continue" - i = this.marker - 1; - continue; - } - // current column area - Area currentArea = bac.getNextArea(fo); - // temporary hack for IDReferences - currentArea.setIDReferences(bac.getIDReferences()); - if (bac.isNewSpanArea()) { - this.marker = i; - markerSnapshot = this.getMarkerSnapshot(new ArrayList()); - } - // Set current content width for percent-based lengths in children - setContentWidth(currentArea.getContentWidth()); - - _status = fo.layout(currentArea); - - /* - * if((_status.isPageBreak() || i == numChildren - 1) && bac.needsFootnoteAdjusting()) { - * bac.adjustFootnoteArea(); - * this.rollback(pageMarker); - * i = this.marker - 1; - * Area mainReferenceArea = bac.getMainReferenceArea(); - * // remove areas - * continue; - * } - */ - if (_status.isIncomplete()) { - if ((prevChildMustKeepWithNext) && - (_status.laidOutNone())) { - this.marker = i - 1; - FObj prevChild = (FObj) children.get(this.marker); - prevChild.removeAreas(); - prevChild.resetMarker(); - _status = new Status(Status.AREA_FULL_SOME); - return _status; - // should probably return AREA_FULL_NONE if first - // or perhaps an entirely new status code - } - if (bac.isLastColumn()) - if (_status.getCode() == Status.FORCE_COLUMN_BREAK) { - this.marker = i; - _status = new Status(Status.FORCE_PAGE_BREAK); - // same thing - return _status; - } else { - this.marker = i; - return _status; - } - else { - // not the last column, but could be page breaks - if (_status.isPageBreak()) { - this.marker = i; - return _status; - } - // I don't much like exposing this. (AHS 001217) - ((org.apache.fop.layout.ColumnArea) currentArea). - incrementSpanIndex(); - i--; - } - } - if (_status.getCode() == Status.KEEP_WITH_NEXT) { - prevChildMustKeepWithNext = true; - } else { - prevChildMustKeepWithNext = false; - } - } - return _status; - } - protected void setContentWidth(int contentWidth) { this.contentWidth = contentWidth; } @@ -214,10 +106,6 @@ public class Flow extends FObj { return this.contentWidth; } - public Status getStatus() { - return _status; - } - public boolean generatesReferenceAreas() { return true; } diff --git a/src/org/apache/fop/fo/flow/Footnote.java b/src/org/apache/fop/fo/flow/Footnote.java index 103e6665c..9ab5e13e2 100644 --- a/src/org/apache/fop/fo/flow/Footnote.java +++ b/src/org/apache/fop/fo/flow/Footnote.java @@ -33,87 +33,5 @@ public class Footnote extends FObj { // set start and end footnote reference } - - public Status layout(Area area) throws FOPException { - FONode inline = null; - FONode fbody = null; - if (this.marker == START) { - this.marker = 0; - } - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.get(i); - if (fo instanceof Inline) { - inline = fo; - Status status = fo.layout(area); - if (status.isIncomplete()) { - return status; - } - } else if (inline != null && fo instanceof FootnoteBody) { - // add footnote to current page or next if it can't fit - fbody = fo; - if (area instanceof BlockArea) { - ((BlockArea)area).addFootnote((FootnoteBody)fbody); - } else { - Page page = area.getPage(); - layoutFootnote(page, (FootnoteBody)fbody, area); - } - } - } - if (fbody == null) { - log.error("no footnote-body in footnote"); - } - if (area instanceof BlockArea) {} - return new Status(Status.OK); - } - - public static boolean layoutFootnote(Page p, FootnoteBody fb, Area area) { - try { - BodyAreaContainer bac = p.getBody(); - AreaContainer footArea = bac.getFootnoteReferenceArea(); - footArea.setIDReferences(bac.getIDReferences()); - int basePos = footArea.getCurrentYPosition() - - footArea.getHeight(); - int oldHeight = footArea.getHeight(); - if (area != null) { - footArea.setMaxHeight(area.getMaxHeight() - area.getHeight() - + footArea.getHeight()); - } else { - footArea.setMaxHeight(bac.getMaxHeight() - + footArea.getHeight()); - } - Status status = fb.layout(footArea); - if (status.isIncomplete()) { - // add as a pending footnote - return false; - } else { - if (area != null) { - area.setMaxHeight(area.getMaxHeight() - - footArea.getHeight() + oldHeight); - } - // bac.setMaxHeight(bac.getMaxHeight() - footArea.getHeight() + oldHeight); - if (bac.getFootnoteState() == 0) { - Area ar = bac.getMainReferenceArea(); - //decreaseMaxHeight(ar, footArea.getHeight() - oldHeight); - footArea.setYPosition(basePos + footArea.getHeight()); - } - } - } catch (FOPException fope) { - return false; - } - return true; - } - -/* protected static void decreaseMaxHeight(Area ar, int change) { - ar.setMaxHeight(ar.getMaxHeight() - change); - ArrayList childs = ar.getChildren(); - for (Iterator en = childs.iterator(); en.hasNext(); ) { - Object obj = en.next(); - if (obj instanceof Area) { - Area childArea = (Area)obj; - decreaseMaxHeight(childArea, change); - } - } - } -*/ } + diff --git a/src/org/apache/fop/fo/flow/FootnoteBody.java b/src/org/apache/fop/fo/flow/FootnoteBody.java index ef560ab45..2a6e798cf 100644 --- a/src/org/apache/fop/fo/flow/FootnoteBody.java +++ b/src/org/apache/fop/fo/flow/FootnoteBody.java @@ -9,7 +9,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; -import org.apache.fop.layout.Area; import org.apache.fop.layout.AreaClass; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.*; @@ -31,40 +30,4 @@ public class FootnoteBody extends FObj { super(parent); } - public Status layout(Area area) throws FOPException { - this.areaClass = AreaClass.setAreaClass(AreaClass.XSL_FOOTNOTE); - if (this.marker == START) { - this.marker = 0; - } - BlockArea blockArea = - new BlockArea(propMgr.getFontState(area.getFontInfo()), - area.getAllocationWidth(), area.spaceLeft(), - startIndent, endIndent, textIndent, align, - alignLast, lineHeight); - blockArea.setGeneratedBy(this); - blockArea.isFirst(true); - blockArea.setPage(area.getPage()); - blockArea.start(); - - blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); - blockArea.setIDReferences(area.getIDReferences()); - - blockArea.setTableCellXOffset(area.getTableCellXOffset()); - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.get(i); - Status status; - if ((status = fo.layout(blockArea)).isIncomplete()) { - this.resetMarker(); - return status; - } - } - blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - blockArea.isLast(true); - return new Status(Status.OK); - } - } diff --git a/src/org/apache/fop/fo/flow/InitialPropertySet.java b/src/org/apache/fop/fo/flow/InitialPropertySet.java index dee6c2ac8..1bc599bb0 100644 --- a/src/org/apache/fop/fo/flow/InitialPropertySet.java +++ b/src/org/apache/fop/fo/flow/InitialPropertySet.java @@ -12,7 +12,6 @@ import org.apache.fop.fo.*; import org.apache.fop.layout.*; import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.AreaTree; import org.apache.fop.apps.FOPException; /** @@ -23,7 +22,7 @@ public class InitialPropertySet extends ToBeImplementedElement { super(parent); } - public Status layout(Area area) throws FOPException { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -52,6 +51,5 @@ public class InitialPropertySet extends ToBeImplementedElement { // this.properties.get("text-transform"); // this.properties.get("word-spacing"); - return super.layout(area); } } diff --git a/src/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/org/apache/fop/fo/flow/InstreamForeignObject.java index 95532dd35..91797175b 100644 --- a/src/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -149,20 +149,7 @@ public class InstreamForeignObject extends FObj { return true; } - /** - * layout this formatting object. - * - * @param area the area to layout the object into - * - * @return the status of the layout - * - public Status layout(Area area) throws FOPException { - - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { + /* // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -233,135 +220,5 @@ public class InstreamForeignObject extends FObj { this.scaling = this.properties.get("scaling").getEnum(); - area.getIDReferences().createID(id); - if (this.areaCurrent == null) { - this.areaCurrent = - new ForeignObjectArea(propMgr.getFontState(area.getFontInfo()), - area.getAllocationWidth()); - - this.areaCurrent.start(); - areaCurrent.setWidth(this.width); - areaCurrent.setHeight(this.height); - areaCurrent.setContentWidth(this.contwidth); - areaCurrent.setContentHeight(this.contheight); - areaCurrent.setScaling(this.scaling); - areaCurrent.setAlign(align); - areaCurrent.setVerticalAlign(valign); - areaCurrent.setOverflow(overflow); - areaCurrent.setSizeAuto(wauto, hauto); - areaCurrent.setContentSizeAuto(cwauto, chauto); - - // this means that children can get the fontstate - areaCurrent.setPage(area.getPage()); - - int numChildren = this.children.size(); - if (numChildren > 1) { - throw new FOPException("Only one child element is allowed in an instream-foreign-object"); - } - /* layout foreign object * - if (this.children.size() > 0) { - FONode fo = (FONode)children.get(0); - Status status; - if ((status = - fo.layout(this.areaCurrent)).isIncomplete()) { - return status; - } - - /* finish off the foreign object area * - this.areaCurrent.end(); - } - } - - this.marker = 0; - - if (breakBefore == BreakBefore.PAGE - || ((spaceBefore + areaCurrent.getEffectiveHeight()) - > area.spaceLeft())) { - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakBefore == BreakBefore.ODD_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakBefore == BreakBefore.EVEN_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - } - - if (this.areaCurrent == null) { - return new Status(Status.OK); - } - - if (area instanceof BlockArea) { - BlockArea ba = (BlockArea)area; - LineArea la = ba.getCurrentLineArea(); - if (la == null) { - return new Status(Status.AREA_FULL_NONE); - } - la.addPending(); - if (areaCurrent.getEffectiveWidth() > la.getRemainingWidth()) { - la = ba.createNextLineArea(); - if (la == null) { - return new Status(Status.AREA_FULL_NONE); - } - } - la.addInlineArea(areaCurrent); - } else { - area.addChild(areaCurrent); - area.increaseHeight(areaCurrent.getEffectiveHeight()); - } - - if (this.isInTableCell) { - startIndent += forcedStartOffset; - /* - * endIndent = areaCurrent.getEffectiveWidth() - forcedWidth - - * forcedStartOffset; - * - } - - areaCurrent.setStartIndent(startIndent); - // areaCurrent.setEndIndent(endIndent); - - /* if there is a space-before * - if (spaceBefore != 0) { - /* add a display space * - // area.addDisplaySpace(spaceBefore); - } - - /* add the SVG area to the containing area * - // area.addChild(areaCurrent); - - areaCurrent.setPage(area.getPage()); - - /* increase the height of the containing area accordingly * - // area.increaseHeight(areaCurrent.getEffectiveHeight()); - - /* if there is a space-after * - if (spaceAfter != 0) { - /* add a display space * - // area.addDisplaySpace(spaceAfter); - } - - - if (breakAfter == BreakAfter.PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakAfter == BreakAfter.ODD_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakAfter == BreakAfter.EVEN_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - - areaCurrent = null; - /* return status * - return new Status(Status.OK); - } */ } diff --git a/src/org/apache/fop/fo/flow/Leader.java b/src/org/apache/fop/fo/flow/Leader.java index 1cbe2bdf5..5e5c4e49f 100644 --- a/src/org/apache/fop/fo/flow/Leader.java +++ b/src/org/apache/fop/fo/flow/Leader.java @@ -13,9 +13,6 @@ import org.apache.fop.fo.properties.*; import org.apache.fop.datatypes.*; import org.apache.fop.area.inline.InlineArea; import org.apache.fop.layout.*; -import org.apache.fop.layout.BlockArea; -import org.apache.fop.layout.inline.LeaderArea; -import org.apache.fop.layout.LineArea; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; import org.apache.fop.layoutmgr.LayoutManager; @@ -53,15 +50,7 @@ public class Leader extends FObjMixed { return leader; } - public Status layout(Area area) throws FOPException { - BlockArea blockArea; - // restriction in this version - if (!(area instanceof BlockArea)) { - log.warn("in this version of Fop fo:leader must be a direct child of fo:block "); - return new Status(Status.OK); - } else { - blockArea = (BlockArea)area; - } + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -121,8 +110,8 @@ public class Leader extends FObjMixed { Length maxlength = this.properties.get("leader-length.maximum").getLength(); int leaderLengthMaximum; if(maxlength instanceof PercentLength) { - leaderLengthMaximum = (int)(((PercentLength)maxlength).value() - * area.getAllocationWidth()); + //leaderLengthMaximum = (int)(((PercentLength)maxlength).value() + // * area.getAllocationWidth()); } else { leaderLengthMaximum = maxlength.mvalue(); } @@ -136,23 +125,6 @@ public class Leader extends FObjMixed { int leaderAlignment = this.properties.get("leader-alignment").getEnum(); - // initialize id - blockArea.getIDReferences().initializeID(id, blockArea); - - // adds leader to blockarea, there the leaderArea is generated - int succeeded = addLeader(blockArea, - propMgr.getFontState(area.getFontInfo()), - red, green, blue, leaderPattern, - leaderLengthMinimum, leaderLengthOptimum, - leaderLengthMaximum, ruleThickness, - ruleStyle, leaderPatternWidth, - leaderAlignment); - if (succeeded == 1) { - return new Status(Status.OK); - } else { - // not sure that this is the correct Status here - return new Status(Status.AREA_FULL_SOME); - } } /* @@ -164,64 +136,5 @@ public class Leader extends FObjMixed { * } */ - - /** - * adds a leader to current line area of containing block area - * the actual leader area is created in the line area - * - * @return int +1 for success and -1 for none - */ - public int addLeader(BlockArea ba, FontState fontState, float red, - float green, float blue, int leaderPattern, - int leaderLengthMinimum, int leaderLengthOptimum, - int leaderLengthMaximum, int ruleThickness, - int ruleStyle, int leaderPatternWidth, - int leaderAlignment) { - - LineArea la = ba.getCurrentLineArea(); - // this should start a new page - if (la == null) { - return -1; - } - - la.changeFont(fontState); - la.changeColor(red, green, blue); - - // check whether leader fits into the (rest of the) line - // using length.optimum to determine where to break the line as defined - // in the xsl:fo spec: "User agents may choose to use the value of 'leader-length.optimum' - // to determine where to break the line" (7.20.4) - // if leader is longer then create a new LineArea and put leader there - if (leaderLengthOptimum <= (la.getRemainingWidth())) { - la.addLeader(leaderPattern, leaderLengthMinimum, - leaderLengthOptimum, leaderLengthMaximum, ruleStyle, - ruleThickness, leaderPatternWidth, leaderAlignment); - } else { - la = ba.createNextLineArea(); - if (la == null) { - // not enough room - return -1; - } - la.changeFont(fontState); - la.changeColor(red, green, blue); - - // check whether leader fits into LineArea at all, otherwise - // clip it (should honor the clip option of containing area) - if (leaderLengthMinimum <= la.getContentWidth()) { - la.addLeader(leaderPattern, leaderLengthMinimum, - leaderLengthOptimum, leaderLengthMaximum, - ruleStyle, ruleThickness, leaderPatternWidth, - leaderAlignment); - } else { - log.error("Leader doesn't fit into line, it will be clipped to fit."); - la.addLeader(leaderPattern, la.getRemainingWidth(), - leaderLengthOptimum, leaderLengthMaximum, - ruleStyle, ruleThickness, leaderPatternWidth, - leaderAlignment); - } - } - // this.hasLines = true; - return 1; - } } diff --git a/src/org/apache/fop/fo/flow/ListBlock.java b/src/org/apache/fop/fo/flow/ListBlock.java index 59393c06f..56fb2f49d 100644 --- a/src/org/apache/fop/fo/flow/ListBlock.java +++ b/src/org/apache/fop/fo/flow/ListBlock.java @@ -12,7 +12,6 @@ import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.datatypes.*; import org.apache.fop.layout.*; -import org.apache.fop.layout.BlockArea; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; @@ -37,8 +36,7 @@ public class ListBlock extends FObj { super(parent); } - public Status layout(Area area) throws FOPException { - if (this.marker == START) { + public void setup() throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -81,86 +79,6 @@ public class ListBlock extends FObj { this.backgroundColor = this.properties.get("background-color").getColorType(); - this.marker = 0; - - if (area instanceof BlockArea) { - area.end(); - } - - if (spaceBefore != 0) { - area.addDisplaySpace(spaceBefore); - } - - if (this.isInTableCell) { - startIndent += forcedStartOffset; - endIndent += area.getAllocationWidth() - forcedWidth - - forcedStartOffset; - } - - // initialize id - area.getIDReferences().initializeID(id, area); - } - - BlockArea blockArea = - new BlockArea(propMgr.getFontState(area.getFontInfo()), - area.getAllocationWidth(), area.spaceLeft(), - startIndent, endIndent, 0, align, alignLast, - lineHeight); - blockArea.setGeneratedBy(this); - this.areasGenerated++; - if (this.areasGenerated == 1) - blockArea.isFirst(true); - // for normal areas this should be the only pair - blockArea.addLineagePair(this, this.areasGenerated); - - // markers - //if (this.hasMarkers()) - //blockArea.addMarkers(this.getMarkers()); - - - blockArea.setPage(area.getPage()); - blockArea.setBackgroundColor(backgroundColor); - blockArea.start(); - - blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); - blockArea.setIDReferences(area.getIDReferences()); - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - if (!(children.get(i) instanceof ListItem)) { - log.error("children of list-blocks must be list-items"); - return new Status(Status.OK); - } - ListItem listItem = (ListItem)children.get(i); - Status status; - if ((status = listItem.layout(blockArea)).isIncomplete()) { - if (status.getCode() == Status.AREA_FULL_NONE && i > 0) { - status = new Status(Status.AREA_FULL_SOME); - } - this.marker = i; - blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - return status; - } - } - - blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - - if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); - } - - if (area instanceof BlockArea) { - area.start(); - } - - blockArea.isLast(true); - return new Status(Status.OK); } public boolean generatesInlineAreas() { diff --git a/src/org/apache/fop/fo/flow/ListItem.java b/src/org/apache/fop/fo/flow/ListItem.java index 13363f497..01304bced 100644 --- a/src/org/apache/fop/fo/flow/ListItem.java +++ b/src/org/apache/fop/fo/flow/ListItem.java @@ -11,7 +11,6 @@ package org.apache.fop.fo.flow; import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; -import org.apache.fop.layout.BlockArea; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; @@ -29,14 +28,12 @@ public class ListItem extends FObj { int endIndent; int spaceBefore; int spaceAfter; - BlockArea blockArea; public ListItem(FONode parent) { super(parent); } - public Status layout(Area area) throws FOPException { - if (this.marker == START) { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -71,98 +68,6 @@ public class ListItem extends FObj { this.spaceAfter = this.properties.get("space-after.optimum").getLength().mvalue(); - area.getIDReferences().createID(id); - - this.marker = 0; - } - - /* not sure this is needed given we know area is from list block */ - if (area instanceof BlockArea) { - area.end(); - } - - if (spaceBefore != 0) { - area.addDisplaySpace(spaceBefore); - } - - this.blockArea = - new BlockArea(propMgr.getFontState(area.getFontInfo()), - area.getAllocationWidth(), area.spaceLeft(), 0, 0, - 0, align, alignLast, lineHeight); - this.blockArea.setGeneratedBy(this); - this.areasGenerated++; - if (this.areasGenerated == 1) - this.blockArea.isFirst(true); - // for normal areas this should be the only pair - this.blockArea.addLineagePair(this, this.areasGenerated); - - // markers - //if (this.hasMarkers()) - //this.blockArea.addMarkers(this.getMarkers()); - - blockArea.setPage(area.getPage()); - blockArea.start(); - - blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); - blockArea.setIDReferences(area.getIDReferences()); - - int numChildren = this.children.size(); - if (numChildren != 2) { - throw new FOPException("list-item must have exactly two children"); - } - ListItemLabel label = (ListItemLabel)children.get(0); - ListItemBody body = (ListItemBody)children.get(1); - - 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) { - // configure id - area.getIDReferences().configureID(id, area); - - status = label.layout(blockArea); - if (status.isIncomplete()) { - return status; - } - } - - status = body.layout(blockArea); - if (status.isIncomplete()) { - blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - this.marker = 1; - return status; - } - - blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - - if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); - } - - /* not sure this is needed given we know area is from list block */ - if (area instanceof BlockArea) { - area.start(); - } - this.blockArea.isLast(true); - return new Status(Status.OK); - } - - /** - * Return the content width of the boxes generated by this FO. - */ - public int getContentWidth() { - if (blockArea != null) - return blockArea.getContentWidth(); // getAllocationWidth()?? - else - return 0; // not laid out yet } public boolean generatesInlineAreas() { diff --git a/src/org/apache/fop/fo/flow/ListItemBody.java b/src/org/apache/fop/fo/flow/ListItemBody.java index 7a59d523d..d27046e0b 100644 --- a/src/org/apache/fop/fo/flow/ListItemBody.java +++ b/src/org/apache/fop/fo/flow/ListItemBody.java @@ -23,8 +23,7 @@ public class ListItemBody extends FObj { super(parent); } - public Status layout(Area area) throws FOPException { - if (this.marker == START) { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -32,11 +31,6 @@ public class ListItemBody extends FObj { setupID(); // this.properties.get("keep-together"); - this.marker = 0; - // initialize id - area.getIDReferences().initializeID(id, area); - } - /* * For calculating the lineage - The fo:list-item-body formatting object * does not generate any areas. The fo:list-item-body formatting object @@ -44,21 +38,6 @@ public class ListItemBody extends FObj { * of areas returned by each of the children of the fo:list-item-body. */ - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FObj fo = (FObj)children.get(i); - - Status status; - if ((status = fo.layout(area)).isIncomplete()) { - this.marker = i; - if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - return new Status(Status.AREA_FULL_NONE); - } else { - return new Status(Status.AREA_FULL_SOME); - } - } - } - 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 36a738610..da2ef5d30 100644 --- a/src/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/org/apache/fop/fo/flow/ListItemLabel.java @@ -23,12 +23,7 @@ public class ListItemLabel extends FObj { super(parent); } - public Status layout(Area area) throws FOPException { - int numChildren = this.children.size(); - - if (numChildren != 1) { - throw new FOPException("list-item-label must have exactly one block in this version of FOP"); - } + public void setup() throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -36,11 +31,6 @@ public class ListItemLabel extends FObj { setupID(); // this.properties.get("keep-together"); - // initialize id - area.getIDReferences().initializeID(id, area); - - Block block = (Block)children.get(0); - /* * For calculating the lineage - The fo:list-item-label formatting object * does not generate any areas. The fo:list-item-label formatting object @@ -48,10 +38,6 @@ public class ListItemLabel extends FObj { * of areas returned by each of the children of the fo:list-item-label. */ - Status status; - status = block.layout(area); - area.addDisplaySpace(-block.getAreaHeight()); - return status; } } diff --git a/src/org/apache/fop/fo/flow/Marker.java b/src/org/apache/fop/fo/flow/Marker.java index 513033732..5119d4c9a 100644 --- a/src/org/apache/fop/fo/flow/Marker.java +++ b/src/org/apache/fop/fo/flow/Marker.java @@ -19,7 +19,6 @@ import org.xml.sax.Attributes; public class Marker extends FObjMixed { private String markerClassName; - private Area registryArea; public Marker(FONode parent) { super(parent); @@ -42,39 +41,9 @@ public class Marker extends FObjMixed { } } - public Status layout(Area area) throws FOPException { - // no layout action desired - this.registryArea = area; - area.addMarker(this); - area.getPage().registerMarker(this); - // System.out.println("Marker being registered in area '" + area + "'"); - return new Status(Status.OK); - } - - public Status layoutMarker(Area area) throws FOPException { - if (this.marker == START) - this.marker = 0; - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.get(i); - - Status status; - if ((status = fo.layout(area)).isIncomplete()) { - this.marker = i; - return status; - } - } - - return new Status(Status.OK); - } - public String getMarkerClassName() { return markerClassName; } - public Area getRegistryArea() { - return registryArea; - } } diff --git a/src/org/apache/fop/fo/flow/MultiCase.java b/src/org/apache/fop/fo/flow/MultiCase.java index cbf6e7264..0c42357a9 100644 --- a/src/org/apache/fop/fo/flow/MultiCase.java +++ b/src/org/apache/fop/fo/flow/MultiCase.java @@ -22,7 +22,7 @@ public class MultiCase extends ToBeImplementedElement { super(parent); } - public Status layout(Area area) throws FOPException { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -32,6 +32,5 @@ public class MultiCase extends ToBeImplementedElement { // this.properties.get("case-name"); // this.properties.get("case-title"); - return super.layout(area); } } diff --git a/src/org/apache/fop/fo/flow/MultiProperties.java b/src/org/apache/fop/fo/flow/MultiProperties.java index 3ba02e999..a2bd224b6 100644 --- a/src/org/apache/fop/fo/flow/MultiProperties.java +++ b/src/org/apache/fop/fo/flow/MultiProperties.java @@ -22,13 +22,12 @@ public class MultiProperties extends ToBeImplementedElement { super(parent); } - public Status layout(Area area) throws FOPException { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); setupID(); - return super.layout(area); } } diff --git a/src/org/apache/fop/fo/flow/MultiPropertySet.java b/src/org/apache/fop/fo/flow/MultiPropertySet.java index cf2a9f12b..5ff4f2fdd 100644 --- a/src/org/apache/fop/fo/flow/MultiPropertySet.java +++ b/src/org/apache/fop/fo/flow/MultiPropertySet.java @@ -22,11 +22,10 @@ public class MultiPropertySet extends ToBeImplementedElement { super(parent); } - public Status layout(Area area) throws FOPException { + public void setup() { setupID(); // this.properties.get("active-state"); - return super.layout(area); } } diff --git a/src/org/apache/fop/fo/flow/MultiSwitch.java b/src/org/apache/fop/fo/flow/MultiSwitch.java index 8defde3a4..c30ce6ebc 100644 --- a/src/org/apache/fop/fo/flow/MultiSwitch.java +++ b/src/org/apache/fop/fo/flow/MultiSwitch.java @@ -22,7 +22,7 @@ public class MultiSwitch extends ToBeImplementedElement { super(parent); } - public Status layout(Area area) throws FOPException { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -30,6 +30,5 @@ public class MultiSwitch extends ToBeImplementedElement { // this.properties.get("auto-restore"); setupID(); - return super.layout(area); } } diff --git a/src/org/apache/fop/fo/flow/MultiToggle.java b/src/org/apache/fop/fo/flow/MultiToggle.java index 781e72866..8da98b000 100644 --- a/src/org/apache/fop/fo/flow/MultiToggle.java +++ b/src/org/apache/fop/fo/flow/MultiToggle.java @@ -22,7 +22,7 @@ public class MultiToggle extends ToBeImplementedElement { super(parent); } - public Status layout(Area area) throws FOPException { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -30,6 +30,5 @@ public class MultiToggle extends ToBeImplementedElement { setupID(); // this.properties.get("switch-to"); - return super.layout(area); } } diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java index 59060e989..e9f186b7d 100644 --- a/src/org/apache/fop/fo/flow/PageNumber.java +++ b/src/org/apache/fop/fo/flow/PageNumber.java @@ -53,12 +53,7 @@ public class PageNumber extends FObj { }); } - public Status layout(Area area) throws FOPException { - if (!(area instanceof BlockArea)) { - log.warn("page-number outside block area"); - return new Status(Status.OK); - } - if (this.marker == START) { + public void setup() throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -71,7 +66,7 @@ public class PageNumber extends FObj { BackgroundProps bProps = propMgr.getBackgroundProps(); // Common Font Properties - //this.fontState = propMgr.getFontState(area.getFontInfo()); + //this.fontState = propMgr.getFontState(structHandler.getFontInfo()); // Common Margin Properties-Inline MarginInlineProps mProps = propMgr.getMarginInlineProps(); @@ -104,19 +99,7 @@ public class PageNumber extends FObj { this.whiteSpaceCollapse = this.properties.get("white-space-collapse").getEnum(); ts = new TextState(); - this.marker = 0; - - // initialize id - area.getIDReferences().initializeID(id, area); - } - - String p = area.getPage().getFormattedNumber(); - this.marker = FOText.addText((BlockArea)area, - propMgr.getFontState(area.getFontInfo()), - red, green, blue, wrapOption, null, - whiteSpaceCollapse, p.toCharArray(), 0, - p.length(), ts, VerticalAlign.BASELINE); - return new Status(Status.OK); + } } diff --git a/src/org/apache/fop/fo/flow/PageNumberCitation.java b/src/org/apache/fop/fo/flow/PageNumberCitation.java index 6e812f8f1..e9f2979e0 100644 --- a/src/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/org/apache/fop/fo/flow/PageNumberCitation.java @@ -81,7 +81,6 @@ public class PageNumberCitation extends FObj { float blue; int wrapOption; int whiteSpaceCollapse; - Area area; String pageNumber; String refId; TextState ts; @@ -103,15 +102,7 @@ public class PageNumberCitation extends FObj { return null; } - public Status layout(Area area) throws FOPException { - if (!(area instanceof BlockArea)) { - log.warn("page-number-citation outside block area"); - return new Status(Status.OK); - } - - IDReferences idReferences = area.getIDReferences(); - this.area = area; - if (this.marker == START) { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -162,56 +153,8 @@ public class PageNumberCitation extends FObj { this.refId = this.properties.get("ref-id").getString(); if (this.refId.equals("")) { - throw new FOPException("page-number-citation must contain \"ref-id\""); - } - - // create id - idReferences.createID(id); - ts = new TextState(); - - this.marker = 0; - } - - if (marker == 0) { - idReferences.configureID(id, area); - } - - - pageNumber = idReferences.getPageNumber(refId); - - if (pageNumber != null) { // if we already know the page number - this.marker = FOText.addText((BlockArea) area, - propMgr.getFontState(area.getFontInfo()), red, - green, blue, wrapOption, null, whiteSpaceCollapse, - pageNumber.toCharArray(), 0, pageNumber.length(), - ts, VerticalAlign.BASELINE); - } else { // add pageNumberCitation to area to be resolved during rendering - BlockArea blockArea = (BlockArea) area; - LineArea la = blockArea.getCurrentLineArea(); - if (la == null) { - return new Status(Status.AREA_FULL_NONE); + //throw new FOPException("page-number-citation must contain \"ref-id\""); } - la.changeFont(propMgr.getFontState(area.getFontInfo())); - la.changeColor(red, green, blue); - la.changeWrapOption(wrapOption); - la.changeWhiteSpaceCollapse(whiteSpaceCollapse); - /* - * la.changeHyphenation(language, country, hyphenate, - * hyphenationChar, hyphenationPushCharacterCount, - * hyphenationRemainCharacterCount); - */ - - // blockArea.setupLinkSet(null); - la.addPageNumberCitation(refId, null); - this.marker = -1; - } - - - if (this.marker == -1) { - return new Status(Status.OK); - } else { - return new Status(Status.AREA_FULL_NONE); - } } diff --git a/src/org/apache/fop/fo/flow/RetrieveMarker.java b/src/org/apache/fop/fo/flow/RetrieveMarker.java index 2baa6419f..fb59e7d7b 100644 --- a/src/org/apache/fop/fo/flow/RetrieveMarker.java +++ b/src/org/apache/fop/fo/flow/RetrieveMarker.java @@ -39,115 +39,4 @@ public class RetrieveMarker extends FObjMixed { this.properties.get("retrieve-boundary").getEnum(); } - public Status layout(Area area) throws FOPException { - // locate qualifying areas by 'marker-class-name' and - // 'retrieve-boundary'. Initially we will always check - // the containing page - Page containingPage = area.getPage(); - Marker bestMarker = searchPage(containingPage, true); - - // if marker not yet found, and 'retrieve-boundary' permits, - // search forward by Page - if ((null == bestMarker) - && (retrieveBoundary != RetrieveBoundary.PAGE)) { - // System.out.println("Null bestMarker and searching..."); - Page currentPage = containingPage; - boolean isFirstCall = true; - while (bestMarker == null) { - Page previousPage = locatePreviousPage(currentPage, - retrieveBoundary, - isFirstCall); - isFirstCall = false; - // System.out.println("Previous page = '" + previousPage + "'"); - bestMarker = searchPage(previousPage, false); - currentPage = previousPage; - } - } - - Status status = new Status(Status.OK); - if (null != bestMarker) { - // System.out.println("Laying out marker '" + bestMarker + "' in area '" + area + "'"); - // the 'markers' referred to in this method are internal; they have - // nothing to do with fo:marker - bestMarker.resetMarker(); - status = bestMarker.layoutMarker(area); - } - - return status; - } - - private Marker searchPage(Page page, - boolean isContainingPage) throws FOPException { - Vector pageMarkers = page.getMarkers(); - if (pageMarkers.isEmpty()) { - // System.out.println("No markers on page"); - return null; - } - - // if no longer the containing page (fo:retrieve-marker, or the page - // being processed), grab the last qualifying marker on this one - if (!isContainingPage) { - for (int c = pageMarkers.size(); c > 0; c--) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1); - if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { - return currentMarker; - } - } - } - - // search forward if 'first-starting-within-page' or - // 'first-including-carryover' - if (retrievePosition == RetrievePosition.FIC) { - for (int c = 0; c < pageMarkers.size(); c++) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c); - if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { - return currentMarker; - } - } - - } else if (retrievePosition == RetrievePosition.FSWP) { - for (int c = 0; c < pageMarkers.size(); c++) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c); - if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { - if (currentMarker.getRegistryArea().isFirst()) { - return currentMarker; - } - } - } - - } else if (retrievePosition == RetrievePosition.LSWP) { - for (int c = pageMarkers.size(); c > 0; c--) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1); - if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { - if (currentMarker.getRegistryArea().isFirst()) { - return currentMarker; - } - } - } - - } else if (retrievePosition == RetrievePosition.LEWP) { - for (int c = pageMarkers.size(); c > 0; c--) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1); - if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { - if (currentMarker.getRegistryArea().isLast()) { - return currentMarker; - } - } - } - - } else { - throw new FOPException("Illegal 'retrieve-position' value"); - } - return null; - } - - private Page locatePreviousPage(Page page, int retrieveBoundary, - boolean isFirstCall) { - boolean pageWithinSequence = true; - if (retrieveBoundary == RetrieveBoundary.DOCUMENT) - pageWithinSequence = false; - return page.getAreaTree().getPreviousPage(page, pageWithinSequence, - isFirstCall); - } - } diff --git a/src/org/apache/fop/fo/flow/RowSpanMgr.java b/src/org/apache/fop/fo/flow/RowSpanMgr.java index 363963b62..aaae9fe53 100644 --- a/src/org/apache/fop/fo/flow/RowSpanMgr.java +++ b/src/org/apache/fop/fo/flow/RowSpanMgr.java @@ -7,7 +7,6 @@ package org.apache.fop.fo.flow; -import org.apache.fop.layout.Area; import java.util.Enumeration; public class RowSpanMgr { @@ -41,7 +40,6 @@ public class RowSpanMgr { totalRowHeight += rowHeight; if (--rowsRemaining == 0) { if (cell != null) { - cell.setRowHeight(totalRowHeight); } return true; } else diff --git a/src/org/apache/fop/fo/flow/StaticContent.java b/src/org/apache/fop/fo/flow/StaticContent.java index df70955b4..77f6fbb8f 100644 --- a/src/org/apache/fop/fo/flow/StaticContent.java +++ b/src/org/apache/fop/fo/flow/StaticContent.java @@ -11,67 +11,16 @@ package org.apache.fop.fo.flow; import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.fo.pagination.*; -import org.apache.fop.layout.Area; import org.apache.fop.apps.FOPException; public class StaticContent extends Flow { public StaticContent(FONode parent) { super(parent); - ((PageSequence)parent).setIsFlowSet(false); // hacquery of sorts } - 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 regionClass = "none"; -// if (region != null) { -// regionClass = region.getRegionClass(); -// } else { -// if (getFlowName().equals("xsl-region-before")) { -// regionClass = RegionBefore.REGION_CLASS; -// } else if (getFlowName().equals("xsl-region-after")) { -// regionClass = RegionAfter.REGION_CLASS; -// } else if (getFlowName().equals("xsl-region-start")) { -// regionClass = RegionStart.REGION_CLASS; -// } else if (getFlowName().equals("xsl-region-end")) { -// regionClass = RegionEnd.REGION_CLASS; -// } - -// } - -// if (area instanceof org.apache.fop.layout.AreaContainer) -// ((org.apache.fop.layout.AreaContainer)area).setAreaName(regionClass); - -// if (regionClass.equals(RegionBefore.REGION_CLASS)) { -// area.setAbsoluteHeight(-area.getMaxHeight()); -// } else if (regionClass.equals(RegionAfter.REGION_CLASS)) { -// area.setAbsoluteHeight(area.getPage().getBody().getMaxHeight()); -// } -// setContentWidth(area.getContentWidth()); - -// for (int i = 0; i < numChildren; i++) { -// FObj fo = (FObj)children.elementAt(i); + public void setup() { -// Status status; -// if ((status = fo.layout(area)).isIncomplete()) { -// // in fact all should be laid out and clip, error etc depending on 'overflow' -// log.warn("Some static content could not fit in the area."); -// this.marker = i; -// if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { -// status = new Status(Status.AREA_FULL_SOME); -// } -// return (status); -// } -// } -// resetMarker(); - return new Status(Status.OK); } // flowname checking is more stringient for static content currently diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java index 899460d2a..526ff429a 100644 --- a/src/org/apache/fop/fo/flow/Table.java +++ b/src/org/apache/fop/fo/flow/Table.java @@ -44,18 +44,11 @@ public class Table extends FObj { /** Maximum inline-progression-dimension */ private int maxIPD; - AreaContainer areaContainer; - public Table(FONode parent) { super(parent); } - public Status layout(Area area) throws FOPException { - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -115,487 +108,10 @@ public class Table extends FObj { this.properties.get("table-omit-footer-at-break").getEnum() == TableOmitFooterAtBreak.TRUE; - if (area instanceof BlockArea) { - area.end(); - } - if (this.areaContainer - == null) { // check if anything was previously laid out - area.getIDReferences().createID(id); - } - - - this.marker = 0; - - if (breakBefore == BreakBefore.PAGE) { - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakBefore == BreakBefore.ODD_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakBefore == BreakBefore.EVEN_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - - } - - if ((spaceBefore != 0) && (this.marker == 0)) { - area.addDisplaySpace(spaceBefore); - } - - if (marker == 0 && areaContainer == null) { - // configure id - area.getIDReferences().configureID(id, area); - } - - int spaceLeft = area.spaceLeft(); - this.areaContainer = - new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0, 0, - area.getAllocationWidth(), area.spaceLeft(), - Position.STATIC); - - areaContainer.foCreator = this; // G Seshadri - areaContainer.setPage(area.getPage()); - areaContainer.setBackgroundColor(backgroundColor); - areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding()); - areaContainer.start(); - - areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); - areaContainer.setIDReferences(area.getIDReferences()); - - boolean addedHeader = false; - boolean addedFooter = false; - int numChildren = this.children.size(); - - // Set up the column vector; - // calculate width of all columns and get total width - if (columns.size()==0) { - findColumns(areaContainer); - if (this.bAutoLayout) { - log.warn("table-layout=auto is not supported, using fixed!"); - } - // Pretend it's fixed... - this.contentWidth = - calcFixedColumnWidths(areaContainer.getAllocationWidth()); - } - areaContainer.setAllocationWidth(this.contentWidth); - layoutColumns(areaContainer); - - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.get(i); - if (fo instanceof TableHeader) { - if (columns.size() == 0) { - log.warn("current implementation of tables requires a table-column for each column, indicating column-width"); - return new Status(Status.OK); - } - tableHeader = (TableHeader)fo; - tableHeader.setColumns(columns); - } else if (fo instanceof TableFooter) { - if (columns.size() == 0) { - log.warn("current implementation of tables requires a table-column for each column, indicating column-width"); - return new Status(Status.OK); - } - tableFooter = (TableFooter)fo; - tableFooter.setColumns(columns); - } else if (fo instanceof TableBody) { - if (columns.size() == 0) { - log.warn("current implementation of tables requires a table-column for each column, indicating column-width"); - return new Status(Status.OK); - } - Status status; - if (tableHeader != null &&!addedHeader) { - if ((status = - tableHeader.layout(areaContainer)).isIncomplete()) { - tableHeader.resetMarker(); - return new Status(Status.AREA_FULL_NONE); - } - addedHeader = true; - tableHeader.resetMarker(); - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); - } - if (tableFooter != null &&!this.omitFooterAtBreak - &&!addedFooter) { - if ((status = - tableFooter.layout(areaContainer)).isIncomplete()) { - return new Status(Status.AREA_FULL_NONE); - } - addedFooter = true; - tableFooter.resetMarker(); - } - //fo.setWidows(widows); - //fo.setOrphans(orphans); - ((TableBody)fo).setColumns(columns); - - if ((status = fo.layout(areaContainer)).isIncomplete()) { - this.marker = i; - if (bodyCount == 0 - && status.getCode() == Status.AREA_FULL_NONE) { - if (tableHeader != null) - tableHeader.removeLayout(areaContainer); - if (tableFooter != null) - tableFooter.removeLayout(areaContainer); - resetMarker(); - // status = new Status(Status.AREA_FULL_SOME); - } - // areaContainer.end(); - if (areaContainer.getContentHeight() > 0) { - area.addChild(areaContainer); - area.increaseHeight(areaContainer.getHeight()); - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - if (this.omitHeaderAtBreak) { - // remove header, no longer needed - tableHeader = null; - } - if (tableFooter != null &&!this.omitFooterAtBreak) { - // move footer to bottom of area and move up body - ((TableBody)fo).setYPosition(tableFooter.getYPosition()); - tableFooter.setYPosition(tableFooter.getYPosition() - + ((TableBody)fo).getHeight()); - } - setupColumnHeights(); - status = new Status(Status.AREA_FULL_SOME); - } - return status; - } else { - bodyCount++; - } - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); - if (tableFooter != null &&!this.omitFooterAtBreak) { - // move footer to bottom of area and move up body - // space before and after footer will make this wrong - ((TableBody)fo).setYPosition(tableFooter.getYPosition()); - tableFooter.setYPosition(tableFooter.getYPosition() - + ((TableBody)fo).getHeight()); - } - } - } - - if (tableFooter != null && this.omitFooterAtBreak) { - if (tableFooter.layout(areaContainer).isIncomplete()) { - // this is a problem since we need to remove a row - // from the last table body and place it on the - // next page so that it can have a footer at - // the end of the table. - log.warn("footer could not fit on page, moving last body row to next page"); - area.addChild(areaContainer); - area.increaseHeight(areaContainer.getHeight()); - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - if (this.omitHeaderAtBreak) { - // remove header, no longer needed - tableHeader = null; - } - tableFooter.removeLayout(areaContainer); - tableFooter.resetMarker(); - return new Status(Status.AREA_FULL_SOME); - } - } - - if (height != 0) - areaContainer.setHeight(height); - - setupColumnHeights(); - - areaContainer.end(); - area.addChild(areaContainer); - - /* should this be combined into above? */ - area.increaseHeight(areaContainer.getHeight()); - - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - - if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); - } - - if (area instanceof BlockArea) { - area.start(); - } - - if (breakAfter == BreakAfter.PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakAfter == BreakAfter.ODD_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakAfter == BreakAfter.EVEN_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - - return new Status(Status.OK); - } - - protected void setupColumnHeights() { - Iterator eCol = columns.iterator(); - while (eCol.hasNext()) { - TableColumn c = (TableColumn)eCol.next(); - if ( c != null) { - c.setHeight(areaContainer.getContentHeight()); - } - } - } - - private void findColumns(Area areaContainer) throws FOPException { - int nextColumnNumber = 1; - Iterator e = children.iterator(); - while (e.hasNext()) { - FONode fo = (FONode)e.next(); - if (fo instanceof TableColumn) { - TableColumn c = (TableColumn)fo; - c.doSetup(areaContainer); - int numColumnsRepeated = c.getNumColumnsRepeated(); - int currentColumnNumber = c.getColumnNumber(); - if (currentColumnNumber == 0) { - currentColumnNumber = nextColumnNumber; - } - - for (int j = 0; j < numColumnsRepeated; j++) { - if (currentColumnNumber > columns.size()) { - columns.ensureCapacity(currentColumnNumber); - } - if (columns.get(currentColumnNumber - 1) != null) { - log.warn("More than one column object assigned " + - "to column " + - currentColumnNumber); - } - columns.set(currentColumnNumber - 1, c); - currentColumnNumber++; - } - nextColumnNumber = currentColumnNumber; - } - } - } - - - - private int calcFixedColumnWidths(int maxAllocationWidth) { - int nextColumnNumber=1; - int iEmptyCols=0; - double dTblUnits=0.0; - int iFixedWidth=0; - double dWidthFactor = 0.0; - double dUnitLength = 0.0; - double tuMin = 100000.0 ; // Minimum number of proportional units - Iterator eCol = columns.iterator(); - while (eCol.hasNext()) { - TableColumn c = (TableColumn)eCol.next(); - if (c == null) { - log.warn("No table-column specification for column " + - nextColumnNumber); - // What about sizing issues? - iEmptyCols++; - } - else { - Length colLength = c.getColumnWidthAsLength(); - double tu = colLength.getTableUnits(); - if (tu > 0 && tu < tuMin && colLength.mvalue()==0) { - /* Keep track of minimum number of proportional units - * in any column which has only proportional units. - */ - tuMin = tu; - } - dTblUnits += tu; - iFixedWidth += colLength.mvalue(); - } - nextColumnNumber++; - } - - setIPD((dTblUnits > 0.0), maxAllocationWidth); - if (dTblUnits > 0.0) { - int iProportionalWidth = 0; - if (this.optIPD > iFixedWidth) { - iProportionalWidth = this.optIPD - iFixedWidth; - } - else if (this.maxIPD > iFixedWidth) { - iProportionalWidth = this.maxIPD - iFixedWidth; - } - else { - iProportionalWidth = maxAllocationWidth - iFixedWidth; - } - if (iProportionalWidth > 0) { - dUnitLength = ((double)iProportionalWidth)/dTblUnits; - } - else { - log.error("Sum of fixed column widths " + iFixedWidth + - " greater than maximum available IPD " + - maxAllocationWidth + "; no space for " + - dTblUnits + " proportional units."); - /* Set remaining proportional units to a number which - * will assure the minimum column size for tuMin. - */ - dUnitLength = MINCOLWIDTH/tuMin; - // Reduce fixed column widths by this much??? - } - //log.debug("1 table-unit = " + dUnitLength + " mpt"); - } - else { - /* No proportional units. If minimum IPD is specified, check - * that sum of column widths > minIPD. - */ - int iTableWidth = iFixedWidth; - if (this.minIPD > iFixedWidth) { - iTableWidth = this.minIPD; - // Add extra space to each column - dWidthFactor = (double)this.minIPD/(double)iFixedWidth; - } - else if (this.maxIPD < iFixedWidth) { - // Note: if maxIPD=auto, use maxAllocWidth - log.warn("Sum of fixed column widths " + iFixedWidth + - " greater than maximum specified IPD " + this.maxIPD); - } - else if (this.optIPD != -1 && iFixedWidth != this.optIPD) { - log.warn("Sum of fixed column widths " + iFixedWidth + - " differs from specified optimum IPD " + this.optIPD); - } - } - // Now distribute the extra units onto each column and set offsets - int offset = 0; - eCol = columns.iterator(); - while (eCol.hasNext()) { - TableColumn c = (TableColumn)eCol.next(); - if (c != null) { - c.setColumnOffset(offset); - Length l = c.getColumnWidthAsLength(); - if (dUnitLength > 0) { - l.resolveTableUnit(dUnitLength); - } - // Check minimum values and adjust if necessary - int colWidth = l.mvalue(); - if (colWidth <= 0) { - log.warn("Zero-width table column!"); - } - if (dWidthFactor > 0.0) { - // Increase column sizes to use up extra space - colWidth *= dWidthFactor; - } - c.setColumnWidth(colWidth); - offset += colWidth; - } - } - return offset; - } - - private void layoutColumns(Area tableArea) throws FOPException { - Iterator eCol = columns.iterator(); - while (eCol.hasNext()) { - TableColumn c = (TableColumn)eCol.next(); - if (c != null) { - c.layout(tableArea); - } - } - } - - - public int getAreaHeight() { - return areaContainer.getHeight(); - } - - /** - * Return the content width of the boxes generated by this table FO. - */ - public int getContentWidth() { - if (areaContainer != null) - return areaContainer.getContentWidth(); // getAllocationWidth()?? - else - return 0; // not laid out yet } public boolean generatesInlineAreas() { return false; } - - /** - * Initialize table inline-progression-properties values - */ - private void setIPD(boolean bHasProportionalUnits, int maxAllocIPD) { - boolean bMaxIsSpecified = !this.ipd.getMaximum().getLength().isAuto(); - if (bMaxIsSpecified) { - this.maxIPD = ipd.getMaximum().getLength().mvalue(); - } - else { - this.maxIPD = maxAllocIPD; - } - - if (ipd.getOptimum().getLength().isAuto()) { - this.optIPD = -1; - } - else { - this.optIPD = ipd.getMaximum().getLength().mvalue(); - } - if (ipd.getMinimum().getLength().isAuto()) { - this.minIPD = -1; - } - else { - this.minIPD = ipd.getMinimum().getLength().mvalue(); - } - if (bHasProportionalUnits && this.optIPD < 0) { - if (this.minIPD > 0) { - if (bMaxIsSpecified) { - this.optIPD = (minIPD + maxIPD)/2; - } - else { - this.optIPD = this.minIPD; - } - } - else if (bMaxIsSpecified) { - this.optIPD = this.maxIPD; - } - else { - log.error("At least one of minimum, optimum, or maximum " + - "IPD must be specified on table."); - this.optIPD = this.maxIPD; - } - } - } - - - // /** - // * Return the last TableRow in the header or null if no header or - // * no header in non-first areas. - // * @param bForInitialArea If true, return the header row for the - // * initial table area, else for a continuation area, taking into - // * account the omit-header-at-break property. - // */ - // TableRow getLastHeaderRow(boolean bForInitialArea) { - // // Check omit... - // if ((tableHeader != null) && - // (bForInitialArea || omitHeaderAtBreak == false)) { - // return tableHeader.children.lastElement(); - // } - // return null; - // } - - // /** - // * Return the first TableRow in the footer or null if no footer or - // * no footer in non-last areas. - // * @param bForFinalArea If true, return the footer row for the - // * final table area, else for a non-final area, taking into - // * account the omit-footer-at-break property. - // */ - // TableRow getLastFooterRow(boolean bForFinalArea) { - // if ((tableFooter != null) && - // (bForFinalArea || omitFooterAtBreak == false)) { - // return tableFooter.children.firstElement(); - // } - // return null; - // } - - - // /** - // * Return border information for the side (start/end) of the column - // * whose number is iColNumber (first column = 1). - // * ATTENTION: for now we assume columns are in order in the array! - // */ - // BorderInfo getColumnBorder(BorderInfo.Side side, int iColNumber) { - // TableColumn col = (TableColumn)columns.get(iColNumber); - // return col.getBorderInfo(side); - // } } diff --git a/src/org/apache/fop/fo/flow/TableAndCaption.java b/src/org/apache/fop/fo/flow/TableAndCaption.java index 5f1ec3148..997127a32 100644 --- a/src/org/apache/fop/fo/flow/TableAndCaption.java +++ b/src/org/apache/fop/fo/flow/TableAndCaption.java @@ -22,7 +22,7 @@ public class TableAndCaption extends ToBeImplementedElement { super(parent); } - public Status layout(Area area) throws FOPException { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -46,7 +46,6 @@ public class TableAndCaption extends ToBeImplementedElement { // this.properties.get("keep-with-next"); // this.properties.get("keep-with-previous"); - return super.layout(area); } public boolean generatesInlineAreas() { diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java index bbb22c42d..7d9d07940 100644 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ b/src/org/apache/fop/fo/flow/TableBody.java @@ -27,8 +27,6 @@ public class TableBody extends FObj { ArrayList columns; RowSpanMgr rowSpanMgr; // manage information about spanning rows - AreaContainer areaContainer; - public TableBody(FONode parent) { super(parent); } @@ -37,25 +35,7 @@ public class TableBody extends FObj { this.columns = columns; } - public void setYPosition(int value) { - areaContainer.setYPosition(value); - } - - public int getYPosition() { - return areaContainer.getCurrentYPosition(); - } - - public int getHeight() { - return areaContainer.getHeight() + spaceBefore + spaceAfter; - } - - public Status layout(Area area) throws FOPException { - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { - + public void setup() throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -78,168 +58,7 @@ public class TableBody extends FObj { this.backgroundColor = this.properties.get("background-color").getColorType(); - area.getIDReferences().createID(id); - - if (area instanceof BlockArea) { - area.end(); - } - - if (rowSpanMgr == null) { - rowSpanMgr = new RowSpanMgr(columns.size()); - } - - // if (this.isInListBody) { - // startIndent += bodyIndent + distanceBetweenStarts; - // } - - this.marker = 0; - - } - - if ((spaceBefore != 0) && (this.marker == 0)) { - area.increaseHeight(spaceBefore); - } - - if (marker == 0) { - // configure id - area.getIDReferences().configureID(id, area); - } - - int spaceLeft = area.spaceLeft(); - - /* - * Note: the parent FO must be a Table. The parent Area is the Block - * type area created by the Table, which is also a reference area. - * The content "width" (IPD) of the TableBody is the same as that - * of the containing table area, and its relative position is 0,0. - * Strictly speaking (CR), this FO should generate no areas! - */ - this.areaContainer = - new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0, - area.getContentHeight(), - area.getContentWidth(), // IPD - area.spaceLeft(), Position.RELATIVE); - areaContainer.foCreator = this; // G Seshadri - areaContainer.setPage(area.getPage()); - areaContainer.setBackgroundColor(backgroundColor); - areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding()); - areaContainer.start(); - - areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); - areaContainer.setIDReferences(area.getIDReferences()); - - ArrayList keepWith = new ArrayList(); - int numChildren = this.children.size(); - TableRow lastRow = null; - boolean endKeepGroup = true; - for (int i = this.marker; i < numChildren; i++) { - Object child = children.get(i); - if (!(child instanceof TableRow)) { - throw new FOPException("Currently only Table Rows are supported in table body, header and footer"); - } - TableRow row = (TableRow)child; - - row.setRowSpanMgr(rowSpanMgr); - row.setColumns(columns); - row.doSetup(areaContainer); - if (row.getKeepWithPrevious().getType() - != KeepValue.KEEP_WITH_AUTO && lastRow != null - && keepWith.indexOf(lastRow) - == -1) { - keepWith.add(lastRow); - } else { - if (endKeepGroup && keepWith.size() > 0) { - keepWith = new ArrayList(); - } - } - - Status status; - if ((status = row.layout(areaContainer)).isIncomplete()) { - // BUG!!! don't distinguish between break-before and after! - if (status.isPageBreak()) { - this.marker = i; - area.addChild(areaContainer); - // areaContainer.end(); - - area.increaseHeight(areaContainer.getHeight()); - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - if (i == numChildren - 1) { - this.marker = BREAK_AFTER; - if (spaceAfter != 0) { - area.increaseHeight(spaceAfter); - } - } - return status; - } - if (keepWith.size() - > 0) { // && status.getCode() == Status.AREA_FULL_NONE - // FIXME!!! Handle rows spans!!! - row.removeLayout(areaContainer); - for (Iterator e = keepWith.iterator(); - e.hasNext(); ) { - TableRow tr = (TableRow)e.next(); - tr.removeLayout(areaContainer); - i--; - } - if (i == 0) { - resetMarker(); - return new Status(Status.AREA_FULL_NONE); - } - } - this.marker = i; - if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - status = new Status(Status.AREA_FULL_SOME); - } - if (!((i == 0) && (areaContainer.getContentHeight() <= 0))) { - area.addChild(areaContainer); - // areaContainer.end(); - - area.increaseHeight(areaContainer.getHeight()); - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - } - return status; - } else if (status.getCode() == Status.KEEP_WITH_NEXT - || rowSpanMgr.hasUnfinishedSpans()) { - keepWith.add(row); - endKeepGroup = false; - } else { - endKeepGroup = true; - } - lastRow = row; - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); - spaceLeft = area.spaceLeft(); - } - area.addChild(areaContainer); - areaContainer.end(); - - area.increaseHeight(areaContainer.getHeight()); - - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - - if (spaceAfter != 0) { - area.increaseHeight(spaceAfter); - area.setMaxHeight(area.getMaxHeight() - spaceAfter); - } - - if (area instanceof BlockArea) { - area.start(); - } - - return new Status(Status.OK); - } - - public void removeLayout(Area area) { - if (areaContainer != null) { - area.removeChild(areaContainer); - } - if (spaceBefore != 0) { - area.increaseHeight(-spaceBefore); - } - if (spaceAfter != 0) { - area.increaseHeight(-spaceAfter); - } - this.resetMarker(); } } + diff --git a/src/org/apache/fop/fo/flow/TableCaption.java b/src/org/apache/fop/fo/flow/TableCaption.java index 40e29ad45..98469babc 100644 --- a/src/org/apache/fop/fo/flow/TableCaption.java +++ b/src/org/apache/fop/fo/flow/TableCaption.java @@ -22,7 +22,7 @@ public class TableCaption extends ToBeImplementedElement { super(parent); } - public Status layout(Area area) throws FOPException { + public void setup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -44,6 +44,5 @@ public class TableCaption extends ToBeImplementedElement { // this.properties.get("keep-togethe"); // this.properties.get("width"); - return super.layout(area); } } diff --git a/src/org/apache/fop/fo/flow/TableCell.java b/src/org/apache/fop/fo/flow/TableCell.java index dff24d463..21dc31e71 100644 --- a/src/org/apache/fop/fo/flow/TableCell.java +++ b/src/org/apache/fop/fo/flow/TableCell.java @@ -83,8 +83,6 @@ public class TableCell extends FObj { */ int m_borderSeparation = 0; - AreaContainer cellArea; - public TableCell(FONode parent) { super(parent); } @@ -186,175 +184,6 @@ public class TableCell extends FObj { this.properties.get("height").getLength().mvalue(); } - - public Status layout(Area area) throws FOPException { - int originalAbsoluteHeight = area.getAbsoluteHeight(); - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { - // if (!setup) { - // doSetup(area); - // } - - // Calculate cell borders - // calcBorders(propMgr.getBorderAndPadding()); - - area.getIDReferences().createID(id); - - this.marker = 0; - this.bDone=false; - } - - /* - * if ((spaceBefore != 0) && (this.marker ==0)) { - * area.increaseHeight(spaceBefore); - * } - */ - - if (marker == 0) { - // configure id - area.getIDReferences().configureID(id, area); - } - - // int spaceLeft = area.spaceLeft() - m_borderSeparation/2 + borderHeight/2 ; - int spaceLeft = area.spaceLeft() - m_borderSeparation; - // The Area position defines the content rectangle! Borders - // and padding are outside of this rectangle. - this.cellArea = - new AreaContainer(propMgr.getFontState(area.getFontInfo()), - startOffset + startAdjust, beforeOffset, - width - widthAdjust, spaceLeft, - Position.RELATIVE); - - cellArea.foCreator = this; // G Seshadri - cellArea.setPage(area.getPage()); - try { - cellArea.setBorderAndPadding((BorderAndPadding) - propMgr.getBorderAndPadding().clone()); - } catch (CloneNotSupportedException e) { - System.err.println("Can't clone BorderAndPadding: " + e) ; - cellArea.setBorderAndPadding(propMgr.getBorderAndPadding()); - } - cellArea.setBackgroundColor(this.backgroundColor); - cellArea.start(); - - cellArea.setAbsoluteHeight(area.getAbsoluteHeight()); // ??? - cellArea.setIDReferences(area.getIDReferences()); - // ******** CHECK THIS: we've changed startOffset (KL) - cellArea.setTableCellXOffset(startOffset); - - int numChildren = this.children.size(); - for (int i = this.marker; bDone==false && i < numChildren; i++) { - FObj fo = (FObj)children.get(i); - fo.setIsInTableCell(); - fo.forceWidth(width); // ??? - - // Overflows may cause a row to be re-layedout, - // need to pass already processed content. - this.marker = i; - - Status status; - if ((status = fo.layout(cellArea)).isIncomplete()) { - // this.marker = i; - if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - return new Status(Status.AREA_FULL_NONE); - } else { - // hani Elabed 11/21/2000 - area.addChild(cellArea); - // area.setAbsoluteHeight(cellArea.getAbsoluteHeight()); - return new Status(Status.AREA_FULL_SOME); - } - } - - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.cellArea.getMaxHeight()); - } - this.bDone=true; - cellArea.end(); - area.addChild(cellArea); - - // Adjust for minimum cell content height - if (minCellHeight > cellArea.getContentHeight()) { - cellArea.setHeight(minCellHeight); - } - - // This is the allocation height of the cell (including borders - // and padding - // ALSO need to include offsets if using "separate borders" - height = cellArea.getHeight(); - top = cellArea.getCurrentYPosition(); // CHECK THIS!!! - - // reset absoluteHeight to beginning of row - // area.setHeight(cellArea.getHeight() + spaceBefore + spaceAfter); - // I don't think we should do this here (KL) !!! - // area.setHeight(cellArea.getHeight()); - // area.setAbsoluteHeight(originalAbsoluteHeight); - - return new Status(Status.OK); - } - - /** - * Return the allocation height of the cell area. - * Note: called by TableRow. - * We adjust the actual allocation height of the area by the value - * of border separation (for separate borders) or border height - * adjustment for collapse style (because current scheme makes cell - * overestimate the allocation height). - */ - public int getHeight() { - return cellArea.getHeight() + m_borderSeparation - borderHeight; - } - - /** - * Set the final size of cell content rectangles to the actual row height - * and to vertically align the actual content within the cell rectangle. - * @param h Height of this row in the grid which is based on - * the allocation height of all the cells in the row, including any - * border separation values. - */ - public void setRowHeight(int h) { - int delta = h - getHeight(); - // cellArea.increaseHeight(h + borderHeight/2 - cellArea.getHeight()); - if (bRelativeAlign) { - // Must get info for all cells starting in row! - // verticalAlign can be BEFORE or BASELINE - // For now just treat like "before" - cellArea.increaseHeight(delta); - } else if (delta > 0) { - BorderAndPadding cellBP = cellArea.getBorderAndPadding(); - switch (verticalAlign) { - case DisplayAlign.CENTER: - // Increase cell padding before and after and change - // "Y" position of content rectangle - cellArea.shiftYPosition(delta / 2); - cellBP.setPaddingLength(BorderAndPadding.TOP, - cellBP.getPaddingTop(false) - + delta / 2); - cellBP.setPaddingLength(BorderAndPadding.BOTTOM, - cellBP.getPaddingBottom(false) - + delta - delta / 2); - break; - case DisplayAlign.AFTER: - // Increase cell padding before and change - // "Y" position of content rectangle - cellBP.setPaddingLength(BorderAndPadding.TOP, - cellBP.getPaddingTop(false) + delta); - cellArea.shiftYPosition(delta); - break; - case DisplayAlign.BEFORE: - // cellArea.increaseHeight(delta); - cellBP.setPaddingLength(BorderAndPadding.BOTTOM, - cellBP.getPaddingBottom(false) - + delta); - - default: // OK - break; - } - } - } - /** * Calculate cell border and padding, including offset of content * rectangle from the theoretical grid position. diff --git a/src/org/apache/fop/fo/flow/TableColumn.java b/src/org/apache/fop/fo/flow/TableColumn.java index f3f894dc6..17390e672 100644 --- a/src/org/apache/fop/fo/flow/TableColumn.java +++ b/src/org/apache/fop/fo/flow/TableColumn.java @@ -26,8 +26,6 @@ public class TableColumn extends FObj { boolean setup = false; - AreaContainer areaContainer; - public TableColumn(FONode parent) { super(parent); } @@ -56,7 +54,7 @@ public class TableColumn extends FObj { return numColumnsRepeated; } - public void doSetup(Area area) throws FOPException { + public void doSetup() throws FOPException { // Common Border, Padding, and Background Properties // only background apply, border apply if border-collapse @@ -85,45 +83,8 @@ public class TableColumn extends FObj { // initialize id setupID(); - area.getIDReferences().initializeID(id, area); setup = true; } - public Status layout(Area area) throws FOPException { - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { - if (!setup) { - doSetup(area); - } - } - if (columnWidth > 0) { - this.areaContainer = - new AreaContainer(propMgr.getFontState(area.getFontInfo()), - columnOffset, 0, columnWidth, - area.getContentHeight(), Position.RELATIVE); - areaContainer.foCreator = this; // G Seshadri - areaContainer.setPage(area.getPage()); - areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding()); - areaContainer.setBackgroundColor(this.backgroundColor); - areaContainer.setHeight(area.getHeight()); - area.addChild(areaContainer); - } - return new Status(Status.OK); - } - - public void setColumnOffset(int columnOffset) { - this.columnOffset = columnOffset; - } - - public void setHeight(int height) { - if (areaContainer != null) { - areaContainer.setMaxHeight(height); - areaContainer.setHeight(height); - } - } - } diff --git a/src/org/apache/fop/fo/flow/TableFooter.java b/src/org/apache/fop/fo/flow/TableFooter.java index 32b9416a1..847e1c2ae 100644 --- a/src/org/apache/fop/fo/flow/TableFooter.java +++ b/src/org/apache/fop/fo/flow/TableFooter.java @@ -16,14 +16,6 @@ import org.apache.fop.apps.FOPException; public class TableFooter extends TableBody { - public int getYPosition() { - return areaContainer.getCurrentYPosition() - spaceBefore; - } - - public void setYPosition(int value) { - areaContainer.setYPosition(value + 2 * spaceBefore); - } - public TableFooter(FONode parent) { super(parent); } diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index d481a1dd2..cec10dde9 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -34,8 +34,6 @@ public class TableRow extends FObj { int minHeight = 0; // force row height ArrayList columns; - AreaContainer areaContainer; - boolean areaAdded = false; private RowSpanMgr rowSpanMgr = null; @@ -171,7 +169,7 @@ public class TableRow extends FObj { return keepWithPrevious; } - public void doSetup(Area area) throws FOPException { + public void doSetup() { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); @@ -228,229 +226,6 @@ public class TableRow extends FObj { } } - public Status layout(Area area) throws FOPException { - boolean configID = false; - - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - // Layout the first area for this FO - if (this.marker == START) { - if (!setup) - doSetup(area); - - // Only do this once. If the row is "thrown" and we start - // layout over again, we can skip this. - if (cellArray == null) { - initCellArray(); - // check to make sure this row hasn't been partially - // laid out yet (with an id created already) - area.getIDReferences().createID(id); - configID = true; - } - - this.marker = 0; - int breakStatus = propMgr.checkBreakBefore(area); - if (breakStatus != Status.OK) - return new Status(breakStatus); - } - - // if (marker == 0 && configID) { - if (marker == 0) { // KDL: need to do this if thrown or if split? - // configure id - area.getIDReferences().configureID(id, area); - } - - int spaceLeft = area.spaceLeft(); - - this.areaContainer = - new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0, 0, - area.getContentWidth(), spaceLeft, - Position.RELATIVE); - areaContainer.foCreator = this; // G Seshadri - areaContainer.setPage(area.getPage()); - - areaContainer.setBackgroundColor(backgroundColor); - areaContainer.start(); - - areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); - areaContainer.setIDReferences(area.getIDReferences()); - - largestCellHeight = minHeight; - - // Flag indicaing whether any cell didn't fit in available space - boolean someCellDidNotLayoutCompletely = false; - - /* - * If it takes multiple calls to completely layout the row, - * we need to process all of the children (cells) - * not just those from the marker so that the borders - * will be drawn properly. - */ - int offset = 0; // Offset of each cell from table start edge - int iColIndex = 0; // 1-based column index - Iterator eCols = columns.iterator(); - /* - * Ideas: set offset on each column when they are initialized - * no need to calculate for each row. - * Pass column object to cell to get offset and width and border - * info if borders are "collapsed". - */ - - while (eCols.hasNext()) { - TableCell cell; - ++iColIndex; - TableColumn tcol = (TableColumn)eCols.next(); - int colWidth = tcol.getColumnWidth(); - if (cellArray.getCellType(iColIndex) == CellArray.CELLSTART) { - cell = cellArray.getCell(iColIndex); - } else { - /* - * If this cell is spanned from a previous row, - * and this is the last row, get the remaining height - * and use it to increase maxCellHeight if necessary - */ - if (rowSpanMgr.isInLastRow(iColIndex)) { - int h = rowSpanMgr.getRemainingHeight(iColIndex); - if (h > largestCellHeight) - largestCellHeight = h; - } - offset += colWidth; - continue; - } - // cell.setTableColumn(tcol); - cell.setStartOffset(offset); - offset += colWidth; - - - int rowSpan = cell.getNumRowsSpanned(); - Status status; - if ((status = cell.layout(areaContainer)).isIncomplete()) { - if ((keepTogether.getType() == KeepValue.KEEP_WITH_ALWAYS) - || (status.getCode() == Status.AREA_FULL_NONE) - || rowSpan > 1) { - // We will put this row into the next column/page - // Note: the only time this shouldn't be honored is - // if this row is at the top of the column area. - // Remove spanning cells from RowSpanMgr? - this.resetMarker(); - return new Status(Status.AREA_FULL_NONE); - } else if (status.getCode() == Status.AREA_FULL_SOME) { - /* - * Row is not keep-together, cell isn't spanning - * and part of it fits. We can break the cell and - * the row. - */ - someCellDidNotLayoutCompletely = true; - } - } // else { - // layout was complete for a particular cell - int h = cell.getHeight(); // allocation height of cell - if (rowSpan > 1) { // pass cell fo or area??? - rowSpanMgr.addRowSpan(cell, iColIndex, - cell.getNumColumnsSpanned(), h, - rowSpan); - } else if (h > largestCellHeight) { - largestCellHeight = h; - } - // } - } // end of loop over all columns/cells - - // This is in case a float was composed in the cells - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); - - // Only do this for "STARTCELL", ending spans are handled separately - // What about empty cells? Yes, we should set their height too! - for (int iCol = 1; iCol <= columns.size(); iCol++) { - if (cellArray.getCellType(iCol) == CellArray.CELLSTART - && rowSpanMgr.isSpanned(iCol) == false) { - cellArray.getCell(iCol).setRowHeight(largestCellHeight); - } - } - - // Adjust spanning row information - // ??? what if some cells are broken??? - rowSpanMgr.finishRow(largestCellHeight); - - area.addChild(areaContainer); - areaContainer.setHeight(largestCellHeight); - areaAdded = true; - areaContainer.end(); - - /* - * The method addDisplaySpace increases both the content - * height of the parent area (table body, head or footer) and - * also its "absolute height". So we don't need to do this - * explicitly. - * - * Note: it doesn't look from the CR as though we should take - * into account borders and padding on rows, only background. - * The exception is perhaps if the borders are "collapsed", but - * they should still be rendered only on cells and not on the - * rows themselves. (Karen Lease - 01may2001) - */ - area.addDisplaySpace(largestCellHeight - + areaContainer.getPaddingTop() - + areaContainer.getBorderTopWidth() - + areaContainer.getPaddingBottom() - + areaContainer.getBorderBottomWidth()); - - - // replaced by Hani Elabed 11/27/2000 - // return new Status(Status.OK); - - if (someCellDidNotLayoutCompletely) { - return new Status(Status.AREA_FULL_SOME); - } else { - if (rowSpanMgr.hasUnfinishedSpans()) { - // Ignore break after if row span! - return new Status(Status.KEEP_WITH_NEXT); - } - if (breakAfter == BreakAfter.PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakAfter == BreakAfter.ODD_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakAfter == BreakAfter.EVEN_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - - if (breakAfter == BreakAfter.COLUMN) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_COLUMN_BREAK); - } - if (keepWithNext.getType() != KeepValue.KEEP_WITH_AUTO) { - return new Status(Status.KEEP_WITH_NEXT); - } - return new Status(Status.OK); - } - - } - - public int getAreaHeight() { - return areaContainer.getHeight(); - } - - public void removeLayout(Area area) { - if (areaAdded) - area.removeChild(areaContainer); - areaAdded = false; - this.resetMarker(); - } - - public void resetMarker() { - super.resetMarker(); - // Just reset all the states to not laid out and fix up row spans - } - /** * Called by parent FO to initialize information about * cells started in previous rows which span into this row. diff --git a/src/org/apache/fop/fo/pagination/PageSequence.java b/src/org/apache/fop/fo/pagination/PageSequence.java index e77b11085..2ff146c3a 100644 --- a/src/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/org/apache/fop/fo/pagination/PageSequence.java @@ -691,10 +691,10 @@ public class PageSequence extends FObj { Flow flow = (Flow)_flowMap.get(region.getRegionName()); - if ((null == flow) || flow.getStatus().isIncomplete()) + /*if ((null == flow) || flow.getStatus().isIncomplete()) return false; else - return true; + return true;*/ } return false; } diff --git a/src/org/apache/fop/fo/pagination/Root.java b/src/org/apache/fop/fo/pagination/Root.java index 7d81f4dbf..a9dd133d5 100644 --- a/src/org/apache/fop/fo/pagination/Root.java +++ b/src/org/apache/fop/fo/pagination/Root.java @@ -11,7 +11,6 @@ package org.apache.fop.fo.pagination; import org.apache.fop.fo.*; import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.AreaTree; import org.apache.fop.apps.FOPException; // Java |