From 7043c9829a66de30102b9a4ea839cc1633aa1db1 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Thu, 20 Jun 2002 09:14:16 +0000 Subject: [PATCH] removed old area tree git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194902 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/apps/Driver.java | 7 - src/org/apache/fop/apps/PrintStarter.java | 6 +- .../apache/fop/datatypes/IDReferences.java | 34 - src/org/apache/fop/fo/FONode.java | 13 - src/org/apache/fop/fo/FOText.java | 12 - src/org/apache/fop/fo/FOTreeBuilder.java | 1 - src/org/apache/fop/fo/FObj.java | 21 - src/org/apache/fop/fo/FObjMixed.java | 26 +- src/org/apache/fop/fo/PropertyManager.java | 6 +- src/org/apache/fop/fo/Title.java | 6 +- .../apache/fop/fo/ToBeImplementedElement.java | 4 +- src/org/apache/fop/fo/Unknown.java | 4 +- src/org/apache/fop/fo/UnknownXMLObj.java | 11 - src/org/apache/fop/fo/XMLElement.java | 20 - src/org/apache/fop/fo/XMLObj.java | 15 - src/org/apache/fop/fo/flow/BasicLink.java | 52 +- src/org/apache/fop/fo/flow/BidiOverride.java | 1 - src/org/apache/fop/fo/flow/Block.java | 193 +-- .../apache/fop/fo/flow/BlockContainer.java | 79 +- .../apache/fop/fo/flow/ExternalGraphic.java | 24 +- src/org/apache/fop/fo/flow/Float.java | 3 +- src/org/apache/fop/fo/flow/Flow.java | 112 -- src/org/apache/fop/fo/flow/Footnote.java | 84 +- src/org/apache/fop/fo/flow/FootnoteBody.java | 37 - .../fop/fo/flow/InitialPropertySet.java | 4 +- .../fop/fo/flow/InstreamForeignObject.java | 145 +- src/org/apache/fop/fo/flow/Leader.java | 93 +- src/org/apache/fop/fo/flow/ListBlock.java | 84 +- src/org/apache/fop/fo/flow/ListItem.java | 97 +- src/org/apache/fop/fo/flow/ListItemBody.java | 23 +- src/org/apache/fop/fo/flow/ListItemLabel.java | 16 +- src/org/apache/fop/fo/flow/Marker.java | 31 - src/org/apache/fop/fo/flow/MultiCase.java | 3 +- .../apache/fop/fo/flow/MultiProperties.java | 3 +- .../apache/fop/fo/flow/MultiPropertySet.java | 3 +- src/org/apache/fop/fo/flow/MultiSwitch.java | 3 +- src/org/apache/fop/fo/flow/MultiToggle.java | 3 +- src/org/apache/fop/fo/flow/PageNumber.java | 23 +- .../fop/fo/flow/PageNumberCitation.java | 61 +- .../apache/fop/fo/flow/RetrieveMarker.java | 111 -- src/org/apache/fop/fo/flow/RowSpanMgr.java | 2 - src/org/apache/fop/fo/flow/StaticContent.java | 53 +- src/org/apache/fop/fo/flow/Table.java | 486 +----- .../apache/fop/fo/flow/TableAndCaption.java | 3 +- src/org/apache/fop/fo/flow/TableBody.java | 185 +-- src/org/apache/fop/fo/flow/TableCaption.java | 3 +- src/org/apache/fop/fo/flow/TableCell.java | 171 --- src/org/apache/fop/fo/flow/TableColumn.java | 41 +- src/org/apache/fop/fo/flow/TableFooter.java | 8 - src/org/apache/fop/fo/flow/TableRow.java | 227 +-- .../fop/fo/pagination/PageSequence.java | 4 +- src/org/apache/fop/fo/pagination/Root.java | 1 - src/org/apache/fop/layout/Area.java | 414 ----- src/org/apache/fop/layout/AreaContainer.java | 75 - src/org/apache/fop/layout/AreaTree.java | 95 -- src/org/apache/fop/layout/BlockArea.java | 228 --- .../apache/fop/layout/BodyAreaContainer.java | 390 ----- src/org/apache/fop/layout/BodyRegionArea.java | 49 - src/org/apache/fop/layout/Box.java | 15 - src/org/apache/fop/layout/ColumnArea.java | 53 - src/org/apache/fop/layout/DisplaySpace.java | 23 - src/org/apache/fop/layout/ExtensionArea.java | 32 - src/org/apache/fop/layout/LineArea.java | 1336 ----------------- src/org/apache/fop/layout/LinkSet.java | 163 -- .../apache/fop/layout/LinkedRectangle.java | 107 -- src/org/apache/fop/layout/Page.java | 221 --- src/org/apache/fop/layout/RegionArea.java | 46 - src/org/apache/fop/layout/Space.java | 10 - src/org/apache/fop/layout/SpanArea.java | 120 -- .../fop/layout/inline/ForeignObjectArea.java | 206 --- .../apache/fop/layout/inline/InlineArea.java | 115 -- .../apache/fop/layout/inline/InlineSpace.java | 90 -- .../apache/fop/layout/inline/LeaderArea.java | 59 - .../layout/inline/PageNumberInlineArea.java | 23 - .../apache/fop/layout/inline/WordArea.java | 42 - src/org/apache/fop/pdf/PDFDocument.java | 5 +- src/org/apache/fop/pdf/PDFLink.java | 2 + .../apache/fop/render/awt/AWTRenderer.java | 2 +- .../apache/fop/render/pdf/PDFRenderer.java | 2 +- src/org/apache/fop/svg/PDFANode.java | 4 +- src/org/apache/fop/svg/PDFGraphics2D.java | 2 +- .../apache/fop/svg/PDFTextElementBridge.java | 1 + src/org/apache/fop/svg/SVGElement.java | 1 - 83 files changed, 72 insertions(+), 6517 deletions(-) delete mode 100644 src/org/apache/fop/layout/Area.java delete mode 100644 src/org/apache/fop/layout/AreaContainer.java delete mode 100644 src/org/apache/fop/layout/AreaTree.java delete mode 100644 src/org/apache/fop/layout/BlockArea.java delete mode 100644 src/org/apache/fop/layout/BodyAreaContainer.java delete mode 100644 src/org/apache/fop/layout/BodyRegionArea.java delete mode 100644 src/org/apache/fop/layout/Box.java delete mode 100644 src/org/apache/fop/layout/ColumnArea.java delete mode 100644 src/org/apache/fop/layout/DisplaySpace.java delete mode 100644 src/org/apache/fop/layout/ExtensionArea.java delete mode 100644 src/org/apache/fop/layout/LineArea.java delete mode 100644 src/org/apache/fop/layout/LinkSet.java delete mode 100644 src/org/apache/fop/layout/LinkedRectangle.java delete mode 100644 src/org/apache/fop/layout/Page.java delete mode 100644 src/org/apache/fop/layout/RegionArea.java delete mode 100644 src/org/apache/fop/layout/Space.java delete mode 100644 src/org/apache/fop/layout/SpanArea.java delete mode 100644 src/org/apache/fop/layout/inline/ForeignObjectArea.java delete mode 100644 src/org/apache/fop/layout/inline/InlineArea.java delete mode 100644 src/org/apache/fop/layout/inline/InlineSpace.java delete mode 100644 src/org/apache/fop/layout/inline/LeaderArea.java delete mode 100644 src/org/apache/fop/layout/inline/PageNumberInlineArea.java delete mode 100644 src/org/apache/fop/layout/inline/WordArea.java diff --git a/src/org/apache/fop/apps/Driver.java b/src/org/apache/fop/apps/Driver.java index 76334399e..899be77c5 100644 --- a/src/org/apache/fop/apps/Driver.java +++ b/src/org/apache/fop/apps/Driver.java @@ -11,7 +11,6 @@ package org.apache.fop.apps; import org.apache.fop.fo.FOUserAgent; import org.apache.fop.fo.FOTreeBuilder; import org.apache.fop.fo.ElementMapping; -import org.apache.fop.layout.AreaTree; import org.apache.fop.render.Renderer; import org.apache.fop.configuration.ConfigurationReader; import org.apache.fop.configuration.Configuration; @@ -138,11 +137,6 @@ public class Driver { */ private FOTreeBuilder _treeBuilder; - /** - * the area tree that is the result of formatting the FO tree - */ - private AreaTree _areaTree; - /** * the renderer to use to output the area tree */ @@ -242,7 +236,6 @@ public class Driver { * The output stream is cleared. The renderer is cleared. */ public synchronized void reset() { - _areaTree = null; _source = null; _stream = null; _reader = null; diff --git a/src/org/apache/fop/apps/PrintStarter.java b/src/org/apache/fop/apps/PrintStarter.java index 21b160e1b..11154f1e6 100644 --- a/src/org/apache/fop/apps/PrintStarter.java +++ b/src/org/apache/fop/apps/PrintStarter.java @@ -31,8 +31,6 @@ import java.io.IOException; import java.util.Vector; import org.apache.fop.render.awt.AWTRenderer; -import org.apache.fop.layout.AreaTree; -import org.apache.fop.layout.Page; /** * This class prints a xsl-fo dokument without interaction. @@ -154,10 +152,10 @@ public class PrintStarter extends CommandLineStarter { } } - public void renderPage(Page page) { + /*public void renderPage(Page page) { pageWidth = (int)((float)page.getWidth() / 1000f); pageHeight = (int)((float)page.getHeight() / 1000f); - } + }*/ private Vector getInvalidPageNumbers() { diff --git a/src/org/apache/fop/datatypes/IDReferences.java b/src/org/apache/fop/datatypes/IDReferences.java index 8f157cc81..8ee8e3249 100644 --- a/src/org/apache/fop/datatypes/IDReferences.java +++ b/src/org/apache/fop/datatypes/IDReferences.java @@ -8,7 +8,6 @@ package org.apache.fop.datatypes; import org.apache.fop.pdf.PDFGoTo; -import org.apache.fop.layout.AreaContainer; // Java @@ -16,7 +15,6 @@ import java.util.Hashtable; import java.util.Vector; import java.util.Enumeration; import java.util.NoSuchElementException; -import org.apache.fop.layout.Area; import org.apache.fop.apps.FOPException; /** @@ -48,20 +46,6 @@ public class IDReferences { idUnvalidated = new Hashtable(); } - - /** - * Creates and configures the specified id. - * - * @param id The id to initialize - * @param area The area where this id was encountered - * @exception FOPException - */ - public void initializeID(String id, Area area) throws FOPException { - createID(id); - configureID(id, area); - } - - /** * Creates id entry * @@ -134,24 +118,6 @@ public class IDReferences { return idUnvalidated.containsKey(id); } - /** - * Configures this id - * - * @param id The id to configure - * @param area The area where the id was encountered - */ - public void configureID(String id, Area area) { - if (id != null &&!id.equals("")) { - setPosition(id, - area.getPage().getBody().getXPosition() - + area.getTableCellXOffset() - ID_PADDING, - area.getPage().getBody().getYPosition() - - area.getAbsoluteHeight() + ID_PADDING); - setPageNumber(id, area.getPage().getNumber()); - area.getPage().addToIDList(id); - } - } - /** * Adds id to validation list to be validated . This should be used if it is unsure whether the id is valid * 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 @@ -72,18 +71,6 @@ abstract public class FONode { // ignore } - /** - * 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); - } - /** * */ 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; @@ -30,11 +28,6 @@ public class Flow extends FObj { */ private PageSequence pageSequence; - /** - * Area in which we lay out our kids - */ - private Area area; - /** * ArrayList to store snapshot */ @@ -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 diff --git a/src/org/apache/fop/layout/Area.java b/src/org/apache/fop/layout/Area.java deleted file mode 100644 index 4ac0c935d..000000000 --- a/src/org/apache/fop/layout/Area.java +++ /dev/null @@ -1,414 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -// FOP -import org.apache.fop.datatypes.*; -import org.apache.fop.fo.flow.Marker; -import org.apache.fop.layout.inline.InlineSpace; - -// Java -import java.util.Vector; -import java.util.Hashtable; - -abstract public class Area extends Box { - - /* - * nominal font size and nominal font family incorporated in - * fontState - */ - protected FontState fontState; - protected BorderAndPadding bp = null; - - protected Vector children = new Vector(); - - /* max size in line-progression-direction */ - protected int maxHeight; - - /** - * Total height of content of this area. - */ - protected int currentHeight = 0; - - // used to keep track of the current x position within a table. Required for drawing rectangle links. - protected int tableCellXOffset = 0; - - // used to keep track of the absolute height on the page. Required for drawing rectangle links. - private int absoluteHeight = 0; - - protected int contentRectangleWidth; - - protected int allocationWidth; - - /* the page this area is on */ - protected Page page; - - protected ColorType backgroundColor; - - private IDReferences idReferences; - - protected Vector markers; - - // as defined in Section 6.1.1 - protected org.apache.fop.fo.FObj generatedBy; // corresponds to 'generated-by' trait - protected Hashtable returnedBy; - - // as defined in Section 6.1.1 - protected String areaClass; - - // as defined in Section 4.2.2 - protected boolean isFirst = false; - protected boolean isLast = false; - - /* - * author : Seshadri G - * * the fo which created it - */ - // This is deprecated and should be phased out in - // favour of using 'generatedBy' - public org.apache.fop.fo.FObj foCreator; - - public Area(FontState fontState) { - setFontState(fontState); - this.markers = new Vector(); - this.returnedBy = new Hashtable(); - } - - /** - * Creates a new Area instance. - * - * @param fontState a FontState value - * @param allocationWidth the inline-progression dimension of the content - * rectangle of the Area - * @param maxHeight the maximum block-progression dimension available - * for this Area (its allocation rectangle) - */ - public Area(FontState fontState, int allocationWidth, int maxHeight) { - setFontState(fontState); - this.allocationWidth = allocationWidth; - this.contentRectangleWidth = allocationWidth; - this.maxHeight = maxHeight; - this.markers = new Vector(); - this.returnedBy = new Hashtable(); - } - - private void setFontState(FontState fontState) { - // fontState.setFontInfo(this.page.getFontInfo()); - this.fontState = fontState; - } - - public void addChild(Box child) { - this.children.addElement(child); - child.parent = this; - } - - public void addChildAtStart(Box child) { - this.children.insertElementAt(child, 0); - child.parent = this; - } - - public void addDisplaySpace(int size) { - this.addChild(new DisplaySpace(size)); - this.absoluteHeight += size; - this.currentHeight += size; - } - - public void addInlineSpace(int size) { - this.addChild(new InlineSpace(size)); - // other adjustments... - } - - public FontInfo getFontInfo() { - return this.page.getFontInfo(); - } - - public void end() {} - - public int getAllocationWidth() { - /* - * ATTENTION: this may change your output!! (Karen Lease, 4mar2001) - * return this.allocationWidth - getPaddingLeft() - getPaddingRight() - * - getBorderLeftWidth() - getBorderRightWidth(); - */ - return this.allocationWidth; - } - - /** - * Set the allocation width. - * @param w The new allocation width. - * This sets content width to the same value. - * Currently only called during layout of Table to set the width - * to the total width of all the columns. Note that this assumes the - * column widths are explicitly specified. - */ - public void setAllocationWidth(int w) { - this.allocationWidth = w; - this.contentRectangleWidth = this.allocationWidth; - } - - public Vector getChildren() { - return this.children; - } - - public boolean hasChildren() { - return (this.children.size() != 0); - } - - public int getContentWidth() { - /* - * ATTENTION: this may change your output!! (Karen Lease, 4mar2001) - * return contentRectangleWidth - getPaddingLeft() - getPaddingRight() - * - getBorderLeftWidth() - getBorderRightWidth(); - */ - return contentRectangleWidth; - } - - public FontState getFontState() { - return this.fontState; - } - - /** - * Returns content height of the area. - * - * @return Content height in millipoints - */ - public int getContentHeight() { - return this.currentHeight; - } - - /** - * Returns allocation height of this area. - * The allocation height is the sum of the content height plus border - * and padding in the vertical direction. - * - * @return allocation height in millipoints - */ - public int getHeight() { - return this.currentHeight + getPaddingTop() + getPaddingBottom() - + getBorderTopWidth() + getBorderBottomWidth(); - } - - public int getMaxHeight() { - // Change KDL: return max height of content rectangle - return this.maxHeight; - /* - * return this.maxHeight - getPaddingTop() - getPaddingBottom() - - * getBorderTopWidth() - getBorderBottomWidth(); - */ - } - - public Page getPage() { - return this.page; - } - - public ColorType getBackgroundColor() { - return this.backgroundColor; - } - - // Must handle conditionality here, depending on isLast/isFirst - public int getPaddingTop() { - return (bp == null ? 0 : bp.getPaddingTop(false)); - } - - public int getPaddingLeft() { - return (bp == null ? 0 : bp.getPaddingLeft(false)); - } - - public int getPaddingBottom() { - return (bp == null ? 0 : bp.getPaddingBottom(false)); - } - - public int getPaddingRight() { - return (bp == null ? 0 : bp.getPaddingRight(false)); - } - - // Handle border-width, including conditionality - // For now, just pass false everywhere! - public int getBorderTopWidth() { - return (bp == null ? 0 : bp.getBorderTopWidth(false)); - } - - public int getBorderRightWidth() { - return (bp == null ? 0 : bp.getBorderRightWidth(false)); - } - - public int getBorderLeftWidth() { - return (bp == null ? 0 : bp.getBorderLeftWidth(false)); - } - - public int getBorderBottomWidth() { - return (bp == null ? 0 : bp.getBorderBottomWidth(false)); - } - - public int getTableCellXOffset() { - return tableCellXOffset; - } - - public void setTableCellXOffset(int offset) { - tableCellXOffset = offset; - } - - public int getAbsoluteHeight() { - return absoluteHeight; - } - - public void setAbsoluteHeight(int value) { - absoluteHeight = value; - } - - public void increaseAbsoluteHeight(int value) { - absoluteHeight += value; - } - - public void increaseHeight(int amount) { - this.currentHeight += amount; - this.absoluteHeight += amount; - } - - // Remove allocation height of child - public void removeChild(Area area) { - this.currentHeight -= area.getHeight(); - this.absoluteHeight -= area.getHeight(); - this.children.removeElement(area); - } - - public void removeChild(DisplaySpace spacer) { - this.currentHeight -= spacer.getSize(); - this.absoluteHeight -= spacer.getSize(); - this.children.removeElement(spacer); - } - - public void remove() { - this.parent.removeChild(this); - } - - public void setPage(Page page) { - this.page = page; - } - - public void setBackgroundColor(ColorType bgColor) { - this.backgroundColor = bgColor; - } - - public void setBorderAndPadding(BorderAndPadding bp) { - this.bp = bp; - } - - /** - * Return space remaining in the vertical direction (height). - * This returns maximum available space - current content height - * Note: content height should be based on allocation height of content! - * @return space remaining in base units (millipoints) - */ - public int spaceLeft() { - return maxHeight - currentHeight; - } - - public void start() {} - - - /** - * Set the content height to the passed value if that value is - * larger than current content height. If the new content height - * is greater than the maximum available height, set the content height - * to the max. available (!!!) - * - * @param height allocation height of content in millipoints - */ - public void setHeight(int height) { - int prevHeight = currentHeight; - if (height > currentHeight) { - currentHeight = height; - } - - if (currentHeight > getMaxHeight()) { - currentHeight = getMaxHeight(); - } - absoluteHeight += (currentHeight - prevHeight); - } - - public void setMaxHeight(int height) { - this.maxHeight = height; - } - - public Area getParent() { - return this.parent; - } - - public void setParent(Area parent) { - this.parent = parent; - } - - public void setIDReferences(IDReferences idReferences) { - this.idReferences = idReferences; - } - - public IDReferences getIDReferences() { - return idReferences; - } - - /* Author seshadri */ - public org.apache.fop.fo.FObj getfoCreator() { - return this.foCreator; - } - - // Function not currently used! (KLease, 16mar01) - - public AreaContainer getNearestAncestorAreaContainer() { - Area area = this.getParent(); - while (!(area instanceof AreaContainer)) { - area = area.getParent(); - } - return (AreaContainer)area; - } - - public BorderAndPadding getBorderAndPadding() { - return bp; - } - - public void addMarker(Marker marker) { - markers.addElement(marker); - } - - public void addMarkers(Vector markers) { - markers.addAll(markers); - } - - public void addLineagePair(org.apache.fop.fo.FObj fo, int areaPosition) { - returnedBy.put(fo, new Integer(areaPosition)); - } - - public Vector getMarkers() { - return markers; - } - - public void setGeneratedBy(org.apache.fop.fo.FObj generatedBy) { - this.generatedBy = generatedBy; - } - - public org.apache.fop.fo.FObj getGeneratedBy() { - return generatedBy; - } - - public void isFirst(boolean isFirst) { - this.isFirst = isFirst; - } - - public boolean isFirst() { - return isFirst; - } - - public void isLast(boolean isLast) { - this.isLast = isLast; - } - - public boolean isLast() { - return isLast; - } - -} diff --git a/src/org/apache/fop/layout/AreaContainer.java b/src/org/apache/fop/layout/AreaContainer.java deleted file mode 100644 index 086043ac2..000000000 --- a/src/org/apache/fop/layout/AreaContainer.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -// FOP -import org.apache.fop.render.Renderer; -import org.apache.fop.fo.properties.*; - -// Java -import java.util.Vector; -import java.util.Enumeration; - -public class AreaContainer extends Area { - - private int xPosition; // should be able to take value 'left' and 'right' too - private int yPosition; // should be able to take value 'top' and 'bottom' too - private int position; - - // use this for identifying the general usage of the area, - // like 'main-reference-area' or 'region-before' - private String areaName; - - public AreaContainer(FontState fontState, int xPosition, int yPosition, - int allocationWidth, int maxHeight, int position) { - super(fontState, allocationWidth, maxHeight); - this.xPosition = xPosition; - this.yPosition = yPosition; - this.position = position; - // setIsReferenceArea(true); // Should always be true! - } - - public int getPosition() { - return position; - } - - public int getXPosition() { - // return xPosition + getPaddingLeft() + getBorderLeftWidth(); - return xPosition; - } - - public void setXPosition(int value) { - xPosition = value; - } - - public int getYPosition() { - // return yPosition + getPaddingTop() + getBorderTopWidth(); - return yPosition; - } - - public int getCurrentYPosition() { - return yPosition; - } - - public void setYPosition(int value) { - yPosition = value; - } - - public void shiftYPosition(int value) { - yPosition += value; - } - - public String getAreaName() { - return areaName; - } - - public void setAreaName(String areaName) { - this.areaName = areaName; - } - -} diff --git a/src/org/apache/fop/layout/AreaTree.java b/src/org/apache/fop/layout/AreaTree.java deleted file mode 100644 index 12554efd0..000000000 --- a/src/org/apache/fop/layout/AreaTree.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -// FOP -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.flow.StaticContent; -import org.apache.fop.svg.*; -import org.apache.fop.render.Renderer; -import org.apache.fop.datatypes.IDReferences; -import org.apache.fop.extensions.ExtensionObj; -import org.apache.fop.fo.pagination.PageSequence; - -// Java -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Enumeration; -import java.util.Stack; -import java.util.Vector; - -/* - * Modified by Mark Lillywhite, mark-fop@inomial.com. No longer keeps - a list of pages in the tree, instead these are passed to the - StreamRenderer. No longer keeps it's own list of IDReferences; - these are handled by StreamRenderer. In many ways StreamRenderer - has taken over from AreaTree and possibly this might be a better - place to deal with things in the future..?

- - Any extensions added to the AreaTree while generating a page - are given to the Page for the renderer to deal with. - */ - -public class AreaTree { - - /** - * object containing information on available fonts, including - * metrics - */ - FontInfo fontInfo; - - /** - * List of root extension objects - */ - Vector rootExtensions = null; - - public AreaTree() { - } - - public void setFontInfo(FontInfo fontInfo) { - this.fontInfo = fontInfo; - } - - public FontInfo getFontInfo() { - return this.fontInfo; - } - - public Page getNextPage(Page current, boolean isWithinPageSequence, - boolean isFirstCall) { - //return streamRenderer.getNextPage(current, isWithinPageSequence,isFirstCall); - return null; // This will go away in new layout! - } - - public Page getPreviousPage(Page current, boolean isWithinPageSequence, - boolean isFirstCall) { - //return streamRenderer.getPreviousPage(current,isWithinPageSequence,isFirstCall); - return null; // This will go away in new layout! - } - - public void addPage(Page page) - throws FOPException { -// try { -// page.setExtensions(rootExtensions); -// rootExtensions = null; -// streamRenderer.queuePage(page); -// } catch (IOException e) { -// throw new FOPException(e); -// } - } - - public IDReferences getIDReferences() { - return null;//streamRenderer.getIDReferences(); - } - - public void addExtension(ExtensionObj obj) { - if(rootExtensions ==null) - rootExtensions = new Vector(); - rootExtensions.addElement(obj); - } - -} diff --git a/src/org/apache/fop/layout/BlockArea.java b/src/org/apache/fop/layout/BlockArea.java deleted file mode 100644 index c8d4a99a9..000000000 --- a/src/org/apache/fop/layout/BlockArea.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -// FOP -import org.apache.fop.render.Renderer; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.*; -import org.apache.fop.apps.*; -import org.apache.fop.fo.properties.*; - -// Java -import java.util.Vector; -import java.util.Enumeration; - -/** - * This class represents a Block Area. - * A block area is made up of a sequence of Line Areas. - * - * This class is used to organise the sequence of line areas as - * inline areas are added to this block it creates and ands line areas - * to hold the inline areas. - * This uses the line-height and line-stacking-strategy to work - * out how to stack the lines. - */ -public class BlockArea extends Area { - - /* relative to area container */ - protected int startIndent; - protected int endIndent; - - /* first line startIndent modifier */ - protected int textIndent; - - protected int lineHeight; - - protected int halfLeading; - - - /* text-align of all but the last line */ - protected int align; - - /* text-align of the last line */ - protected int alignLastLine; - - protected LineArea currentLineArea; - protected LinkSet currentLinkSet; - - /* have any line areas been used? */ - protected boolean hasLines = false; - - /* hyphenation */ - protected HyphenationProps hyphProps; - - protected Vector pendingFootnotes = null; - - public BlockArea(FontState fontState, int allocationWidth, int maxHeight, - int startIndent, int endIndent, int textIndent, - int align, int alignLastLine, int lineHeight) { - super(fontState, allocationWidth, maxHeight); - - this.startIndent = startIndent; - this.endIndent = endIndent; - this.textIndent = textIndent; - this.contentRectangleWidth = allocationWidth - startIndent - - endIndent; - this.align = align; - this.alignLastLine = alignLastLine; - this.lineHeight = lineHeight; - - if (fontState != null) - this.halfLeading = (lineHeight - fontState.getFontSize()) / 2; - } - - /** - * Add a Line Area to this block area. - * Used internally to add a completed line area to this block area - * when either a new line area is created or this block area is - * completed. - * - * @param la the LineArea to add - */ - protected void addLineArea(LineArea la) { - if (!la.isEmpty()) { - la.verticalAlign(); - this.addDisplaySpace(this.halfLeading); - int size = la.getHeight(); - this.addChild(la); - this.increaseHeight(size); - this.addDisplaySpace(this.halfLeading); - } - // add pending footnotes - if (pendingFootnotes != null) { - for (Enumeration e = pendingFootnotes.elements(); - e.hasMoreElements(); ) { - FootnoteBody fb = (FootnoteBody)e.nextElement(); - Page page = getPage(); - if (!Footnote.layoutFootnote(page, fb, this)) { - page.addPendingFootnote(fb); - } - } - pendingFootnotes = null; - } - } - - /** - * Get the current line area in this block area. - * This is used to get the current line area for adding - * inline objects to. - * This will return null if there is not enough room left - * in the block area to accomodate the line area. - * - * @return the line area to be used to add inlie objects - */ - public LineArea getCurrentLineArea() { - if (currentHeight + lineHeight > maxHeight) { - return null; - } - this.currentLineArea.changeHyphenation(hyphProps); - this.hasLines = true; - return this.currentLineArea; - } - - /** - * Create a new line area to add inline objects. - * This should be called after getting the current line area - * and discovering that the inline object will not fit inside the current - * line. This method will create a new line area to place the inline - * object into. - * This will return null if the new line cannot fit into the block area. - * - * @return the new current line area, which will be empty. - */ - public LineArea createNextLineArea() { - if (this.hasLines) { - this.currentLineArea.align(this.align); - this.addLineArea(this.currentLineArea); - } - this.currentLineArea = new LineArea(fontState, lineHeight, - halfLeading, allocationWidth, - startIndent, endIndent, - currentLineArea); - this.currentLineArea.changeHyphenation(hyphProps); - if (currentHeight + lineHeight > maxHeight) { - return null; - } - return this.currentLineArea; - } - - public void setupLinkSet(LinkSet ls) { - if (ls != null) { - this.currentLinkSet = ls; - ls.setYOffset(currentHeight); - } - } - - /** - * Notify this block that the area has completed layout. - * Indicates the the block has been fully laid out, this will - * add (if any) the current line area. - */ - public void end() { - if (this.hasLines) { - this.currentLineArea.addPending(); - this.currentLineArea.align(this.alignLastLine); - this.addLineArea(this.currentLineArea); - } - } - - public void start() { - currentLineArea = new LineArea(fontState, lineHeight, halfLeading, - allocationWidth, - startIndent + textIndent, endIndent, - null); - } - - public int getEndIndent() { - return endIndent; - } - - // KL: I think we should just return startIndent here! - public int getStartIndent() { - // return startIndent + paddingLeft + borderWidthLeft; - return startIndent; - } - - public void setIndents(int startIndent, int endIndent) { - this.startIndent = startIndent; - this.endIndent = endIndent; - this.contentRectangleWidth = allocationWidth - startIndent - - endIndent; - } - - /** - * Return the maximum space remaining for this area's content in - * the block-progression-dimension. - * Remove top and bottom padding and spacing since these reduce - * available space for content and they are not yet accounted for - * in the positioning of the object. - */ - public int spaceLeft() { - // return maxHeight - currentHeight ; - return maxHeight - currentHeight - - (getPaddingTop() + getPaddingBottom() - + getBorderTopWidth() + getBorderBottomWidth()); - } - - public int getHalfLeading() { - return halfLeading; - } - - public void setHyphenation(HyphenationProps hyphProps) { - this.hyphProps = hyphProps; - } - - public void addFootnote(FootnoteBody fb) { - if (pendingFootnotes == null) { - pendingFootnotes = new Vector(); - } - pendingFootnotes.addElement(fb); - } - -} diff --git a/src/org/apache/fop/layout/BodyAreaContainer.java b/src/org/apache/fop/layout/BodyAreaContainer.java deleted file mode 100644 index f94924d4b..000000000 --- a/src/org/apache/fop/layout/BodyAreaContainer.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -// FOP -import org.apache.fop.render.Renderer; -import org.apache.fop.fo.properties.*; -import org.apache.fop.datatypes.IDReferences; -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.FObj; -import org.apache.fop.fo.flow.Block; -import org.apache.fop.fo.flow.BlockContainer; - -// Java -import java.util.Vector; -import java.util.Enumeration; - -public class BodyAreaContainer extends Area { - - // dimensions for the 'region-reference-area' - private int xPosition; // should be able to take value 'left' and 'right' too - private int yPosition; // should be able to take value 'top' and 'bottom' too - private int position; - - // the column-count and column-gap - private int columnCount; - private int columnGap; - - // the 3 primary reference areas - private AreaContainer mainReferenceArea; - private AreaContainer beforeFloatReferenceArea; - private AreaContainer footnoteReferenceArea; - - // current heights - private int mainRefAreaHeight; - private int beforeFloatRefAreaHeight; - private int footnoteRefAreaHeight; - - // reference area yPositions - private int mainYPosition; - private int beforeFloatYPosition; - private int footnoteYPosition; - - // the start FO in case of rollback - private FObj startFO; - private boolean isNewSpanArea; - - // keeps track of footnote state for multiple layouts - private int footnoteState = 0; - - public BodyAreaContainer(FontState fontState, int xPosition, - int yPosition, int allocationWidth, - int maxHeight, int position, int columnCount, - int columnGap) { - super(fontState, allocationWidth, maxHeight); - this.xPosition = xPosition; - this.yPosition = yPosition; - this.position = position; - this.columnCount = columnCount; - this.columnGap = columnGap; - - // create the primary reference areas - beforeFloatRefAreaHeight = 0; - footnoteRefAreaHeight = 0; - mainRefAreaHeight = maxHeight - beforeFloatRefAreaHeight - - footnoteRefAreaHeight; - beforeFloatReferenceArea = new AreaContainer(fontState, xPosition, - yPosition, allocationWidth, beforeFloatRefAreaHeight, - Position.ABSOLUTE); - beforeFloatReferenceArea.setAreaName("before-float-reference-area"); - this.addChild(beforeFloatReferenceArea); - mainReferenceArea = new AreaContainer(fontState, xPosition, - yPosition, allocationWidth, - mainRefAreaHeight, - Position.ABSOLUTE); - mainReferenceArea.setAreaName("main-reference-area"); - this.addChild(mainReferenceArea); - int footnoteRefAreaYPosition = yPosition - mainRefAreaHeight; - footnoteReferenceArea = new AreaContainer(fontState, xPosition, - footnoteRefAreaYPosition, - allocationWidth, - footnoteRefAreaHeight, - Position.ABSOLUTE); - footnoteReferenceArea.setAreaName("footnote-reference-area"); - this.addChild(footnoteReferenceArea); - - // all padding and border-width must be 0 - // setBorderAndPadding(new BorderAndPadding()); - // setPadding(0, 0, 0, 0); - // setBorderWidth(0, 0, 0, 0); - } - - public int getPosition() { - return position; - } - - public int getXPosition() { - return xPosition + getPaddingLeft() + getBorderLeftWidth(); - } - - public void setXPosition(int value) { - xPosition = value; - } - - public int getYPosition() { - return yPosition + getPaddingTop() + getBorderTopWidth(); - } - - public void setYPosition(int value) { - yPosition = value; - } - - public AreaContainer getMainReferenceArea() { - return mainReferenceArea; - } - - public AreaContainer getBeforeFloatReferenceArea() { - return beforeFloatReferenceArea; - } - - public AreaContainer getFootnoteReferenceArea() { - return footnoteReferenceArea; - } - - public void setIDReferences(IDReferences idReferences) { - mainReferenceArea.setIDReferences(idReferences); - } - - public IDReferences getIDReferences() { - return mainReferenceArea.getIDReferences(); - } - - /** - * Depending on the column-count of the next FO, determine whether - * a new span area needs to be constructed or not, and return the - * appropriate ColumnArea. - * The next cut of this method should also inspect the FO to see - * whether the area to be returned ought not to be the footnote - * or before-float reference area. - * @param fo The next formatting object - * @returns the next column area (possibly the current one) - */ - public AreaContainer getNextArea(FObj fo) throws FOPException { - isNewSpanArea = false; - - int span = Span.NONE; - if (fo instanceof Block) - span = ((Block)fo).getSpan(); - else if (fo instanceof BlockContainer) - span = ((BlockContainer)fo).getSpan(); - - if (this.mainReferenceArea.getChildren().isEmpty()) { - if (span == Span.ALL) - return addSpanArea(1); - else - return addSpanArea(columnCount); - } - - Vector spanAreas = this.mainReferenceArea.getChildren(); - SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size() - - 1); - - if ((span == Span.ALL) && (spanArea.getColumnCount() == 1)) { - // return the single column area in the same span area - return spanArea.getCurrentColumnArea(); - } else if ((span == Span.NONE) - && (spanArea.getColumnCount() == columnCount)) { - // return the current column area in the same span area - return spanArea.getCurrentColumnArea(); - } else if (span == Span.ALL) { - // create new span area with one column; return column area - return addSpanArea(1); - } else if (span == Span.NONE) { - // create new span area with multiple columns; return first column area - return addSpanArea(columnCount); - } else { - throw new FOPException("BodyAreaContainer::getNextArea(): Span attribute messed up"); - } - } - - /** - * Add a new span area with specified number of column areas. - * @param numColumns The number of column areas - * @returns AreaContainer The next column area - */ - private AreaContainer addSpanArea(int numColumns) { - resetHeights(); - // create span area and child column-areas, using whatever - // height remains after existing span areas (in the main - // reference area). - int spanAreaYPosition = getYPosition() - - this.mainReferenceArea.getContentHeight(); - - SpanArea spanArea = new SpanArea(fontState, getXPosition(), - spanAreaYPosition, allocationWidth, - getRemainingHeight(), numColumns, - columnGap); - this.mainReferenceArea.addChild(spanArea); - spanArea.setPage(this.getPage()); - this.isNewSpanArea = true; - return spanArea.getCurrentColumnArea(); - } - - /** - * This almost does what getNewArea() does, without actually - * returning an area. These 2 methods can be reworked. - * @param fo The next formatting object - * @returns boolean True if we need to balance. - */ - public boolean isBalancingRequired(FObj fo) { - if (this.mainReferenceArea.getChildren().isEmpty()) - return false; - - Vector spanAreas = this.mainReferenceArea.getChildren(); - SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size() - - 1); - - if (spanArea.isBalanced()) - return false; - - int span = Span.NONE; - if (fo instanceof Block) - span = ((Block)fo).getSpan(); - else if (fo instanceof BlockContainer) - span = ((BlockContainer)fo).getSpan(); - - if ((span == Span.ALL) && (spanArea.getColumnCount() == 1)) - return false; - else if ((span == Span.NONE) - && (spanArea.getColumnCount() == columnCount)) - return false; - else if (span == Span.ALL) - return true; - else if (span == Span.NONE) - return false; - else - return false; - } - - /** - * This is where the balancing algorithm lives, or gets called. - * Right now it's primitive: get the total content height in all - * columns, divide by the column count, and add a heuristic - * safety factor. - * Then the previous (unbalanced) span area is removed, and a new - * one added with the computed max height. - */ - public void resetSpanArea() { - Vector spanAreas = this.mainReferenceArea.getChildren(); - SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size() - - 1); - - if (!spanArea.isBalanced()) { - // span area maintains a record of the total height of - // laid-out content in the previous (first) attempt - int newHeight = spanArea.getTotalContentHeight() - / spanArea.getColumnCount(); - newHeight += 2 * 15600; // ??? - - this.mainReferenceArea.removeChild(spanArea); - resetHeights(); - SpanArea newSpanArea = new SpanArea(fontState, getXPosition(), - spanArea.getYPosition(), - allocationWidth, newHeight, - spanArea.getColumnCount(), - columnGap); - this.mainReferenceArea.addChild(newSpanArea); - newSpanArea.setPage(this.getPage()); - newSpanArea.setIsBalanced(); - this.isNewSpanArea = true; - } else { - throw new IllegalStateException("Trying to balance balanced area"); - } - } - - /** - * Determine remaining height for new span area. Needs to be - * modified for footnote and before-float reference areas when - * those are supported. - * @returns int The remaining available height in millipoints. - */ - public int getRemainingHeight() { - return this.mainReferenceArea.getMaxHeight() - - this.mainReferenceArea.getContentHeight(); - } - - /** - * Used by resetSpanArea() and addSpanArea() to adjust the main - * reference area height before creating a new span. - */ - private void resetHeights() { - int totalHeight = 0; - for (Enumeration e = this.mainReferenceArea.getChildren().elements(); - e.hasMoreElements(); ) { - SpanArea spanArea = (SpanArea)e.nextElement(); - int spanContentHeight = spanArea.getMaxContentHeight(); - int spanMaxHeight = spanArea.getMaxHeight(); - - totalHeight += (spanContentHeight < spanMaxHeight) - ? spanContentHeight : spanMaxHeight; - } - this.mainReferenceArea.setHeight(totalHeight); - } - - /** - * Used in Flow when layout returns incomplete. - * @returns boolean Is this the last column in this span? - */ - public boolean isLastColumn() { - Vector spanAreas = this.mainReferenceArea.getChildren(); - SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size() - - 1); - return spanArea.isLastColumn(); - } - - /** - * This variable is unset by getNextArea(), is set by addSpanArea(), - * and may be set by resetSpanArea(). - * @returns boolean Is the span area new or not? - */ - public boolean isNewSpanArea() { - return isNewSpanArea; - } - - public AreaContainer getCurrentColumnArea() { - Vector spanAreas = this.mainReferenceArea.getChildren(); - SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size() - - 1); - return spanArea.getCurrentColumnArea(); - } - - public int getFootnoteState() { - return footnoteState; - } - - public boolean needsFootnoteAdjusting() { - footnoteYPosition = footnoteReferenceArea.getYPosition(); - switch (footnoteState) { - case 0: - resetHeights(); - if (footnoteReferenceArea.getHeight() > 0 - && mainYPosition + mainReferenceArea.getHeight() - > footnoteYPosition) { - return true; - } - case 1: - break; - } - return false; - } - - public void adjustFootnoteArea() { - footnoteState++; - if (footnoteState == 1) { - mainReferenceArea.setMaxHeight(footnoteReferenceArea.getYPosition() - - mainYPosition); - footnoteYPosition = footnoteReferenceArea.getYPosition(); - footnoteReferenceArea.setMaxHeight(footnoteReferenceArea.getHeight()); - - Vector childs = footnoteReferenceArea.getChildren(); - for (Enumeration en = childs.elements(); en.hasMoreElements(); ) { - Object obj = en.nextElement(); - if (obj instanceof Area) { - Area childArea = (Area)obj; - footnoteReferenceArea.removeChild(childArea); - } - } - - getPage().setPendingFootnotes(null); - } - } - - protected static void resetMaxHeight(Area ar, int change) { - ar.setMaxHeight(change); - Vector childs = ar.getChildren(); - for (Enumeration en = childs.elements(); en.hasMoreElements(); ) { - Object obj = en.nextElement(); - if (obj instanceof Area) { - Area childArea = (Area)obj; - resetMaxHeight(childArea, change); - } - } - } - -} diff --git a/src/org/apache/fop/layout/BodyRegionArea.java b/src/org/apache/fop/layout/BodyRegionArea.java deleted file mode 100644 index 98d46a873..000000000 --- a/src/org/apache/fop/layout/BodyRegionArea.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -import org.apache.fop.fo.properties.*; - -// Represents region-body viewport/reference areas. -// The areas generated by fo:region-body are sufficiently dissimilar to -// the other 4 regions that we employ a different class - -public class BodyRegionArea extends RegionArea { - - // the column count and column-gap - private int columnCount; - private int columnGap; - - public BodyRegionArea(int xPosition, int yPosition, int width, - int height) { - super(xPosition, yPosition, width, height); - } - - public BodyAreaContainer makeBodyAreaContainer() { - return new BodyAreaContainer(null, xPosition, yPosition, width, - height, Position.ABSOLUTE, columnCount, - columnGap); - } - - public void setColumnCount(int columnCount) { - this.columnCount = columnCount; - } - - public int getColumnCount() { - return columnCount; - } - - public void setColumnGap(int columnGap) { - this.columnGap = columnGap; - } - - public int getColumnGap() { - return columnGap; - } - -} diff --git a/src/org/apache/fop/layout/Box.java b/src/org/apache/fop/layout/Box.java deleted file mode 100644 index 4068f015f..000000000 --- a/src/org/apache/fop/layout/Box.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -import org.apache.fop.render.Renderer; - -abstract public class Box { - protected Area parent; - protected AreaTree areaTree; -} diff --git a/src/org/apache/fop/layout/ColumnArea.java b/src/org/apache/fop/layout/ColumnArea.java deleted file mode 100644 index 8b9b6fb5b..000000000 --- a/src/org/apache/fop/layout/ColumnArea.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -// FOP -import org.apache.fop.render.Renderer; -import org.apache.fop.fo.properties.Position; -import org.apache.fop.datatypes.IDReferences; - -// Java -import java.util.Vector; -import java.util.Enumeration; - -public class ColumnArea extends AreaContainer { - - private int columnIndex; - private int maxColumns; - - public ColumnArea(FontState fontState, int xPosition, int yPosition, - int allocationWidth, int maxHeight, int columnCount) { - super(fontState, xPosition, yPosition, allocationWidth, maxHeight, - Position.ABSOLUTE); - this.maxColumns = columnCount; - this.setAreaName("normal-flow-ref.-area"); - } - - public void end() {} - - public void start() {} - - public int spaceLeft() { - return maxHeight - currentHeight; - } - - public int getColumnIndex() { - return columnIndex; - } - - public void setColumnIndex(int columnIndex) { - this.columnIndex = columnIndex; - } - - public void incrementSpanIndex() { - SpanArea span = (SpanArea)this.parent; - span.setCurrentColumn(span.getCurrentColumn() + 1); - } - -} diff --git a/src/org/apache/fop/layout/DisplaySpace.java b/src/org/apache/fop/layout/DisplaySpace.java deleted file mode 100644 index d32477f9f..000000000 --- a/src/org/apache/fop/layout/DisplaySpace.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -import org.apache.fop.render.Renderer; - -public class DisplaySpace extends Space { - private int size; - - public DisplaySpace(int size) { - this.size = size; - } - - public int getSize() { - return size; - } - -} diff --git a/src/org/apache/fop/layout/ExtensionArea.java b/src/org/apache/fop/layout/ExtensionArea.java deleted file mode 100644 index 6be851b63..000000000 --- a/src/org/apache/fop/layout/ExtensionArea.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -import org.apache.fop.fo.*; - -import org.apache.fop.extensions.*; -import org.apache.fop.render.*; - -public class ExtensionArea extends Area { - private ExtensionObj _extensionObj; - - public ExtensionArea(ExtensionObj obj) { - super(null); - _extensionObj = obj; - } - - public FObj getExtensionObj() { - return _extensionObj; - } - - public void render(Renderer renderer) { - // renderer.renderExtensionArea(this); - } - - -} diff --git a/src/org/apache/fop/layout/LineArea.java b/src/org/apache/fop/layout/LineArea.java deleted file mode 100644 index 20c572a72..000000000 --- a/src/org/apache/fop/layout/LineArea.java +++ /dev/null @@ -1,1336 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -// fop -import org.apache.fop.render.Renderer; -import org.apache.fop.layout.inline.*; -import org.apache.fop.datatypes.IDNode; -import org.apache.fop.fo.properties.WrapOption; -import org.apache.fop.fo.properties.WhiteSpaceCollapse; -import org.apache.fop.fo.properties.TextAlign; -import org.apache.fop.fo.properties.TextAlignLast; -import org.apache.fop.fo.properties.LeaderPattern; -import org.apache.fop.fo.properties.Hyphenate; -import org.apache.fop.fo.properties.CountryMaker; -import org.apache.fop.fo.properties.LanguageMaker; -import org.apache.fop.fo.properties.LeaderAlignment; -import org.apache.fop.fo.properties.VerticalAlign; -import org.apache.fop.layout.hyphenation.Hyphenation; -import org.apache.fop.layout.hyphenation.Hyphenator; -import org.apache.fop.configuration.Configuration; - -// java -import java.util.Vector; -import java.util.Enumeration; -import java.util.StringTokenizer; -import java.awt.Rectangle; - -public class LineArea extends Area { - - protected int lineHeight; - protected int halfLeading; - protected int nominalFontSize; - protected int nominalGlyphHeight; - - protected int allocationHeight; - protected int startIndent; - protected int endIndent; - - private int placementOffset; - - private FontState currentFontState; // not the nominal, which is - // in this.fontState - private float red, green, blue; - private int wrapOption; - private int whiteSpaceCollapse; - int vAlign; - - /* hyphenation */ - HyphenationProps hyphProps; - - /* - * the width of text that has definitely made it into the line - * area - */ - protected int finalWidth = 0; - - /* the position to shift a link rectangle in order to compensate for links embedded within a word */ - protected int embeddedLinkStart = 0; - - /* the width of the current word so far */ - // protected int wordWidth = 0; - - /* values that prev (below) may take */ - protected static final int NOTHING = 0; - protected static final int WHITESPACE = 1; - protected static final int TEXT = 2; - - /* the character type of the previous character */ - protected int prev = NOTHING; - - /* the position in data[] of the start of the current word */ - // protected int wordStart; - - /* the length (in characters) of the current word */ - // protected int wordLength = 0; - - /* width of spaces before current word */ - protected int spaceWidth = 0; - - /* - * the inline areas that have not yet been added to the line - * because subsequent characters to come (in a different addText) - * may be part of the same word - */ - protected Vector pendingAreas = new Vector(); - - /* the width of the pendingAreas */ - protected int pendingWidth = 0; - - /* text-decoration of the previous text */ - protected boolean prevUlState = false; - protected boolean prevOlState = false; - protected boolean prevLTState = false; - - public LineArea(FontState fontState, int lineHeight, int halfLeading, - int allocationWidth, int startIndent, int endIndent, - LineArea prevLineArea) { - super(fontState); - - this.currentFontState = fontState; - this.lineHeight = lineHeight; - this.nominalFontSize = fontState.getFontSize(); - this.nominalGlyphHeight = fontState.getAscender() - - fontState.getDescender(); - - this.placementOffset = fontState.getAscender(); - this.contentRectangleWidth = allocationWidth - startIndent - - endIndent; - this.fontState = fontState; - - this.allocationHeight = this.nominalGlyphHeight; - this.halfLeading = this.lineHeight - this.allocationHeight; - - this.startIndent = startIndent; - this.endIndent = endIndent; - - if (prevLineArea != null) { - Enumeration e = prevLineArea.pendingAreas.elements(); - Box b = null; - // There might be InlineSpaces at the beginning - // that should not be there - eat them - boolean eatMoreSpace = true; - int eatenWidth = 0; - - while (eatMoreSpace) { - if (e.hasMoreElements()) { - b = (Box)e.nextElement(); - if (b instanceof InlineSpace) { - InlineSpace is = (InlineSpace)b; - if (is.isEatable()) - eatenWidth += is.getSize(); - else - eatMoreSpace = false; - } else { - eatMoreSpace = false; - } - } else { - eatMoreSpace = false; - b = null; - } - } - - while (b != null) { - pendingAreas.addElement(b); - if (e.hasMoreElements()) - b = (Box)e.nextElement(); - else - b = null; - } - pendingWidth = prevLineArea.getPendingWidth() - eatenWidth; - } - } - - public int addPageNumberCitation(String refid, LinkSet ls) { - - /* - * We should add code here to handle the case where the page number doesn't fit on the current line - */ - - // Space must be alloted to the page number, so currently we give it 3 spaces - - int width = currentFontState.width(currentFontState.mapChar(' ')); - - - PageNumberInlineArea pia = new PageNumberInlineArea(currentFontState, - this.red, this.green, this.blue, refid, width); - - pia.setYOffset(placementOffset); - pendingAreas.addElement(pia); - pendingWidth += width; - prev = TEXT; - - return -1; - } - - - /** - * adds text to line area - * - * @return int character position - */ - public int addText(char odata[], int start, int end, LinkSet ls, - TextState textState) { - // this prevents an array index out of bounds - // which occurs when some text is laid out again. - if (start == -1) - return -1; - boolean overrun = false; - - int wordStart = start; - int wordLength = 0; - int wordWidth = 0; - // With CID fonts, space isn't neccesary currentFontState.width(32) - int whitespaceWidth = getCharWidth(' '); - - char[] data = new char[odata.length]; - char[] dataCopy = new char[odata.length]; - System.arraycopy(odata, 0, data, 0, odata.length); - System.arraycopy(odata, 0, dataCopy, 0, odata.length); - - boolean isText = false; - - /* iterate over each character */ - for (int i = start; i < end; i++) { - int charWidth; - /* get the character */ - char c = data[i]; - if (!(isSpace(c) || (c == '\n') || (c == '\r') || (c == '\t') - || (c == '\u2028'))) { - charWidth = getCharWidth(c); - isText = true; - // Add support for zero-width spaces - if (charWidth <= 0 && c != '\u200B' && c != '\uFEFF') - charWidth = whitespaceWidth; - } else { - if ((c == '\n') || (c == '\r') || (c == '\t')) - charWidth = whitespaceWidth; - else - charWidth = getCharWidth(c); - - isText = false; - - if (prev == WHITESPACE) { - - // if current & previous are WHITESPACE - - if (this.whiteSpaceCollapse == WhiteSpaceCollapse.FALSE) { - if (isSpace(c)) { - spaceWidth += getCharWidth(c); - } else if (c == '\n' || c == '\u2028') { - // force line break - if (spaceWidth > 0) { - InlineSpace is = new InlineSpace(spaceWidth); - is.setUnderlined(textState.getUnderlined()); - is.setOverlined(textState.getOverlined()); - is.setLineThrough(textState.getLineThrough()); - addChild(is); - finalWidth += spaceWidth; - spaceWidth = 0; - } - return i + 1; - } else if (c == '\t') { - spaceWidth += 8 * whitespaceWidth; - } - } else if (c == '\u2028') { - // Line separator - // Breaks line even if WhiteSpaceCollapse = True - if (spaceWidth > 0) { - InlineSpace is = new InlineSpace(spaceWidth); - is.setUnderlined(textState.getUnderlined()); - is.setOverlined(textState.getOverlined()); - is.setLineThrough(textState.getLineThrough()); - addChild(is); - finalWidth += spaceWidth; - spaceWidth = 0; - } - return i + 1; - } - - } else if (prev == TEXT) { - - // if current is WHITESPACE and previous TEXT - // the current word made it, so - // add the space before the current word (if there - // was some) - - if (spaceWidth > 0) { - InlineSpace is = new InlineSpace(spaceWidth); - if (prevUlState) { - is.setUnderlined(textState.getUnderlined()); - } - if (prevOlState) { - is.setOverlined(textState.getOverlined()); - } - if (prevLTState) { - is.setLineThrough(textState.getLineThrough()); - } - addChild(is); - finalWidth += spaceWidth; - spaceWidth = 0; - } - - // add any pending areas - - Enumeration e = pendingAreas.elements(); - while (e.hasMoreElements()) { - Box box = (Box)e.nextElement(); - if (box instanceof InlineArea) { - if (ls != null) { - Rectangle lr = - new Rectangle(finalWidth, 0, - ((InlineArea)box).getContentWidth(), - fontState.getFontSize()); - ls.addRect(lr, this, (InlineArea)box); - } - } - addChild(box); - } - - finalWidth += pendingWidth; - - // reset pending areas array - pendingWidth = 0; - pendingAreas = new Vector(); - - // add the current word - - if (wordLength > 0) { - // The word might contain nonbreaking - // spaces. Split the word and add InlineSpace - // as necessary. All spaces inside the word - // Have a fixed width. - addSpacedWord(new String(data, wordStart, wordLength), - ls, finalWidth, 0, textState, false); - finalWidth += wordWidth; - - // reset word width - wordWidth = 0; - } - - // deal with this new whitespace following the - // word we just added - prev = WHITESPACE; - - embeddedLinkStart = - 0; // reset embeddedLinkStart since a space was encountered - - spaceWidth = getCharWidth(c); - - /* - * here is the place for space-treatment value 'ignore': - * if (this.spaceTreatment == - * SpaceTreatment.IGNORE) { - * // do nothing - * } else { - * spaceWidth = currentFontState.width(32); - * } - */ - - - if (this.whiteSpaceCollapse == WhiteSpaceCollapse.FALSE) { - if (c == '\n' || c == '\u2028') { - // force a line break - return i + 1; - } else if (c == '\t') { - spaceWidth = whitespaceWidth; - } - } else if (c == '\u2028') { - return i + 1; - } - } else { - - // if current is WHITESPACE and no previous - - if (this.whiteSpaceCollapse == WhiteSpaceCollapse.FALSE) { - if (isSpace(c)) { - prev = WHITESPACE; - spaceWidth = getCharWidth(c); - } else if (c == '\n') { - // force line break - // textdecoration not used because spaceWidth is 0 - InlineSpace is = new InlineSpace(spaceWidth); - addChild(is); - return i + 1; - } else if (c == '\t') { - prev = WHITESPACE; - spaceWidth = 8 * whitespaceWidth; - } - - } else { - // skip over it - wordStart++; - } - } - - } - - if (isText) { // current is TEXT - - if (prev == WHITESPACE) { - - // if current is TEXT and previous WHITESPACE - - wordWidth = charWidth; - if ((finalWidth + spaceWidth + wordWidth) - > this.getContentWidth()) { - if (overrun) { - //log.debug("area contents overflows area"); - } - if (this.wrapOption == WrapOption.WRAP) { - return i; - } - } - prev = TEXT; - wordStart = i; - wordLength = 1; - } else if (prev == TEXT) { - wordLength++; - wordWidth += charWidth; - } else { // nothing previous - - prev = TEXT; - wordStart = i; - wordLength = 1; - wordWidth = charWidth; - } - - if ((finalWidth + spaceWidth + pendingWidth + wordWidth) - > this.getContentWidth()) { - - // BREAK MID WORD - if (canBreakMidWord()) { - addSpacedWord(new String(data, wordStart, wordLength - 1), - ls, - finalWidth + spaceWidth - + embeddedLinkStart, spaceWidth, - textState, false); - finalWidth += wordWidth; - wordWidth = 0; - return i; - } - - if (this.wrapOption == WrapOption.WRAP) { - - if (hyphProps.hyphenate == Hyphenate.TRUE) { - int ret = wordStart; - ret = this.doHyphenation(dataCopy, i, wordStart, - this.getContentWidth() - - (finalWidth - + spaceWidth - + pendingWidth)); - - // current word couldn't be hypenated - // couldn't fit first word - // I am at the beginning of my line - if ((ret == wordStart) && - (wordStart == start) && - (finalWidth == 0)) { - - //log.debug("area contents overflows area"); - addSpacedWord(new String(data, wordStart, wordLength - 1), - ls, - finalWidth + spaceWidth - + embeddedLinkStart, - spaceWidth, textState, false); - - finalWidth += wordWidth; - wordWidth = 0; - ret = i; - } - return ret; - } else if (wordStart == start) { - // first word - overrun = true; - // if not at start of line, return word start - // to try again on a new line - if (finalWidth > 0) { - return wordStart; - } - } else { - return wordStart; - } - - } - } - } - } // end of iteration over text - - if (prev == TEXT) { - - if (spaceWidth > 0) { - InlineSpace pis = new InlineSpace(spaceWidth); - // Make sure that this space doesn't occur as - // first thing in the next line - pis.setEatable(true); - if (prevUlState) { - pis.setUnderlined(textState.getUnderlined()); - } - if (prevOlState) { - pis.setOverlined(textState.getOverlined()); - } - if (prevLTState) { - pis.setLineThrough(textState.getLineThrough()); - } - pendingAreas.addElement(pis); - pendingWidth += spaceWidth; - spaceWidth = 0; - } - - addSpacedWord(new String(data, wordStart, wordLength), ls, - finalWidth + spaceWidth + embeddedLinkStart, - spaceWidth, textState, true); - - embeddedLinkStart += wordWidth; - wordWidth = 0; - } - - if (overrun) { - //log.debug("area contents overflows area"); - } - return -1; - } - - /** - * adds a Leader; actually the method receives the leader properties - * and creates a leader area or an inline area which is appended to - * the children of the containing line area.
- * leader pattern use-content is not implemented. - */ - public void addLeader(int leaderPattern, int leaderLengthMinimum, - int leaderLengthOptimum, int leaderLengthMaximum, - int ruleStyle, int ruleThickness, - int leaderPatternWidth, int leaderAlignment) { - WordArea leaderPatternArea; - int leaderLength = 0; - char dotIndex = '.'; // currentFontState.mapChar('.'); - int dotWidth = - currentFontState.width(currentFontState.mapChar(dotIndex)); - char whitespaceIndex = ' '; // currentFontState.mapChar(' '); - int whitespaceWidth = - currentFontState.width(currentFontState.mapChar(whitespaceIndex)); - - int remainingWidth = this.getContentWidth() - - this.getCurrentXPosition(); - - /** - * checks whether leaderLenghtOptimum fits into rest of line; - * should never overflow, as it has been checked already in BlockArea - * first check: use remaining width if it smaller than optimum oder maximum - */ - if ((remainingWidth <= leaderLengthOptimum) - || (remainingWidth <= leaderLengthMaximum)) { - leaderLength = remainingWidth; - } else if ((remainingWidth > leaderLengthOptimum) - && (remainingWidth > leaderLengthMaximum)) { - leaderLength = leaderLengthMaximum; - } else if ((leaderLengthOptimum > leaderLengthMaximum) - && (leaderLengthOptimum < remainingWidth)) { - leaderLength = leaderLengthOptimum; - } - - // stop if leader-length is too small - if (leaderLength <= 0) { - return; - } - - switch (leaderPattern) { - case LeaderPattern.SPACE: - InlineSpace spaceArea = new InlineSpace(leaderLength); - pendingAreas.addElement(spaceArea); - break; - case LeaderPattern.RULE: - LeaderArea leaderArea = new LeaderArea(fontState, red, green, - blue, "", leaderLength, - leaderPattern, - ruleThickness, ruleStyle); - leaderArea.setYOffset(placementOffset); - pendingAreas.addElement(leaderArea); - break; - case LeaderPattern.DOTS: - // if the width of a dot is larger than leader-pattern-width - // ignore this property - if (leaderPatternWidth < dotWidth) { - leaderPatternWidth = 0; - } - // if value of leader-pattern-width is 'use-font-metrics' (0) - if (leaderPatternWidth == 0) { - pendingAreas.addElement(this.buildSimpleLeader(dotIndex, - leaderLength)); - } else { - // if leader-alignment is used, calculate space to insert before leader - // so that all dots will be parallel. - if (leaderAlignment == LeaderAlignment.REFERENCE_AREA) { - int spaceBeforeLeader = - this.getLeaderAlignIndent(leaderLength, - leaderPatternWidth); - // appending indent space leader-alignment - // setting InlineSpace to false, so it is not used in line justification - if (spaceBeforeLeader != 0) { - pendingAreas.addElement(new InlineSpace(spaceBeforeLeader, - false)); - pendingWidth += spaceBeforeLeader; - // shorten leaderLength, otherwise - in case of - // leaderLength=remaining length - it will cut off the end of - // leaderlength - leaderLength -= spaceBeforeLeader; - } - } - - // calculate the space to insert between the dots and create a - // inline area with this width - InlineSpace spaceBetweenDots = - new InlineSpace(leaderPatternWidth - dotWidth, false); - - leaderPatternArea = new WordArea(currentFontState, this.red, - this.green, this.blue, - new String("."), dotWidth); - leaderPatternArea.setYOffset(placementOffset); - int dotsFactor = - (int)Math.floor(((double)leaderLength) - / ((double)leaderPatternWidth)); - - // add combination of dot + space to fill leader - // is there a way to do this in a more effective way? - for (int i = 0; i < dotsFactor; i++) { - pendingAreas.addElement(leaderPatternArea); - pendingAreas.addElement(spaceBetweenDots); - } - // append at the end some space to fill up to leader length - pendingAreas.addElement(new InlineSpace(leaderLength - - dotsFactor - * leaderPatternWidth)); - } - break; - // leader pattern use-content not implemented. - case LeaderPattern.USECONTENT: - //log.error("leader-pattern=\"use-content\" not " - // + "supported by this version of Fop"); - return; - } - // adds leader length to length of pending inline areas - pendingWidth += leaderLength; - // sets prev to TEXT and makes so sure, that also blocks only - // containing leaders are processed - prev = TEXT; - } - - /** - * adds pending inline areas to the line area - * normally done, when the line area is filled and - * added as child to the parent block area - */ - public void addPending() { - if (spaceWidth > 0) { - addChild(new InlineSpace(spaceWidth)); - finalWidth += spaceWidth; - spaceWidth = 0; - } - - Enumeration e = pendingAreas.elements(); - while (e.hasMoreElements()) { - Box box = (Box)e.nextElement(); - addChild(box); - } - - finalWidth += pendingWidth; - - // reset pending areas array - pendingWidth = 0; - pendingAreas = new Vector(); - } - - /** - * aligns line area - * - */ - public void align(int type) { - int padding = 0; - - switch (type) { - case TextAlign.START: // left - padding = this.getContentWidth() - finalWidth; - endIndent += padding; - break; - case TextAlign.END: // right - padding = this.getContentWidth() - finalWidth; - startIndent += padding; - break; - case TextAlign.CENTER: // center - padding = (this.getContentWidth() - finalWidth) / 2; - startIndent += padding; - endIndent += padding; - break; - case TextAlign.JUSTIFY: // justify - // first pass - count the spaces - int spaceCount = 0; - Enumeration e = children.elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); - if (b instanceof InlineSpace) { - InlineSpace space = (InlineSpace)b; - if (space.getResizeable()) { - spaceCount++; - } - } - } - if (spaceCount > 0) { - padding = (this.getContentWidth() - finalWidth) / spaceCount; - } else { // no spaces - padding = 0; - } - // second pass - add additional space - spaceCount = 0; - e = children.elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); - if (b instanceof InlineSpace) { - InlineSpace space = (InlineSpace)b; - if (space.getResizeable()) { - space.setSize(space.getSize() + padding); - spaceCount++; - } - } else if (b instanceof InlineArea) { - ((InlineArea)b).setXOffset(spaceCount * padding); - } - - } - } - } - - /** - * Balance (vertically) the inline areas within this line. - */ - public void verticalAlign() { - int superHeight = -this.placementOffset; - int maxHeight = this.allocationHeight; - Enumeration e = children.elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); - if (b instanceof InlineArea) { - InlineArea ia = (InlineArea)b; - if (ia instanceof WordArea) { - ia.setYOffset(placementOffset); - } - if (ia.getHeight() > maxHeight) { - maxHeight = ia.getHeight(); - } - int vert = ia.getVerticalAlign(); - if (vert == VerticalAlign.SUPER) { - int fh = fontState.getAscender(); - ia.setYOffset((int)(placementOffset - (2 * fh / 3.0))); - } else if (vert == VerticalAlign.SUB) { - int fh = fontState.getAscender(); - ia.setYOffset((int)(placementOffset + (2 * fh / 3.0))); - } - } else {} - } - // adjust the height of this line to the - // resulting alignment height. - this.allocationHeight = maxHeight; - } - - public void changeColor(float red, float green, float blue) { - this.red = red; - this.green = green; - this.blue = blue; - } - - public void changeFont(FontState fontState) { - this.currentFontState = fontState; - } - - public void changeWhiteSpaceCollapse(int whiteSpaceCollapse) { - this.whiteSpaceCollapse = whiteSpaceCollapse; - } - - public void changeWrapOption(int wrapOption) { - this.wrapOption = wrapOption; - } - - public void changeVerticalAlign(int vAlign) { - this.vAlign = vAlign; - } - - public int getEndIndent() { - return endIndent; - } - - public int getHeight() { - return this.allocationHeight; - } - - public int getPlacementOffset() { - return this.placementOffset; - } - - public int getStartIndent() { - return startIndent; - } - - public boolean isEmpty() { - return !(pendingAreas.size() > 0 || children.size() > 0); - // return (prev == NOTHING); - } - - public Vector getPendingAreas() { - return pendingAreas; - } - - public int getPendingWidth() { - return pendingWidth; - } - - public void setPendingAreas(Vector areas) { - pendingAreas = areas; - } - - public void setPendingWidth(int width) { - pendingWidth = width; - } - - /** - * sets hyphenation related traits: language, country, hyphenate, hyphenation-character - * and minimum number of character to remain one the previous line and to be on the - * next line. - */ - public void changeHyphenation(HyphenationProps hyphProps) { - this.hyphProps = hyphProps; - } - - - /** - * creates a leader as String out of the given char and the leader length - * and wraps it in an InlineArea which is returned - */ - private InlineArea buildSimpleLeader(char c, int leaderLength) { - int width = this.currentFontState.width(currentFontState.mapChar(c)); - if (width == 0) { - //log.error("char " + c - // + " has width 0. Using width 100 instead."); - width = 100; - } - int factor = (int)Math.floor(leaderLength / width); - char[] leaderChars = new char[factor]; - for (int i = 0; i < factor; i++) { - leaderChars[i] = c; // currentFontState.mapChar(c); - } - WordArea leaderPatternArea = new WordArea(currentFontState, this.red, - this.green, this.blue, - new String(leaderChars), - leaderLength); - leaderPatternArea.setYOffset(placementOffset); - return leaderPatternArea; - } - - /** - * calculates the width of space which has to be inserted before the - * start of the leader, so that all leader characters are aligned. - * is used if property leader-align is set. At the moment only the value - * for leader-align="reference-area" is supported. - * - */ - private int getLeaderAlignIndent(int leaderLength, - int leaderPatternWidth) { - // calculate position of used space in line area - double position = getCurrentXPosition(); - // calculate factor of next leader pattern cycle - double nextRepeatedLeaderPatternCycle = Math.ceil(position - / leaderPatternWidth); - // calculate difference between start of next leader - // pattern cycle and already used space - double difference = - (leaderPatternWidth * nextRepeatedLeaderPatternCycle) - position; - return (int)difference; - } - - /** - * calculates the used space in this line area - */ - private int getCurrentXPosition() { - return finalWidth + spaceWidth + startIndent + pendingWidth; - } - - /** - * extracts a complete word from the character data - */ - private String getHyphenationWord(char[] characters, int wordStart) { - boolean wordendFound = false; - int counter = 0; - char[] newWord = new char[characters.length]; // create a buffer - while ((!wordendFound) - && ((wordStart + counter) < characters.length)) { - char tk = characters[wordStart + counter]; - if (Character.isLetter(tk)) { - newWord[counter] = tk; - counter++; - } else { - wordendFound = true; - } - } - return new String(newWord, 0, counter); - } - - - /** - * extracts word for hyphenation and calls hyphenation package, - * handles cases of inword punctuation and quotation marks at the beginning - * of words, but not in a internationalized way - */ - public int doHyphenation(char[] characters, int position, int wordStart, - int remainingWidth) { - // check whether the language property has been set - if (this.hyphProps.language.equalsIgnoreCase("none")) { - //log.error("if property 'hyphenate' is used, a language must be specified"); - return wordStart; - } - - /** - * remaining part string of hyphenation - */ - StringBuffer remainingString = new StringBuffer(); - - /** - * for words with some inword punctuation like / or - - */ - StringBuffer preString = null; - - /** - * char before the word, probably whitespace - */ - char startChar = ' '; // characters[wordStart-1]; - - /** - * in word punctuation character - */ - char inwordPunctuation; - - /** - * the complete word handed to the hyphenator - */ - String wordToHyphenate; - - // width of hyphenation character - int hyphCharWidth = - this.currentFontState.width(currentFontState.mapChar(this.hyphProps.hyphenationChar)); - remainingWidth -= hyphCharWidth; - - // handles ' or " at the beginning of the word - if (characters[wordStart] == '"' || characters[wordStart] == '\'') { - remainingString.append(characters[wordStart]); - // extracts whole word from string - wordToHyphenate = getHyphenationWord(characters, wordStart + 1); - } else { - wordToHyphenate = getHyphenationWord(characters, wordStart); - } - - // if the extracted word is smaller than the remaining width - // we have a non letter character inside the word. at the moment - // we will only handle hard hyphens and slashes - if (getWordWidth(wordToHyphenate) < remainingWidth) { - inwordPunctuation = - characters[wordStart + wordToHyphenate.length()]; - if (inwordPunctuation == '-' || inwordPunctuation == '/') { - preString = new StringBuffer(wordToHyphenate); - preString = preString.append(inwordPunctuation); - wordToHyphenate = - getHyphenationWord(characters, - wordStart + wordToHyphenate.length() - + 1); - remainingWidth -= - (getWordWidth(wordToHyphenate) - + this.currentFontState.width(currentFontState.mapChar(inwordPunctuation))); - } - } - - // are there any hyphenation points - Hyphenation hyph = - Hyphenator.hyphenate(hyphProps.language, hyphProps.country, - wordToHyphenate, - hyphProps.hyphenationRemainCharacterCount, - hyphProps.hyphenationPushCharacterCount); - // no hyphenation points and no inword non letter character - if (hyph == null && preString == null) { - if (remainingString.length() > 0) { - return wordStart - 1; - } else { - return wordStart; - } - - // no hyphenation points, but a inword non-letter character - } else if (hyph == null && preString != null) { - remainingString.append(preString); - // is.addMapWord(startChar,remainingString); - this.addWord(startChar, remainingString); - return wordStart + remainingString.length(); - // hyphenation points and no inword non-letter character - } else if (hyph != null && preString == null) { - int index = getFinalHyphenationPoint(hyph, remainingWidth); - if (index != -1) { - remainingString.append(hyph.getPreHyphenText(index)); - remainingString.append(this.hyphProps.hyphenationChar); - // is.addMapWord(startChar,remainingString); - this.addWord(startChar, remainingString); - return wordStart + remainingString.length() - 1; - } - // hyphenation points and a inword non letter character - } else if (hyph != null && preString != null) { - int index = getFinalHyphenationPoint(hyph, remainingWidth); - if (index != -1) { - remainingString.append(preString.append(hyph.getPreHyphenText(index))); - remainingString.append(this.hyphProps.hyphenationChar); - // is.addMapWord(startChar,remainingString); - this.addWord(startChar, remainingString); - return wordStart + remainingString.length() - 1; - } else { - remainingString.append(preString); - // is.addMapWord(startChar,remainingString); - this.addWord(startChar, remainingString); - return wordStart + remainingString.length(); - } - } - return wordStart; - } - - - /** - * Calculates the wordWidth using the actual fontstate - */ - private int getWordWidth(String word) { - if (word == null) - return 0; - int wordLength = word.length(); - int width = 0; - char[] characters = new char[wordLength]; - word.getChars(0, wordLength, characters, 0); - - for (int i = 0; i < wordLength; i++) { - width += getCharWidth(characters[i]); - } - return width; - } - - public int getRemainingWidth() { - return this.getContentWidth() - this.getCurrentXPosition(); - } - - public void setLinkSet(LinkSet ls) {} - - public void addInlineArea(Area box) { - addPending(); - addChild(box); - prev = TEXT; - finalWidth += box.getContentWidth(); - } - - public void addInlineSpace(InlineSpace is, int spaceWidth) { - addChild(is); - finalWidth += spaceWidth; - // spaceWidth = 0; - } - - /** - * adds a single character to the line area tree - */ - public int addCharacter(char data, LinkSet ls, boolean ul) { - WordArea ia = null; - int remainingWidth = this.getContentWidth() - - this.getCurrentXPosition(); - int width = - this.currentFontState.width(currentFontState.mapChar(data)); - // if it doesn't fit, return - if (width > remainingWidth) { - return org.apache.fop.fo.flow.Character.DOESNOT_FIT; - } else { - // if whitespace-collapse == true, discard character - if (Character.isSpaceChar(data) - && whiteSpaceCollapse == WhiteSpaceCollapse.TRUE) { - return org.apache.fop.fo.flow.Character.OK; - } - // create new InlineArea - ia = new WordArea(currentFontState, this.red, this.green, - this.blue, new Character(data).toString(), - width); - ia.setYOffset(placementOffset); - ia.setUnderlined(ul); - pendingAreas.addElement(ia); - if (Character.isSpaceChar(data)) { - this.spaceWidth = +width; - prev = LineArea.WHITESPACE; - } else { - pendingWidth += width; - prev = LineArea.TEXT; - } - return org.apache.fop.fo.flow.Character.OK; - } - } - - - /** - * Same as addWord except that characters in wordBuf is mapped - * to the current fontstate's encoding - */ - private void addMapWord(char startChar, StringBuffer wordBuf) { - StringBuffer mapBuf = new StringBuffer(wordBuf.length()); - for (int i = 0; i < wordBuf.length(); i++) { - mapBuf.append(currentFontState.mapChar(wordBuf.charAt(i))); - } - - addWord(startChar, mapBuf); - } - - /** - * adds a InlineArea containing the String startChar+wordBuf to the line area children. - */ - private void addWord(char startChar, StringBuffer wordBuf) { - String word = (wordBuf != null) ? wordBuf.toString() : ""; - WordArea hia; - int startCharWidth = getCharWidth(startChar); - - if (isAnySpace(startChar)) { - this.addChild(new InlineSpace(startCharWidth)); - } else { - hia = new WordArea(currentFontState, this.red, this.green, - this.blue, - new Character(startChar).toString(), 1); - hia.setYOffset(placementOffset); - this.addChild(hia); - } - int wordWidth = this.getWordWidth(word); - hia = new WordArea(currentFontState, this.red, this.green, this.blue, - word, word.length()); - hia.setYOffset(placementOffset); - this.addChild(hia); - - // calculate the space needed - finalWidth += startCharWidth + wordWidth; - } - - - /** - * extracts from a hyphenated word the best (most greedy) fit - */ - private int getFinalHyphenationPoint(Hyphenation hyph, - int remainingWidth) { - int[] hyphenationPoints = hyph.getHyphenationPoints(); - int numberOfHyphenationPoints = hyphenationPoints.length; - - int index = -1; - String wordBegin = ""; - int wordBeginWidth = 0; - - for (int i = 0; i < numberOfHyphenationPoints; i++) { - wordBegin = hyph.getPreHyphenText(i); - if (this.getWordWidth(wordBegin) > remainingWidth) { - break; - } - index = i; - } - return index; - } - - /** - * Checks if it's legal to break a word in the middle - * based on the current language property. - * @return true if legal to break word in the middle - */ - private boolean canBreakMidWord() { - boolean ret = false; - if (hyphProps != null && hyphProps.language != null - &&!hyphProps.language.equals("NONE")) { - String lang = hyphProps.language.toLowerCase(); - if ("zh".equals(lang) || "ja".equals(lang) || "ko".equals(lang) - || "vi".equals(lang)) - ret = true; - } - return ret; - } - - /** - * Helper method for getting the width of a unicode char - * from the current fontstate. - * This also performs some guessing on widths on various - * versions of space that might not exists in the font. - */ - private int getCharWidth(char c) { - int width = currentFontState.width(currentFontState.mapChar(c)); - if (width <= 0) { - // Estimate the width of spaces not represented in - // the font - int em = currentFontState.width(currentFontState.mapChar('m')); - int en = currentFontState.width(currentFontState.mapChar('n')); - if (em <= 0) - em = 500 * currentFontState.getFontSize(); - if (en <= 0) - en = em - 10; - - if (c == ' ') - width = em; - if (c == '\u2000') - width = en; - if (c == '\u2001') - width = em; - if (c == '\u2002') - width = em / 2; - if (c == '\u2003') - width = currentFontState.getFontSize(); - if (c == '\u2004') - width = em / 3; - if (c == '\u2005') - width = em / 4; - if (c == '\u2006') - width = em / 6; - if (c == '\u2007') - width = getCharWidth(' '); - if (c == '\u2008') - width = getCharWidth('.'); - if (c == '\u2009') - width = em / 5; - if (c == '\u200A') - width = 5; - if (c == '\u200B') - width = 100; - if (c == '\u00A0') - width = getCharWidth(' '); - if (c == '\u202F') - width = getCharWidth(' ') / 2; - if (c == '\u3000') - width = getCharWidth(' ') * 2; - if ((c == '\n') || (c == '\r') || (c == '\t')) - width = getCharWidth(' '); - } - - return width; - } - - - /** - * Helper method to determine if the character is a - * space with normal behaviour. Normal behaviour means that - * it's not non-breaking - */ - private boolean isSpace(char c) { - if (c == ' ' || c == '\u2000' || // en quad - c == '\u2001' || // em quad - c == '\u2002' || // en space - c == '\u2003' || // em space - c == '\u2004' || // three-per-em space - c == '\u2005' || // four--per-em space - c == '\u2006' || // six-per-em space - c == '\u2007' || // figure space - c == '\u2008' || // punctuation space - c == '\u2009' || // thin space - c == '\u200A' || // hair space - c == '\u200B') // zero width space - return true; - else - return false; - } - - - /** - * Method to determine if the character is a nonbreaking - * space. - */ - private boolean isNBSP(char c) { - if (c == '\u00A0' || c == '\u202F' || // narrow no-break space - c == '\u3000' || // ideographic space - c == '\uFEFF') { // zero width no-break space - return true; - } else - return false; - } - - /** - * @return true if the character represents any kind of space - */ - private boolean isAnySpace(char c) { - boolean ret = (isSpace(c) || isNBSP(c)); - return ret; - } - - /** - * Add a word that might contain non-breaking spaces. - * Split the word into WordArea and InlineSpace and add it. - * If addToPending is true, add to pending areas. - */ - private void addSpacedWord(String word, LinkSet ls, int startw, - int spacew, TextState textState, - boolean addToPending) { - StringTokenizer st = new StringTokenizer(word, "\u00A0\u202F\u3000\uFEFF", true); - int extraw = 0; - while (st.hasMoreTokens()) { - String currentWord = st.nextToken(); - - if (currentWord.length() == 1 - && (isNBSP(currentWord.charAt(0)))) { - // Add an InlineSpace - int spaceWidth = getCharWidth(currentWord.charAt(0)); - if (spaceWidth > 0) { - InlineSpace is = new InlineSpace(spaceWidth); - extraw += spaceWidth; - if (prevUlState) { - is.setUnderlined(textState.getUnderlined()); - } - if (prevOlState) { - is.setOverlined(textState.getOverlined()); - } - if (prevLTState) { - is.setLineThrough(textState.getLineThrough()); - } - - if (addToPending) { - pendingAreas.addElement(is); - pendingWidth += spaceWidth; - } else { - addChild(is); - } - } - } else { - WordArea ia = new WordArea(currentFontState, this.red, - this.green, this.blue, - currentWord, - getWordWidth(currentWord)); - ia.setYOffset(placementOffset); - ia.setUnderlined(textState.getUnderlined()); - prevUlState = textState.getUnderlined(); - ia.setOverlined(textState.getOverlined()); - prevOlState = textState.getOverlined(); - ia.setLineThrough(textState.getLineThrough()); - prevLTState = textState.getLineThrough(); - ia.setVerticalAlign(vAlign); - - if (addToPending) { - pendingAreas.addElement(ia); - pendingWidth += getWordWidth(currentWord); - } else { - addChild(ia); - } - if (ls != null) { - Rectangle lr = new Rectangle(startw + extraw, spacew, - ia.getContentWidth(), - fontState.getFontSize()); - ls.addRect(lr, this, ia); - } - } - } - } - -} - diff --git a/src/org/apache/fop/layout/LinkSet.java b/src/org/apache/fop/layout/LinkSet.java deleted file mode 100644 index 30d58ca8d..000000000 --- a/src/org/apache/fop/layout/LinkSet.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -// Java -import java.util.Vector; -import java.util.Enumeration; -import java.awt.Rectangle; - -import org.apache.fop.layout.inline.InlineArea; - -import org.apache.fop.fo.properties.WrapOption; // for enumerated -// values -// import org.apache.fop.fo.properties.WhiteSpaceCollapse; // for -// enumerated values -import org.apache.fop.fo.properties.TextAlign; // for enumerated -// values -import org.apache.fop.fo.properties.TextAlignLast; // for enumerated -// values - -/** - * a set of rectangles on a page that are linked to a common - * destination - */ -public class LinkSet { - - /** - * the destination of the links - */ - String destination; - - /** - * the set of rectangles - */ - Vector rects = new Vector(); - - private int xoffset = 0; - private int yoffset = 0; - - /* the maximum Y offset value encountered for this LinkSet */ - private int maxY = 0; - - protected int startIndent; - protected int endIndent; - - private int linkType; - - private Area area; - - public final static int INTERNAL = 0, // represents internal link - EXTERNAL = 1; // represents external link - - // property required for alignment adjustments - int contentRectangleWidth = 0; - - public LinkSet(String destination, Area area, int linkType) { - this.destination = destination; - this.area = area; - this.linkType = linkType; - } - - public void addRect(Rectangle r, LineArea lineArea, - InlineArea inlineArea) { - LinkedRectangle linkedRectangle = new LinkedRectangle(r, lineArea, - inlineArea); - linkedRectangle.setY(this.yoffset); - if (this.yoffset > maxY) { - maxY = this.yoffset; - } - rects.addElement(linkedRectangle); - } - - public void setYOffset(int y) { - this.yoffset = y; - } - - public void setXOffset(int x) { - this.xoffset = x; - } - - public void setContentRectangleWidth(int contentRectangleWidth) { - this.contentRectangleWidth = contentRectangleWidth; - } - - public void applyAreaContainerOffsets(AreaContainer ac, Area area) { - int height = area.getAbsoluteHeight(); - BlockArea ba = (BlockArea)area; - Enumeration re = rects.elements(); - while (re.hasMoreElements()) { - LinkedRectangle r = (LinkedRectangle)re.nextElement(); - r.setX(r.getX() + ac.getXPosition() + area.getTableCellXOffset()); - r.setY(ac.getYPosition() - height + (maxY - r.getY()) - - ba.getHalfLeading()); - } - } - - // intermediate implementation for joining all sublinks on same line - public void mergeLinks() { - int numRects = rects.size(); - if (numRects == 1) - return; - - LinkedRectangle curRect = - new LinkedRectangle((LinkedRectangle)rects.elementAt(0)); - Vector nv = new Vector(); - - for (int ri = 1; ri < numRects; ri++) { - LinkedRectangle r = (LinkedRectangle)rects.elementAt(ri); - - // yes, I'm really happy with comparing refs... - if (r.getLineArea() == curRect.getLineArea()) { - curRect.setWidth(r.getX() + r.getWidth() - curRect.getX()); - } else { - nv.addElement(curRect); - curRect = new LinkedRectangle(r); - } - - if (ri == numRects - 1) - nv.addElement(curRect); - } - - rects = nv; - } - - public void align() { - Enumeration re = rects.elements(); - while (re.hasMoreElements()) { - LinkedRectangle r = (LinkedRectangle)re.nextElement(); - r.setX(r.getX() + r.getLineArea().getStartIndent() - + r.getInlineArea().getXOffset()); - } - } - - public String getDest() { - return this.destination; - } - - public Vector getRects() { - return this.rects; - } - - public int getEndIndent() { - return endIndent; - } - - public int getStartIndent() { - return startIndent; - } - - public Area getArea() { - return area; - } - - public int getLinkType() { - return linkType; - } - -} diff --git a/src/org/apache/fop/layout/LinkedRectangle.java b/src/org/apache/fop/layout/LinkedRectangle.java deleted file mode 100644 index cca659596..000000000 --- a/src/org/apache/fop/layout/LinkedRectangle.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -// Java -import java.awt.Rectangle; - -import org.apache.fop.layout.inline.InlineArea; - -/** - * an object that stores a rectangle that is linked, and the LineArea - * that it is logically associated with - * @author Arved Sandstrom - * @author James Tauber - */ -public class LinkedRectangle { - - /** - * the linked Rectangle - */ - protected Rectangle link; - - /** - * the associated LineArea - */ - protected LineArea lineArea; - - /** - * the associated InlineArea - */ - protected InlineArea inlineArea; - - public LinkedRectangle(Rectangle link, LineArea lineArea, - InlineArea inlineArea) { - this.link = link; - this.lineArea = lineArea; - this.inlineArea = inlineArea; - } - - public LinkedRectangle(LinkedRectangle lr) { - this.link = new Rectangle(lr.getRectangle()); - this.lineArea = lr.getLineArea(); - this.inlineArea = lr.getInlineArea(); - } - - public void setRectangle(Rectangle link) { - this.link = link; - } - - public Rectangle getRectangle() { - return this.link; - } - - public LineArea getLineArea() { - return this.lineArea; - } - - public void setLineArea(LineArea lineArea) { - this.lineArea = lineArea; - } - - public InlineArea getInlineArea() { - return this.inlineArea; - } - - public void setLineArea(InlineArea inlineArea) { - this.inlineArea = inlineArea; - } - - public void setX(int x) { - this.link.x = x; - } - - public void setY(int y) { - this.link.y = y; - } - - public void setWidth(int width) { - this.link.width = width; - } - - public void setHeight(int height) { - this.link.height = height; - } - - public int getX() { - return this.link.x; - } - - public int getY() { - return this.link.y; - } - - public int getWidth() { - return this.link.width; - } - - public int getHeight() { - return this.link.height; - } - -} diff --git a/src/org/apache/fop/layout/Page.java b/src/org/apache/fop/layout/Page.java deleted file mode 100644 index eb079ed13..000000000 --- a/src/org/apache/fop/layout/Page.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -// FOP -import org.apache.fop.render.Renderer; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.*; -import org.apache.fop.apps.*; -import org.apache.fop.datatypes.IDReferences; -import org.apache.fop.fo.pagination.PageSequence; - -// Java -import java.util.Vector; -import java.util.Enumeration; - -/*Modified by Mark Lillywhite mark-fop@inomial.com. Added getIDReferences. - This is just a convenience method for renderers who no longer have access - to the AreaTree when rendering. - */ - -public class Page { - - private int height; - private int width; - - private BodyAreaContainer body; - private AreaContainer before; - private AreaContainer after; - private AreaContainer start; - private AreaContainer end; - - private AreaTree areaTree; - - private Vector rootExtensions; - - private PageSequence pageSequence; - - protected int pageNumber = 0; - protected String formattedPageNumber; - - protected Vector linkSets = new Vector(); - - private Vector idList = new Vector(); - - private Vector footnotes = null; - - private Vector markers = null; - - Page(AreaTree areaTree, int height, int width) { - this.areaTree = areaTree; - this.height = height; - this.width = width; - markers = new Vector(); - } - - public IDReferences getIDReferences() { - return areaTree.getIDReferences(); - } - - public void setPageSequence(PageSequence pageSequence) { - this.pageSequence = pageSequence; - } - - public PageSequence getPageSequence() { - return pageSequence; - } - - public AreaTree getAreaTree() { - return areaTree; - } - - public void setNumber(int number) { - this.pageNumber = number; - } - - public int getNumber() { - return this.pageNumber; - } - - public void setFormattedNumber(String number) { - this.formattedPageNumber = number; - } - - public String getFormattedNumber() { - return this.formattedPageNumber; - } - - void addAfter(AreaContainer area) { - this.after = area; - area.setPage(this); - } - - void addBefore(AreaContainer area) { - this.before = area; - area.setPage(this); - } - - /** - * Ensure that page is set not only on B.A.C. but also on the - * three top-level reference areas. - * @param area The region-body area container (special) - */ - public void addBody(BodyAreaContainer area) { - this.body = area; - area.setPage(this); - ((BodyAreaContainer)area).getMainReferenceArea().setPage(this); - ((BodyAreaContainer)area).getBeforeFloatReferenceArea().setPage(this); - ((BodyAreaContainer)area).getFootnoteReferenceArea().setPage(this); - } - - void addEnd(AreaContainer area) { - this.end = area; - area.setPage(this); - } - - void addStart(AreaContainer area) { - this.start = area; - area.setPage(this); - } - - public AreaContainer getAfter() { - return this.after; - } - - public AreaContainer getBefore() { - return this.before; - } - - public AreaContainer getStart() { - return this.start; - } - - public AreaContainer getEnd() { - return this.end; - } - - public BodyAreaContainer getBody() { - return this.body; - } - - public int getHeight() { - return this.height; - } - - public int getWidth() { - return this.width; - } - - public FontInfo getFontInfo() { - return this.areaTree.getFontInfo(); - } - - public void addLinkSet(LinkSet linkSet) { - this.linkSets.addElement(linkSet); - } - - public Vector getLinkSets() { - return this.linkSets; - } - - public boolean hasLinks() { - return (!this.linkSets.isEmpty()); - } - - public void addToIDList(String id) { - idList.addElement(id); - } - - public Vector getIDList() { - return idList; - } - - public Vector getPendingFootnotes() { - return footnotes; - } - - public Vector getExtensions() { - return rootExtensions; - } - - public void setExtensions(Vector extensions) { - this.rootExtensions = extensions; - } - - public void setPendingFootnotes(Vector v) { - footnotes = v; - if (footnotes != null) { - for (Enumeration e = footnotes.elements(); - e.hasMoreElements(); ) { - FootnoteBody fb = (FootnoteBody)e.nextElement(); - if (!Footnote.layoutFootnote(this, fb, null)) { - // footnotes are too large to fit on empty page - } - - } - footnotes = null; - } - } - - public void addPendingFootnote(FootnoteBody fb) { - if (footnotes == null) { - footnotes = new Vector(); - } - footnotes.addElement(fb); - } - - public void registerMarker(Marker marker) { - markers.addElement(marker); - } - - public Vector getMarkers() { - return this.markers; - } - -} diff --git a/src/org/apache/fop/layout/RegionArea.java b/src/org/apache/fop/layout/RegionArea.java deleted file mode 100644 index 7e7465448..000000000 --- a/src/org/apache/fop/layout/RegionArea.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -import org.apache.fop.fo.properties.*; -import org.apache.fop.datatypes.ColorType; - -public class RegionArea { - - protected int xPosition; - protected int yPosition; - protected int width; - protected int height; - - protected ColorType backgroundColor; - - public RegionArea(int xPosition, int yPosition, int width, int height) { - this.xPosition = xPosition; - this.yPosition = yPosition; - this.width = width; - this.height = height; - } - - public AreaContainer makeAreaContainer() { - return new AreaContainer(null, xPosition, yPosition, width, height, - Position.ABSOLUTE); - } - - public ColorType getBackgroundColor() { - return this.backgroundColor; - } - - public void setBackgroundColor(ColorType bgColor) { - this.backgroundColor = bgColor; - } - - public int getHeight() { - return height; - } - -} diff --git a/src/org/apache/fop/layout/Space.java b/src/org/apache/fop/layout/Space.java deleted file mode 100644 index d49b4be4a..000000000 --- a/src/org/apache/fop/layout/Space.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -abstract public class Space extends Box {} diff --git a/src/org/apache/fop/layout/SpanArea.java b/src/org/apache/fop/layout/SpanArea.java deleted file mode 100644 index 2349b7159..000000000 --- a/src/org/apache/fop/layout/SpanArea.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout; - -// FOP -import org.apache.fop.render.Renderer; -import org.apache.fop.fo.properties.Position; -import org.apache.fop.datatypes.IDReferences; - -// Java -import java.util.Vector; -import java.util.Enumeration; - -public class SpanArea extends AreaContainer { - - private int columnCount; - private int currentColumn = 1; - private int columnGap = 0; - - // has the area been balanced? - private boolean isBalanced = false; - - public SpanArea(FontState fontState, int xPosition, int yPosition, - int allocationWidth, int maxHeight, int columnCount, - int columnGap) { - super(fontState, xPosition, yPosition, allocationWidth, maxHeight, - Position.ABSOLUTE); - - this.contentRectangleWidth = allocationWidth; - this.columnCount = columnCount; - this.columnGap = columnGap; - - int columnWidth = (allocationWidth - columnGap * (columnCount - 1)) - / columnCount; - for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { - int colXPosition = (xPosition - + columnIndex * (columnWidth + columnGap)); - int colYPosition = yPosition; - ColumnArea colArea = new ColumnArea(fontState, colXPosition, - colYPosition, columnWidth, - maxHeight, columnCount); - addChild(colArea); - colArea.setColumnIndex(columnIndex + 1); - } - } - - public void end() {} - - public void start() {} - - public int spaceLeft() { - return maxHeight - currentHeight; - } - - public int getColumnCount() { - return columnCount; - } - - public int getCurrentColumn() { - return currentColumn; - } - - public void setCurrentColumn(int currentColumn) { - if (currentColumn <= columnCount) - this.currentColumn = currentColumn; - else - this.currentColumn = columnCount; - } - - public AreaContainer getCurrentColumnArea() { - return (AreaContainer)getChildren().elementAt(currentColumn - 1); - } - - public boolean isBalanced() { - return isBalanced; - } - - public void setIsBalanced() { - this.isBalanced = true; - } - - public int getTotalContentHeight() { - int totalContentHeight = 0; - for (Enumeration e = getChildren().elements(); - e.hasMoreElements(); ) { - totalContentHeight += - ((AreaContainer)e.nextElement()).getContentHeight(); - } - return totalContentHeight; - } - - public int getMaxContentHeight() { - int maxContentHeight = 0; - for (Enumeration e = getChildren().elements(); - e.hasMoreElements(); ) { - AreaContainer nextElm = (AreaContainer)e.nextElement(); - if (nextElm.getContentHeight() > maxContentHeight) - maxContentHeight = nextElm.getContentHeight(); - } - return maxContentHeight; - } - - public void setPage(Page page) { - this.page = page; - for (Enumeration e = getChildren().elements(); - e.hasMoreElements(); ) { - ((AreaContainer)e.nextElement()).setPage(page); - } - } - - public boolean isLastColumn() { - return (currentColumn == columnCount); - } - -} diff --git a/src/org/apache/fop/layout/inline/ForeignObjectArea.java b/src/org/apache/fop/layout/inline/ForeignObjectArea.java deleted file mode 100644 index f4607e7b5..000000000 --- a/src/org/apache/fop/layout/inline/ForeignObjectArea.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout.inline; - -// FOP -import org.apache.fop.render.Renderer; -import org.apache.fop.layout.*; - -// Java -import java.util.Vector; -import java.util.Enumeration; - -public class ForeignObjectArea extends InlineArea { - - protected int xOffset = 0; - /* text-align of contents */ - protected int align; - /* vertical align of contents */ - protected int valign; - /* scaling method */ - protected int scaling; - protected Area foreignObject; - /* height according to the instream-foreign-object */ - protected int cheight; - /* width according to the instream-foreign-object */ - protected int cwidth; - /* width of the content */ - protected int awidth; - /* height of the content */ - protected int aheight; - /* width */ - protected int width; - boolean wauto; - boolean hauto; - boolean cwauto; - boolean chauto; - int overflow; - - public ForeignObjectArea(FontState fontState, int width) { - super(fontState, width, 0, 0, 0); - } - - /** - * This is NOT the content width of the instream-foreign-object. - * This is the content width for a Box. - */ - public int getContentWidth() { - return getEffectiveWidth(); - } - - /** - * This is NOT the content height of the instream-foreign-object. - * This is the content height for a Box. - */ - public int getHeight() { - return getEffectiveHeight(); - } - - public int getXOffset() { - return this.xOffset; - } - - public void setStartIndent(int startIndent) { - xOffset = startIndent; - } - - public void setObject(Area fobject) { - foreignObject = fobject; - } - - public Area getObject() { - return foreignObject; - } - - public void setSizeAuto(boolean wa, boolean ha) { - wauto = wa; - hauto = ha; - } - - public void setContentSizeAuto(boolean wa, boolean ha) { - cwauto = wa; - chauto = ha; - } - - public boolean isContentWidthAuto() { - return cwauto; - } - - public boolean isContentHeightAuto() { - return chauto; - } - - public void setAlign(int align) { - this.align = align; - } - - public int getAlign() { - return this.align; - } - - public void setVerticalAlign(int align) { - this.valign = align; - } - - public int getVerticalAlign() { - return this.valign; - } - - public void setOverflow(int o) { - this.overflow = o; - } - - public int getOverflow() { - return this.overflow; - } - - public void setHeight(int height) { - this.height = height; - } - - public void setWidth(int width) { - this.width = width; - } - - public void setContentHeight(int cheight) { - this.cheight = cheight; - } - - public void setContentWidth(int cwidth) { - this.cwidth = cwidth; - } - - public void setScaling(int scaling) { - this.scaling = scaling; - } - - public int scalingMethod() { - return this.scaling; - } - - public void setIntrinsicWidth(int w) { - awidth = w; - } - - public void setIntrinsicHeight(int h) { - aheight = h; - } - - public int getIntrinsicHeight() { - return aheight; - } - - public int getIntrinsicWidth() { - return awidth; - } - - public int getEffectiveHeight() { - if (this.hauto) { - if (this.chauto) { - return aheight; - } else { - // need to handle percentages, this would be a scaling factor on the - // instrinsic height (content determined height) - // if(this.properties.get("content-height").getLength().isPercentage()) { - // switch(scaling) { - // case Scaling.UNIFORM: - // break; - // case Scaling.NON_UNIFORM: - // break; - // } - // } else { - return this.cheight; - } - } else { - return this.height; - } - } - - public int getEffectiveWidth() { - if (this.wauto) { - if (this.cwauto) { - return awidth; - } else { - // need to handle percentages, this would be a scaling factor on the - // instrinsic height (content determined height) - // if(this.properties.get("content-width").getLength().isPercentage()) { - // switch(scaling) { - // case Scaling.UNIFORM: - // break; - // case Scaling.NON_UNIFORM: - // break; - // } - // } else { - return this.cwidth; - } - } else { - return this.width; - } - } - -} diff --git a/src/org/apache/fop/layout/inline/InlineArea.java b/src/org/apache/fop/layout/inline/InlineArea.java deleted file mode 100644 index 8671adb57..000000000 --- a/src/org/apache/fop/layout/inline/InlineArea.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout.inline; - -import org.apache.fop.render.Renderer; -import org.apache.fop.layout.Area; -import org.apache.fop.layout.FontState; -import org.apache.fop.layout.*; - -public abstract class InlineArea extends Area { - - private int yOffset = 0; - - /** - * amount of space added since the original layout - needed by links - */ - private int xOffset = 0; - protected int height = 0; - private int verticalAlign = 0; - protected String pageNumberId = null; - private float red, green, blue; - - // Textdecoration - protected boolean underlined = false; - protected boolean overlined = false; - protected boolean lineThrough = false; - - - public InlineArea(FontState fontState, int width, float red, float green, - float blue) { - super(fontState); - this.contentRectangleWidth = width; - this.red = red; - this.green = green; - this.blue = blue; - } - - public float getBlue() { - return this.blue; - } - - public float getGreen() { - return this.green; - } - - public float getRed() { - return this.red; - } - - public void setHeight(int height) { - this.height = height; - } - - public int getHeight() { - return this.height; - } - - public void setVerticalAlign(int align) { - this.verticalAlign = align; - } - - public int getVerticalAlign() { - return this.verticalAlign; - } - - public void setYOffset(int yOffset) { - this.yOffset = yOffset; - } - - public int getYOffset() { - return this.yOffset; - } - - public void setXOffset(int xOffset) { - this.xOffset = xOffset; - } - - public int getXOffset() { - return this.xOffset; - } - - public String getPageNumberID() { - return pageNumberId; - } - - public void setUnderlined(boolean ul) { - this.underlined = ul; - } - - public boolean getUnderlined() { - return this.underlined; - } - - public void setOverlined(boolean ol) { - this.overlined = ol; - } - - public boolean getOverlined() { - return this.overlined; - } - - public void setLineThrough(boolean lt) { - this.lineThrough = lt; - } - - public boolean getLineThrough() { - return this.lineThrough; - } - -} diff --git a/src/org/apache/fop/layout/inline/InlineSpace.java b/src/org/apache/fop/layout/inline/InlineSpace.java deleted file mode 100644 index 7cd9c9452..000000000 --- a/src/org/apache/fop/layout/inline/InlineSpace.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout.inline; - -import org.apache.fop.render.Renderer; -import org.apache.fop.layout.*; - -public class InlineSpace extends Space { - private int size; // in millipoints - private boolean resizeable = - true; // to disallow size changes during justification of a line - // Used to discard some pending spaces in LineArea - private boolean eatable = false; - - // Textdecoration - protected boolean underlined = false; - protected boolean overlined = false; - protected boolean lineThrough = false; - - - public InlineSpace(int amount) { - this.size = amount; - } - - public InlineSpace(int amount, boolean resizeable) { - this.resizeable = resizeable; - this.size = amount; - } - - /** - * @param ul true if text should be underlined - */ - public void setUnderlined(boolean ul) { - this.underlined = ul; - } - - public boolean getUnderlined() { - return this.underlined; - } - - public void setOverlined(boolean ol) { - this.overlined = ol; - } - - public boolean getOverlined() { - return this.overlined; - } - - public void setLineThrough(boolean lt) { - this.lineThrough = lt; - } - - public boolean getLineThrough() { - return this.lineThrough; - } - - public int getSize() { - return size; - } - - public void setSize(int amount) { - this.size = amount; - } - - public boolean getResizeable() { - return resizeable; - } - - public void setResizeable(boolean resizeable) { - this.resizeable = resizeable; - } - - /** - * And eatable InlineSpace is discarded if it occurs - * as the first pending element in a LineArea - */ - public void setEatable(boolean eatable) { - this.eatable = eatable; - } - - public boolean isEatable() { - return eatable; - } - -} diff --git a/src/org/apache/fop/layout/inline/LeaderArea.java b/src/org/apache/fop/layout/inline/LeaderArea.java deleted file mode 100644 index ced173f3e..000000000 --- a/src/org/apache/fop/layout/inline/LeaderArea.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout.inline; - -import org.apache.fop.render.Renderer; -import org.apache.fop.layout.*; - -import java.util.Vector; -import java.util.Enumeration; - -public class LeaderArea extends InlineArea { - - int ruleThickness; - int leaderLengthOptimum; - int leaderPattern; - int ruleStyle; - - float red, green, blue; - public LeaderArea(FontState fontState, float red, float green, - float blue, String text, int leaderLengthOptimum, - int leaderPattern, int ruleThickness, int ruleStyle) { - super(fontState, leaderLengthOptimum, red, green, blue); - - this.leaderPattern = leaderPattern; - this.leaderLengthOptimum = leaderLengthOptimum; - this.ruleStyle = ruleStyle; - // following the xsl spec rule: if rule-style="none" set thickness to 0; - // actually in pdf this doesn't work, because a very thin line is still shown - // this is handled in the pdf renderer - if (ruleStyle == org.apache.fop.fo.properties.RuleStyle.NONE) { - ruleThickness = 0; - } - this.ruleThickness = ruleThickness; - } - - public int getRuleThickness() { - return this.ruleThickness; - } - - public int getRuleStyle() { - return this.ruleStyle; - } - - public int getLeaderPattern() { - return this.leaderPattern; - } - - public int getLeaderLength() { - return this.contentRectangleWidth; - } - - - -} diff --git a/src/org/apache/fop/layout/inline/PageNumberInlineArea.java b/src/org/apache/fop/layout/inline/PageNumberInlineArea.java deleted file mode 100644 index bb3354c2d..000000000 --- a/src/org/apache/fop/layout/inline/PageNumberInlineArea.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout.inline; - -import org.apache.fop.render.Renderer; -import org.apache.fop.datatypes.IDNode; -import org.apache.fop.layout.*; - -public class PageNumberInlineArea extends WordArea { - - - public PageNumberInlineArea(FontState fontState, float red, float green, - float blue, String refid, int width) { - super(fontState, red, green, blue, "?", width); - this.pageNumberId = refid; - } - -} diff --git a/src/org/apache/fop/layout/inline/WordArea.java b/src/org/apache/fop/layout/inline/WordArea.java deleted file mode 100644 index cfb1dd1af..000000000 --- a/src/org/apache/fop/layout/inline/WordArea.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.layout.inline; - -import org.apache.fop.render.Renderer; -import org.apache.fop.layout.FontState; - -public class WordArea extends InlineArea { - - private String text; - - // Textdecoration - protected boolean underlined = false; - protected boolean overlined = false; - protected boolean lineThrough = false; - - - public WordArea(FontState fontState, float red, float green, float blue, - String text, int width) { - super(fontState, width, red, green, blue); - this.text = text; - this.contentRectangleWidth = width; - } - - public String getText() { - return this.text; - } - - public void setUnderlined(boolean ul) { - this.underlined = ul; - } - - public boolean getUnderlined() { - return this.underlined; - } - -} diff --git a/src/org/apache/fop/pdf/PDFDocument.java b/src/org/apache/fop/pdf/PDFDocument.java index a719124d3..3954793d0 100644 --- a/src/org/apache/fop/pdf/PDFDocument.java +++ b/src/org/apache/fop/pdf/PDFDocument.java @@ -14,7 +14,6 @@ package org.apache.fop.pdf; // referenced and I'd rather not do it import org.apache.fop.image.FopImage; -import org.apache.fop.layout.LinkSet; import org.apache.fop.datatypes.ColorSpace; import org.apache.fop.render.pdf.CIDFont; @@ -60,7 +59,7 @@ public class PDFDocument { /** * the version of PDF supported */ - protected static final String pdfVersion = "1.3"; + protected static final String pdfVersion = "1.4"; /** * the current character position @@ -999,7 +998,7 @@ public class PDFDocument { PDFLink link = new PDFLink(++this.objectcount, rect); this.objects.add(link); - if (linkType == LinkSet.EXTERNAL) { + if (linkType == PDFLink.EXTERNAL) { // check destination if (destination.endsWith(".pdf")) { // FileSpec PDFFileSpec fileSpec = new PDFFileSpec(++this.objectcount, diff --git a/src/org/apache/fop/pdf/PDFLink.java b/src/org/apache/fop/pdf/PDFLink.java index dbe8138af..e1e20b661 100644 --- a/src/org/apache/fop/pdf/PDFLink.java +++ b/src/org/apache/fop/pdf/PDFLink.java @@ -14,6 +14,8 @@ import java.awt.Rectangle; * class representing an /Annot object of /Subtype /Link */ public class PDFLink extends PDFObject { + public static final int EXTERNAL = 0; + public static final int INTERNAL = 1; float ulx; float uly; diff --git a/src/org/apache/fop/render/awt/AWTRenderer.java b/src/org/apache/fop/render/awt/AWTRenderer.java index 711accc51..5578187b1 100644 --- a/src/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/org/apache/fop/render/awt/AWTRenderer.java @@ -72,7 +72,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable /** * Image Object and Graphics Object. The Graphics Object is the Graphics - * object that is contained withing the Image Object. + * object that is contained within the Image Object. */ private BufferedImage pageImage = null; private Graphics2D graphics = null; diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index c61c9cf86..26691e61d 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -519,7 +519,7 @@ public class PDFRenderer extends PrintRenderer { currentStream.add("ET\nq\n" + ((float)w) + " 0 0 " + ((float)-h) + " " + (((float)currentBlockIPPosition) / 1000f) + " " - + (((float)(currentBPPosition - 1000 * h)) / 1000f) + " cm\n" + "/Im" + + (((float)(currentBPPosition + 1000 * h)) / 1000f) + " cm\n" + "/Im" + xobj + " Do\nQ\nBT\n"); } diff --git a/src/org/apache/fop/svg/PDFANode.java b/src/org/apache/fop/svg/PDFANode.java index 5117cd76b..e7e47f244 100644 --- a/src/org/apache/fop/svg/PDFANode.java +++ b/src/org/apache/fop/svg/PDFANode.java @@ -55,10 +55,10 @@ public class PDFANode extends CompositeGraphicsNode { super.paint(g2d); if(g2d instanceof PDFGraphics2D) { PDFGraphics2D pdfg = (PDFGraphics2D)g2d; - int type = org.apache.fop.layout.LinkSet.EXTERNAL; + int type = org.apache.fop.pdf.PDFLink.EXTERNAL; Shape outline = getOutline(); if(destination.startsWith("#svgView(viewBox(")) { - type = org.apache.fop.layout.LinkSet.INTERNAL; + type = org.apache.fop.pdf.PDFLink.INTERNAL; String nums = destination.substring(17, destination.length() - 2); float x = 0; float y = 0; diff --git a/src/org/apache/fop/svg/PDFGraphics2D.java b/src/org/apache/fop/svg/PDFGraphics2D.java index e4ada44ba..3d5b65f39 100644 --- a/src/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/org/apache/fop/svg/PDFGraphics2D.java @@ -166,7 +166,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { Rectangle rect = b.getBounds(); rect.height = -rect.height; - if(linkType != LinkSet.EXTERNAL) { + if(linkType != PDFLink.EXTERNAL) { String pdfdest = "/FitR " + dest; currentPage.addAnnotation(pdfDoc.makeLinkCurrentPage(rect, pdfdest)); } else { diff --git a/src/org/apache/fop/svg/PDFTextElementBridge.java b/src/org/apache/fop/svg/PDFTextElementBridge.java index e0992bea0..bb88865db 100644 --- a/src/org/apache/fop/svg/PDFTextElementBridge.java +++ b/src/org/apache/fop/svg/PDFTextElementBridge.java @@ -98,3 +98,4 @@ public class PDFTextElementBridge extends SVGTextElementBridge { return true; } } + diff --git a/src/org/apache/fop/svg/SVGElement.java b/src/org/apache/fop/svg/SVGElement.java index 988658db1..e8d018754 100644 --- a/src/org/apache/fop/svg/SVGElement.java +++ b/src/org/apache/fop/svg/SVGElement.java @@ -10,7 +10,6 @@ package org.apache.fop.svg; // FOP import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.Area; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; import org.apache.fop.layout.inline.*; -- 2.39.5