From b78f0e158a8f17a8fd7d6a747eed94dedd345ee4 Mon Sep 17 00:00:00 2001 From: Christian Geisert Date: Fri, 22 Nov 2002 15:10:49 +0000 Subject: [PATCH] Perfomance tuning (reduced object creation etc.) (see bug #14103) Submitted by: Henrik Olsson git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@195609 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 2 + .../apache/fop/extensions/ExtensionObj.java | 4 +- src/org/apache/fop/fo/ColorProfile.java | 1 - src/org/apache/fop/fo/Declarations.java | 1 - src/org/apache/fop/fo/FONode.java | 2 +- src/org/apache/fop/fo/FOText.java | 10 +-- src/org/apache/fop/fo/FObj.java | 4 +- src/org/apache/fop/fo/FObjMixed.java | 10 ++- src/org/apache/fop/fo/PropertyList.java | 35 +++++----- src/org/apache/fop/fo/PropertyManager.java | 45 +++++++++---- src/org/apache/fop/fo/Status.java | 33 ++++------ src/org/apache/fop/fo/Title.java | 3 +- .../apache/fop/fo/ToBeImplementedElement.java | 5 +- src/org/apache/fop/fo/Unknown.java | 5 +- src/org/apache/fop/fo/UnknownXMLObj.java | 5 +- src/org/apache/fop/fo/XMLElement.java | 4 +- src/org/apache/fop/fo/XMLObj.java | 5 +- .../apache/fop/fo/expr/PropertyTokenizer.java | 33 +++++++--- src/org/apache/fop/fo/flow/AbstractFlow.java | 27 ++++---- .../apache/fop/fo/flow/AbstractTableBody.java | 20 +++--- src/org/apache/fop/fo/flow/BasicLink.java | 8 +-- src/org/apache/fop/fo/flow/BidiOverride.java | 3 +- src/org/apache/fop/fo/flow/Block.java | 20 +++--- .../apache/fop/fo/flow/BlockContainer.java | 10 +-- src/org/apache/fop/fo/flow/Character.java | 10 +-- .../apache/fop/fo/flow/ExternalGraphic.java | 26 ++++---- src/org/apache/fop/fo/flow/Float.java | 3 +- src/org/apache/fop/fo/flow/Footnote.java | 13 ++-- src/org/apache/fop/fo/flow/FootnoteBody.java | 8 +-- .../fop/fo/flow/InitialPropertySet.java | 3 +- .../apache/fop/fo/flow/InlineContainer.java | 1 - .../fop/fo/flow/InstreamForeignObject.java | 30 ++++----- src/org/apache/fop/fo/flow/Leader.java | 8 +-- src/org/apache/fop/fo/flow/ListBlock.java | 14 ++-- src/org/apache/fop/fo/flow/ListItem.java | 10 +-- src/org/apache/fop/fo/flow/ListItemBody.java | 14 ++-- src/org/apache/fop/fo/flow/ListItemLabel.java | 4 +- src/org/apache/fop/fo/flow/Marker.java | 12 ++-- 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 | 7 +- .../fop/fo/flow/PageNumberCitation.java | 10 +-- .../apache/fop/fo/flow/RetrieveMarker.java | 8 +-- src/org/apache/fop/fo/flow/StaticContent.java | 12 ++-- src/org/apache/fop/fo/flow/Table.java | 48 +++++++------- .../apache/fop/fo/flow/TableAndCaption.java | 3 +- src/org/apache/fop/fo/flow/TableCaption.java | 3 +- src/org/apache/fop/fo/flow/TableCell.java | 16 ++--- src/org/apache/fop/fo/flow/TableColumn.java | 6 +- src/org/apache/fop/fo/flow/TableRow.java | 34 +++++----- .../fop/fo/pagination/PageSequence.java | 10 +-- .../apache/fop/fo/pagination/RegionBody.java | 6 +- .../apache/fop/layout/BorderAndPadding.java | 65 ++++++++----------- .../apache/fop/render/mif/MIFRenderer.java | 1 - src/org/apache/fop/svg/SVGElement.java | 10 ++- 58 files changed, 350 insertions(+), 355 deletions(-) diff --git a/CHANGES b/CHANGES index 7d3e34c99..e00679d93 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ ============================================================================== Done since 0.20.4 release +- Perfomance tuning (reduced object creation etc.) (see bug #14103) + Submitted by: Henrik Olsson - Update to Xerces 2.2.1 (Jeremias Maerki) - Fixed EOFException in TTFReader (Bug #14576) Submitted by: Bernard D'Have diff --git a/src/org/apache/fop/extensions/ExtensionObj.java b/src/org/apache/fop/extensions/ExtensionObj.java index 9cfc091ef..2f9f0a504 100644 --- a/src/org/apache/fop/extensions/ExtensionObj.java +++ b/src/org/apache/fop/extensions/ExtensionObj.java @@ -32,10 +32,10 @@ public abstract class ExtensionObj extends FObj { * * @param area */ - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { ExtensionArea extArea = new ExtensionArea(this); area.addChild(extArea); - return new Status(Status.OK); + return Status.OK; } diff --git a/src/org/apache/fop/fo/ColorProfile.java b/src/org/apache/fop/fo/ColorProfile.java index 8d4597477..108e0f117 100644 --- a/src/org/apache/fop/fo/ColorProfile.java +++ b/src/org/apache/fop/fo/ColorProfile.java @@ -8,7 +8,6 @@ package org.apache.fop.fo; // FOP -import org.apache.fop.fo.*; import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.apps.FOPException; diff --git a/src/org/apache/fop/fo/Declarations.java b/src/org/apache/fop/fo/Declarations.java index 928282254..1b629a520 100644 --- a/src/org/apache/fop/fo/Declarations.java +++ b/src/org/apache/fop/fo/Declarations.java @@ -8,7 +8,6 @@ package org.apache.fop.fo; // FOP -import org.apache.fop.fo.*; import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.apps.FOPException; diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java index 8b8f9d956..90634741a 100644 --- a/src/org/apache/fop/fo/FONode.java +++ b/src/org/apache/fop/fo/FONode.java @@ -140,7 +140,7 @@ abstract public class FONode { return this.linkSet; } - abstract public Status layout(Area area) throws FOPException; + abstract public int layout(Area area) throws FOPException; /** * lets outside sources access the property list diff --git a/src/org/apache/fop/fo/FOText.java b/src/org/apache/fop/fo/FOText.java index f03cbea50..e5af635a2 100644 --- a/src/org/apache/fop/fo/FOText.java +++ b/src/org/apache/fop/fo/FOText.java @@ -74,11 +74,11 @@ public class FOText extends FONode { return false; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (!(area instanceof BlockArea)) { log.error("text outside block area" + new String(ca, 0, ca.length)); - return new Status(Status.OK); + return Status.OK; } if (this.marker == START) { String fontFamily = @@ -132,11 +132,11 @@ public class FOText extends FONode { // see LineArea.addText() // this.marker = 0; - return new Status(Status.OK); + return Status.OK; } else if (this.marker != orig_start) { - return new Status(Status.AREA_FULL_SOME); + return Status.AREA_FULL_SOME; } else { - return new Status(Status.AREA_FULL_NONE); + return Status.AREA_FULL_NONE; } } diff --git a/src/org/apache/fop/fo/FObj.java b/src/org/apache/fop/fo/FObj.java index a6f2b73ea..a9f3fede3 100644 --- a/src/org/apache/fop/fo/FObj.java +++ b/src/org/apache/fop/fo/FObj.java @@ -63,9 +63,9 @@ public abstract class FObj extends FONode { * * @param area */ - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // should always be overridden - return new Status(Status.OK); + return Status.OK; } /** diff --git a/src/org/apache/fop/fo/FObjMixed.java b/src/org/apache/fop/fo/FObjMixed.java index 4b1d0df9c..471c0d605 100644 --- a/src/org/apache/fop/fo/FObjMixed.java +++ b/src/org/apache/fop/fo/FObjMixed.java @@ -59,9 +59,7 @@ public abstract class FObjMixed extends FObj { super.addChild(child); } - - - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.properties != null) { Property prop = this.properties.get("id"); @@ -84,13 +82,13 @@ public abstract class FObjMixed extends FObj { 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()) { + int status; + if (Status.isIncomplete((status = fo.layout(area)))) { this.marker = i; return status; } } - return new Status(Status.OK); + return Status.OK; } } diff --git a/src/org/apache/fop/fo/PropertyList.java b/src/org/apache/fop/fo/PropertyList.java index 660348a63..fc4d1795f 100644 --- a/src/org/apache/fop/fo/PropertyList.java +++ b/src/org/apache/fop/fo/PropertyList.java @@ -12,6 +12,9 @@ import org.apache.fop.fo.properties.WritingMode; import org.apache.fop.apps.FOPException; import java.util.HashMap; +import java.util.Map; +import java.util.Iterator; + public class PropertyList extends HashMap { @@ -39,20 +42,22 @@ public class PropertyList extends HashMap { "inline-progression-dimension" }; - static private final HashMap wmtables = new HashMap(4); - { - wmtables.put(new Integer(WritingMode.LR_TB), /* lr-tb */ - new byte[] { - START, END, BEFORE, AFTER, BLOCKPROGDIM, INLINEPROGDIM - }); - wmtables.put(new Integer(WritingMode.RL_TB), /* rl-tb */ - new byte[] { - END, START, BEFORE, AFTER, BLOCKPROGDIM, INLINEPROGDIM - }); - wmtables.put(new Integer(WritingMode.TB_RL), /* tb-rl */ - new byte[] { - AFTER, BEFORE, START, END, INLINEPROGDIM, BLOCKPROGDIM - }); + static private final byte[][] wmtables; + static{ + int i = Math.max( Math.max( WritingMode.LR_TB, WritingMode.RL_TB), WritingMode.TB_RL)+1; + wmtables = new byte[i][]; + wmtables[ WritingMode.LR_TB] = /* lr-tb */ + new byte[] { + START, END, BEFORE, AFTER, BLOCKPROGDIM, INLINEPROGDIM + }; + wmtables[ WritingMode.RL_TB] = /* rl-tb */ + new byte[] { + END, START, BEFORE, AFTER, BLOCKPROGDIM, INLINEPROGDIM + }; + wmtables[ WritingMode.TB_RL] = /* tb-rl */ + new byte[] { + AFTER, BEFORE, START, END, INLINEPROGDIM, BLOCKPROGDIM + }; } private PropertyListBuilder builder; @@ -363,7 +368,7 @@ public class PropertyList extends HashMap { * Set the writing mode traits for the FO with this property list. */ public void setWritingMode(int writingMode) { - this.wmtable = (byte[])wmtables.get(new Integer(writingMode)); + this.wmtable = wmtables[writingMode]; } } diff --git a/src/org/apache/fop/fo/PropertyManager.java b/src/org/apache/fop/fo/PropertyManager.java index c63be2dd5..0f2cf5dc9 100644 --- a/src/org/apache/fop/fo/PropertyManager.java +++ b/src/org/apache/fop/fo/PropertyManager.java @@ -6,7 +6,7 @@ */ package org.apache.fop.fo; - +import java.lang.StringBuffer; import java.net.MalformedURLException; import java.text.FieldPosition; import java.text.MessageFormat; @@ -48,15 +48,6 @@ public class PropertyManager { private String[] saTop; private String[] saBottom; - private static MessageFormat msgColorFmt = - new MessageFormat("border-{0}-color"); - private static MessageFormat msgStyleFmt = - new MessageFormat("border-{0}-style"); - private static MessageFormat msgWidthFmt = - new MessageFormat("border-{0}-width"); - private static MessageFormat msgPaddingFmt = - new MessageFormat("padding-{0}"); - public PropertyManager(PropertyList pList) { this.properties = pList; } @@ -104,16 +95,42 @@ public class PropertyManager { private void initBorderInfo(int whichSide, String[] saSide) { borderAndPadding.setPadding(whichSide, - properties.get(msgPaddingFmt.format(saSide)).getCondLength()); + properties.get(formatPadding(saSide)).getCondLength()); + // If style = none, force width to 0, don't get Color - int style = properties.get(msgStyleFmt.format(saSide)).getEnum(); + int style = properties.get(formatStyle(saSide)).getEnum(); if (style != Constants.NONE) { borderAndPadding.setBorder(whichSide, style, - properties.get(msgWidthFmt.format(saSide)).getCondLength(), - properties.get(msgColorFmt.format(saSide)).getColorType()); + properties.get(formatWidth(saSide)).getCondLength(), + properties.get(formatColor(saSide)).getColorType()); } } + private static final String padding = new String("padding-"); + private static final String border = new String("border-"); + private static final String width = new String("-width"); + private static final String color = new String("-color"); + private static final String style = new String("-style"); + + private String formatPadding(String[] saSide) { + StringBuffer sb = new StringBuffer(14); + return sb.append(padding).append(saSide[0]).toString(); + } + + private String formatColor(String[] saSide) { + StringBuffer sb = new StringBuffer(19); + return sb.append(border).append(saSide[0]).append(color).toString(); + } + private String formatWidth(String[] saSide) { + StringBuffer sb = new StringBuffer(19); + return sb.append(border).append(saSide[0]).append(width).toString(); + } + + private String formatStyle(String[] saSide) { + StringBuffer sb = new StringBuffer(19); + return sb.append(border).append(saSide[0]).append(style).toString(); + } + public HyphenationProps getHyphenationProps() { if (hyphProps == null) { this.hyphProps = new HyphenationProps(); diff --git a/src/org/apache/fop/fo/Status.java b/src/org/apache/fop/fo/Status.java index 58f14c153..720b7e2eb 100644 --- a/src/org/apache/fop/fo/Status.java +++ b/src/org/apache/fop/fo/Status.java @@ -10,9 +10,7 @@ package org.apache.fop.fo; /** * classes representating the status of laying out a formatting object */ -public class Status { - - protected int code; +public abstract class Status { public final static int OK = 1; public final static int AREA_FULL_NONE = 2; @@ -23,26 +21,21 @@ public class Status { public final static int FORCE_COLUMN_BREAK = 7; public final static int KEEP_WITH_NEXT = 8; - public Status(int code) { - this.code = code; - } - - public int getCode() { - return this.code; + public static boolean isIncomplete(int code) { + return ((code != OK) && (code != KEEP_WITH_NEXT)); } - public boolean isIncomplete() { - return ((this.code != OK) && (this.code != KEEP_WITH_NEXT)); + public static boolean laidOutNone(int code) { + return (code == AREA_FULL_NONE); } - public boolean laidOutNone() { - return (this.code == AREA_FULL_NONE); + public static boolean isPageBreak(int code) { + switch( code) { + case FORCE_PAGE_BREAK: + case FORCE_PAGE_BREAK_EVEN: + case FORCE_PAGE_BREAK_ODD: + return true; + } + return false; } - - public boolean isPageBreak() { - return ((this.code == FORCE_PAGE_BREAK) - || (this.code == FORCE_PAGE_BREAK_EVEN) - || (this.code == FORCE_PAGE_BREAK_ODD)); - } - } diff --git a/src/org/apache/fop/fo/Title.java b/src/org/apache/fop/fo/Title.java index 09c31feac..3ab1ea6b7 100644 --- a/src/org/apache/fop/fo/Title.java +++ b/src/org/apache/fop/fo/Title.java @@ -8,7 +8,6 @@ package org.apache.fop.fo; // FOP -import org.apache.fop.fo.*; import org.apache.fop.datatypes.*; import org.apache.fop.layout.*; import org.apache.fop.fo.flow.*; @@ -41,7 +40,7 @@ public class Title extends ToBeImplementedElement { return "fo:title"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); diff --git a/src/org/apache/fop/fo/ToBeImplementedElement.java b/src/org/apache/fop/fo/ToBeImplementedElement.java index c9af684fc..55707d5ee 100644 --- a/src/org/apache/fop/fo/ToBeImplementedElement.java +++ b/src/org/apache/fop/fo/ToBeImplementedElement.java @@ -8,7 +8,6 @@ package org.apache.fop.fo; // FOP -import org.apache.fop.fo.*; import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.Area; @@ -23,10 +22,10 @@ public abstract class ToBeImplementedElement extends FObj { super(parent, propertyList); } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { log.debug("The element '" + this.getName() + "' is not yet implemented."); - return new Status(Status.OK); + return Status.OK; } } diff --git a/src/org/apache/fop/fo/Unknown.java b/src/org/apache/fop/fo/Unknown.java index 25a965de6..091d02308 100644 --- a/src/org/apache/fop/fo/Unknown.java +++ b/src/org/apache/fop/fo/Unknown.java @@ -8,7 +8,6 @@ package org.apache.fop.fo; // FOP -import org.apache.fop.fo.*; import org.apache.fop.layout.*; import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; @@ -44,8 +43,8 @@ public class Unknown extends FObj { return "(unknown)"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { log.debug("Layout Unknown element"); - return new Status(Status.OK); + return Status.OK; } } diff --git a/src/org/apache/fop/fo/UnknownXMLObj.java b/src/org/apache/fop/fo/UnknownXMLObj.java index e3217f953..245e783e6 100644 --- a/src/org/apache/fop/fo/UnknownXMLObj.java +++ b/src/org/apache/fop/fo/UnknownXMLObj.java @@ -7,7 +7,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.*; @@ -82,7 +81,7 @@ public class UnknownXMLObj extends XMLObj { super.addCharacters(data, start, length); } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { //if (!(area instanceof ForeignObjectArea)) { // this is an error //throw new FOPException("Foreign XML not in fo:instream-foreign-object"); @@ -90,7 +89,7 @@ public class UnknownXMLObj extends XMLObj { log.error("no handler defined for " + this.getName() + " foreign xml"); /* return status */ - return new Status(Status.OK); + return Status.OK; } public String getName() { diff --git a/src/org/apache/fop/fo/XMLElement.java b/src/org/apache/fop/fo/XMLElement.java index 518abbdb5..7e0258b7e 100644 --- a/src/org/apache/fop/fo/XMLElement.java +++ b/src/org/apache/fop/fo/XMLElement.java @@ -74,7 +74,7 @@ public class XMLElement extends XMLObj { * * @return the status of the layout */ - public Status layout(final Area area) throws FOPException { + public int layout(final Area area) throws FOPException { if (!(area instanceof ForeignObjectArea)) { // this is an error @@ -82,7 +82,7 @@ public class XMLElement extends XMLObj { } /* return status */ - return new Status(Status.OK); + return Status.OK; } private void init() { diff --git a/src/org/apache/fop/fo/XMLObj.java b/src/org/apache/fop/fo/XMLObj.java index 0449bb976..9e2cf7149 100644 --- a/src/org/apache/fop/fo/XMLObj.java +++ b/src/org/apache/fop/fo/XMLObj.java @@ -8,7 +8,6 @@ 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; @@ -140,12 +139,12 @@ public abstract class XMLObj extends FObj { * @param area the area to layout the object into * @return the status of the layout */ - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { /* generate a warning */ log.error("" + this.tagName + " outside foreign xml"); /* return status */ - return new Status(Status.OK); + return Status.OK; } public void removeID(IDReferences idReferences) {} diff --git a/src/org/apache/fop/fo/expr/PropertyTokenizer.java b/src/org/apache/fop/fo/expr/PropertyTokenizer.java index 025c68695..f09199f9b 100644 --- a/src/org/apache/fop/fo/expr/PropertyTokenizer.java +++ b/src/org/apache/fop/fo/expr/PropertyTokenizer.java @@ -281,12 +281,23 @@ class PropertyTokenizer { return false; } + static private final int CS = 1, nameStartChars = 1; // "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + static private final int C = 2, nameChars = 2; //".-0123456789"; + static private final int D = 4, digits = 4; //"0123456789"; + static private final int H = 8, hexchars = 8; //digits + "abcdefABCDEF"; + static private final int C_CS = C + CS; - static private final String nameStartChars = - "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - static private final String nameChars = ".-0123456789"; - static private final String digits = "0123456789"; - static private final String hexchars = digits + "abcdefABCDEF"; + + static private final int charMap[] = { + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, //0x00 + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, //0x10 + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,C,C,0, //0x20 + C+D+H,C+D+H,C+D+H,C+D+H, C+D+H,C+D+H,C+D+H,C+D+H, C+D+H,C+D+H,0,0, 0,0,0,0, //0x30 + 0,CS+H,CS+H,CS+H, CS+H,CS+H,CS+H,CS, CS,CS,CS,CS, CS,CS,CS,CS, //0x40 + CS,CS,CS,CS, CS,CS,CS,CS, CS,CS,CS,0, 0,0,0,CS, //0x50 + 0,CS+H,CS+H,CS+H, CS+H,CS+H,CS+H,CS, CS,CS,CS,CS, CS,CS,CS,CS, //0x60 + CS,CS,CS,CS, CS,CS,CS,CS, CS,CS,CS,0, 0,0,0,0 //0x70 + }; /** * Return a boolean value indicating whether the argument is a @@ -294,7 +305,7 @@ class PropertyTokenizer { * @param c The character to check */ private static final boolean isDigit(char c) { - return digits.indexOf(c) >= 0; + return c > 0 && c < 128 && (charMap[ c] & digits) != 0; } /** @@ -303,7 +314,8 @@ class PropertyTokenizer { * @param c The character to check */ private static final boolean isHexDigit(char c) { - return hexchars.indexOf(c) >= 0; + return c > 0 && c < 128 && (charMap[ c] & hexchars) != 0; + //return hexchars.indexOf(c) >= 0; } /** @@ -328,7 +340,8 @@ class PropertyTokenizer { * @param c The character to check */ private static final boolean isNameStartChar(char c) { - return nameStartChars.indexOf(c) >= 0 || c >= 0x80; + return c >= 0x80 || c < 0 || (charMap[ c] & nameStartChars) != 0; + //return nameStartChars.indexOf(c) >= 0 || c >= 0x80; } /** @@ -337,8 +350,8 @@ class PropertyTokenizer { * @param c The character to check */ private static final boolean isNameChar(char c) { - return nameStartChars.indexOf(c) >= 0 || nameChars.indexOf(c) >= 0 - || c >= 0x80; + return c > 0x80 || c < 0 || (charMap[ c] & C_CS) != 0; + //return nameStartChars.indexOf(c) >= 0 || nameChars.indexOf(c) >= 0 || c >= 0x80; } } diff --git a/src/org/apache/fop/fo/flow/AbstractFlow.java b/src/org/apache/fop/fo/flow/AbstractFlow.java index fe52e6cf7..e01350d2e 100644 --- a/src/org/apache/fop/fo/flow/AbstractFlow.java +++ b/src/org/apache/fop/fo/flow/AbstractFlow.java @@ -45,7 +45,7 @@ public abstract class AbstractFlow extends FObj { */ private int contentWidth; - private Status _status = new Status(Status.AREA_FULL_NONE); + private int _status = Status.AREA_FULL_NONE; protected AbstractFlow(FObj parent, @@ -64,12 +64,12 @@ public abstract class AbstractFlow extends FObj { return _flowName; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { return layout(area, null); } - public Status layout(Area area, Region region) throws FOPException { + public int layout(Area area, Region region) throws FOPException { if (this.marker == START) { this.marker = 0; } @@ -120,23 +120,22 @@ public abstract class AbstractFlow extends FObj { * continue; * } */ - if (_status.isIncomplete()) { - if ((prevChildMustKeepWithNext) && (_status.laidOutNone())) { + if (Status.isIncomplete(_status)) { + if ((prevChildMustKeepWithNext) && (Status.laidOutNone(_status))) { this.marker = i - 1; FObj prevChild = (FObj)children.get(this.marker); prevChild.removeAreas(); prevChild.resetMarker(); prevChild.removeID(area.getIDReferences()); - _status = new Status(Status.AREA_FULL_SOME); + _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) { + if (_status == Status.FORCE_COLUMN_BREAK) { this.marker = i; - _status = - new Status(Status.FORCE_PAGE_BREAK); // same thing + _status = Status.FORCE_PAGE_BREAK; // same thing return _status; } else { this.marker = i; @@ -144,7 +143,7 @@ public abstract class AbstractFlow extends FObj { } else { // not the last column, but could be page breaks - if (_status.isPageBreak()) { + if (Status.isPageBreak(_status)) { this.marker = i; return _status; } @@ -153,7 +152,7 @@ public abstract class AbstractFlow extends FObj { i--; } } - if (_status.getCode() == Status.KEEP_WITH_NEXT) { + if (_status == Status.KEEP_WITH_NEXT) { prevChildMustKeepWithNext = true; } else { prevChildMustKeepWithNext = false; @@ -163,17 +162,17 @@ public abstract class AbstractFlow extends FObj { } protected void setContentWidth(int contentWidth) { - this.contentWidth = contentWidth; + this.contentWidth = contentWidth; } /** * Return the content width of this flow (really of the region * in which it is flowing). */ public int getContentWidth() { - return this.contentWidth; + return this.contentWidth; } - public Status getStatus() { + public int getStatus() { return _status; } diff --git a/src/org/apache/fop/fo/flow/AbstractTableBody.java b/src/org/apache/fop/fo/flow/AbstractTableBody.java index 62fb0a5a8..b1657098c 100644 --- a/src/org/apache/fop/fo/flow/AbstractTableBody.java +++ b/src/org/apache/fop/fo/flow/AbstractTableBody.java @@ -53,9 +53,9 @@ public abstract class AbstractTableBody extends FObj { return areaContainer.getHeight() + spaceBefore + spaceAfter; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); + return Status.OK; } if (this.marker == START) { @@ -157,10 +157,10 @@ public abstract class AbstractTableBody extends FObj { } } - Status status; - if ((status = row.layout(areaContainer)).isIncomplete()) { + int status; + if (Status.isIncomplete((status = row.layout(areaContainer)))) { // BUG!!! don't distinguish between break-before and after! - if (status.isPageBreak()) { + if (Status.isPageBreak(status)) { this.marker = i; area.addChild(areaContainer); // areaContainer.end(); @@ -190,12 +190,12 @@ public abstract class AbstractTableBody extends FObj { // Fix for infinite loop bug if keeps are too big for page rowSpanMgr.setIgnoreKeeps(true); - return new Status(Status.AREA_FULL_NONE); + return 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) && (status == Status.AREA_FULL_NONE)) { + status = Status.AREA_FULL_SOME; } if (!((i == 0) && (areaContainer.getContentHeight() <= 0))) { area.addChild(areaContainer); @@ -208,7 +208,7 @@ public abstract class AbstractTableBody extends FObj { rowSpanMgr.setIgnoreKeeps(true); return status; - } else if (status.getCode() == Status.KEEP_WITH_NEXT + } else if (status == Status.KEEP_WITH_NEXT || rowSpanMgr.hasUnfinishedSpans()) { keepWith.add(row); endKeepGroup = false; @@ -234,7 +234,7 @@ public abstract class AbstractTableBody extends FObj { area.start(); } - return new Status(Status.OK); + return Status.OK; } public void removeLayout(Area area) { diff --git a/src/org/apache/fop/fo/flow/BasicLink.java b/src/org/apache/fop/fo/flow/BasicLink.java index 13d60ad18..958ed3f75 100644 --- a/src/org/apache/fop/fo/flow/BasicLink.java +++ b/src/org/apache/fop/fo/flow/BasicLink.java @@ -39,7 +39,7 @@ public class BasicLink extends Inline { return "fo:basic-link"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { String destination; int linkType; @@ -118,8 +118,8 @@ public class BasicLink extends Inline { FONode fo = (FONode)children.get(i); fo.setLinkSet(ls); - Status status; - if ((status = fo.layout(area)).isIncomplete()) { + int status; + if (Status.isIncomplete((status = fo.layout(area)))) { this.marker = i; return status; } @@ -135,7 +135,7 @@ public class BasicLink extends Inline { p.addLinkSet(ls); - return new Status(Status.OK); + return Status.OK; } } diff --git a/src/org/apache/fop/fo/flow/BidiOverride.java b/src/org/apache/fop/fo/flow/BidiOverride.java index 6fba63f2f..a0b264fe1 100644 --- a/src/org/apache/fop/fo/flow/BidiOverride.java +++ b/src/org/apache/fop/fo/flow/BidiOverride.java @@ -10,7 +10,6 @@ package org.apache.fop.fo.flow; // FOP 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; @@ -39,7 +38,7 @@ public class BidiOverride extends ToBeImplementedElement { return "fo:bidi-override"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // Common Aural Properties AuralProps mAurProps = propMgr.getAuralProps(); diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index b420d9ca1..10c517242 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -74,14 +74,14 @@ public class Block extends FObjMixed { return "fo:block"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { BlockArea blockArea; // log.error(" b:LAY[" + marker + "] "); if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); + return Status.OK; } if (this.marker == START) { @@ -141,7 +141,7 @@ public class Block extends FObjMixed { // area int breakBeforeStatus = propMgr.checkBreakBefore(area); if (breakBeforeStatus != Status.OK) { - return new Status(breakBeforeStatus); + return breakBeforeStatus; } } @@ -190,8 +190,8 @@ public class Block extends FObjMixed { 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()) { + int status; + if (Status.isIncomplete(status = fo.layout(blockArea))) { this.marker = i; // this block was modified by // Hani Elabed 11/27/2000 @@ -202,10 +202,10 @@ public class Block extends FObjMixed { // new block to replace the one above // Hani Elabed 11/27/2000 - if (status.getCode() == Status.AREA_FULL_NONE) { + if (status == Status.AREA_FULL_NONE) { // something has already been laid out if ((i != 0)) { - status = new Status(Status.AREA_FULL_SOME); + status = Status.AREA_FULL_SOME; area.addChild(blockArea); area.setMaxHeight(area.getMaxHeight() - spaceLeft + blockArea.getMaxHeight()); @@ -259,18 +259,18 @@ public class Block extends FObjMixed { if (breakAfterStatus != Status.OK) { this.marker = BREAK_AFTER; blockArea = null; //Faster GC - BlockArea is big - return new Status(breakAfterStatus); + return breakAfterStatus; } if (keepWithNext != 0) { blockArea = null; // Faster GC - BlockArea is big - return new Status(Status.KEEP_WITH_NEXT); + return Status.KEEP_WITH_NEXT; } // log.error(" b:OK" + marker + " "); blockArea.isLast(true); blockArea = null; // Faster GC - BlockArea is big - return new Status(Status.OK); + return 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 2b41c00f1..7fa74f09c 100644 --- a/src/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/org/apache/fop/fo/flow/BlockContainer.java @@ -54,7 +54,7 @@ public class BlockContainer extends FObj { return "fo:block-container"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.marker == START) { // Common Accessibility Properties @@ -125,8 +125,8 @@ public class BlockContainer extends FObj { 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()) { + int status; + if (Status.isIncomplete((status = fo.layout(areaContainer)))) { /* * if ((prevChildMustKeepWithNext) && (status.laidOutNone())) { * this.marker = i - 1; @@ -142,7 +142,7 @@ public class BlockContainer extends FObj { * } */ } - if (status.getCode() == Status.KEEP_WITH_NEXT) { + if (status == Status.KEEP_WITH_NEXT) { prevChildMustKeepWithNext = true; } } @@ -152,7 +152,7 @@ public class BlockContainer extends FObj { areaContainer.setHeight(height); area.addChild(areaContainer); - return new Status(Status.OK); + return Status.OK; } /** diff --git a/src/org/apache/fop/fo/flow/Character.java b/src/org/apache/fop/fo/flow/Character.java index b15423649..e1b7f7f56 100644 --- a/src/org/apache/fop/fo/flow/Character.java +++ b/src/org/apache/fop/fo/flow/Character.java @@ -56,11 +56,11 @@ public class Character extends FObj { return "fo:character"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { BlockArea blockArea; if (!(area instanceof BlockArea)) { log.warn("currently Character can only be in a BlockArea"); - return new Status(Status.OK); + return Status.OK; } blockArea = (BlockArea)area; boolean textDecoration; @@ -135,7 +135,7 @@ public class Character extends FObj { LineArea la = blockArea.getCurrentLineArea(); if (la == null) { - return new Status(Status.AREA_FULL_NONE); + return Status.AREA_FULL_NONE; } la.changeFont(propMgr.getFontState(area.getFontInfo())); la.changeColor(red, green, blue); @@ -147,7 +147,7 @@ public class Character extends FObj { if (result == Character.DOESNOT_FIT) { la = blockArea.createNextLineArea(); if (la == null) { - return new Status(Status.AREA_FULL_NONE); + return Status.AREA_FULL_NONE; } la.changeFont(propMgr.getFontState(area.getFontInfo())); la.changeColor(red, green, blue); @@ -157,7 +157,7 @@ public class Character extends FObj { la.addCharacter(characterValue, this.getLinkSet(), textDecoration); } - return new Status(Status.OK); + return Status.OK; } diff --git a/src/org/apache/fop/fo/flow/ExternalGraphic.java b/src/org/apache/fop/fo/flow/ExternalGraphic.java index c3fcae73a..04b9ec933 100644 --- a/src/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/org/apache/fop/fo/flow/ExternalGraphic.java @@ -53,7 +53,7 @@ public class ExternalGraphic extends FObj { return "fo:external-graphic"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.marker == START) { @@ -165,7 +165,7 @@ public class ExternalGraphic extends FObj { } if (area.spaceLeft() < (height + spaceBefore)) { - return new Status(Status.AREA_FULL_NONE); + return Status.AREA_FULL_NONE; } this.imageArea = @@ -193,15 +193,15 @@ public class ExternalGraphic extends FObj { if (breakBefore == BreakBefore.PAGE || ((spaceBefore + imageArea.getHeight()) > area.spaceLeft())) { - return new Status(Status.FORCE_PAGE_BREAK); + return Status.FORCE_PAGE_BREAK; } if (breakBefore == BreakBefore.ODD_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_ODD); + return Status.FORCE_PAGE_BREAK_ODD; } if (breakBefore == BreakBefore.EVEN_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_EVEN); + return Status.FORCE_PAGE_BREAK_EVEN; } @@ -209,13 +209,13 @@ public class ExternalGraphic extends FObj { BlockArea ba = (BlockArea)area; LineArea la = ba.getCurrentLineArea(); if (la == null) { - return new Status(Status.AREA_FULL_NONE); + return Status.AREA_FULL_NONE; } la.addPending(); if (imageArea.getContentWidth() > la.getRemainingWidth()) { la = ba.createNextLineArea(); if (la == null) { - return new Status(Status.AREA_FULL_NONE); + return Status.AREA_FULL_NONE; } } la.addInlineArea(imageArea, this.getLinkSet()); @@ -227,23 +227,19 @@ public class ExternalGraphic extends FObj { if (breakAfter == BreakAfter.PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK); + return Status.FORCE_PAGE_BREAK; } if (breakAfter == BreakAfter.ODD_PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_ODD); + return Status.FORCE_PAGE_BREAK_ODD; } if (breakAfter == BreakAfter.EVEN_PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_EVEN); + return Status.FORCE_PAGE_BREAK_EVEN; } - - - - } catch (MalformedURLException urlex) { // bad URL log.error("Error while creating area : " @@ -258,7 +254,7 @@ public class ExternalGraphic extends FObj { // area.start(); // } - return new Status(Status.OK); + return Status.OK; } } diff --git a/src/org/apache/fop/fo/flow/Float.java b/src/org/apache/fop/fo/flow/Float.java index c913704c4..638260a72 100644 --- a/src/org/apache/fop/fo/flow/Float.java +++ b/src/org/apache/fop/fo/flow/Float.java @@ -9,7 +9,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; @@ -39,7 +38,7 @@ public class Float extends ToBeImplementedElement { return "fo:float"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // this.properties.get("float"); // this.properties.get("clear"); diff --git a/src/org/apache/fop/fo/flow/Footnote.java b/src/org/apache/fop/fo/flow/Footnote.java index b6eb8270b..bdfdc0e58 100644 --- a/src/org/apache/fop/fo/flow/Footnote.java +++ b/src/org/apache/fop/fo/flow/Footnote.java @@ -15,6 +15,7 @@ import org.apache.fop.fo.properties.*; import org.apache.fop.messaging.*; // Java +import java.util.Iterator; import java.util.ArrayList; public class Footnote extends FObj { @@ -40,7 +41,7 @@ public class Footnote extends FObj { return "fo:footnote"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { FONode inline = null; FONode fbody = null; if (this.marker == START) { @@ -51,8 +52,8 @@ public class Footnote extends FObj { FONode fo = (FONode)children.get(i); if (fo instanceof Inline) { inline = fo; - Status status = fo.layout(area); - if (status.isIncomplete()) { + int status = fo.layout(area); + if (Status.isIncomplete(status)) { return status; } } else if (inline != null && fo instanceof FootnoteBody) { @@ -70,7 +71,7 @@ public class Footnote extends FObj { log.error("no footnote-body in footnote"); } if (area instanceof BlockArea) {} - return new Status(Status.OK); + return Status.OK; } public static boolean layoutFootnote(Page p, FootnoteBody fb, Area area) { @@ -88,8 +89,8 @@ public class Footnote extends FObj { footArea.setMaxHeight(bac.getMaxHeight() + footArea.getHeight()); } - Status status = fb.layout(footArea); - if (status.isIncomplete()) { + int status = fb.layout(footArea); + if (Status.isIncomplete(status)) { // add as a pending footnote return false; } else { diff --git a/src/org/apache/fop/fo/flow/FootnoteBody.java b/src/org/apache/fop/fo/flow/FootnoteBody.java index 18a8c0917..616706293 100644 --- a/src/org/apache/fop/fo/flow/FootnoteBody.java +++ b/src/org/apache/fop/fo/flow/FootnoteBody.java @@ -46,7 +46,7 @@ public class FootnoteBody extends FObj { return "fo:footnote-body"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.marker == START) { this.marker = 0; } @@ -69,8 +69,8 @@ public class FootnoteBody extends FObj { 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()) { + int status; + if (Status.isIncomplete((status = fo.layout(blockArea)))) { this.resetMarker(); return status; } @@ -79,7 +79,7 @@ public class FootnoteBody extends FObj { area.addChild(blockArea); area.increaseHeight(blockArea.getHeight()); blockArea.isLast(true); - return new Status(Status.OK); + return Status.OK; } } diff --git a/src/org/apache/fop/fo/flow/InitialPropertySet.java b/src/org/apache/fop/fo/flow/InitialPropertySet.java index ca1d7998c..80c455bbb 100644 --- a/src/org/apache/fop/fo/flow/InitialPropertySet.java +++ b/src/org/apache/fop/fo/flow/InitialPropertySet.java @@ -10,7 +10,6 @@ package org.apache.fop.fo.flow; // FOP 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; @@ -40,7 +39,7 @@ public class InitialPropertySet extends ToBeImplementedElement { return "fo:initial-property-set"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); diff --git a/src/org/apache/fop/fo/flow/InlineContainer.java b/src/org/apache/fop/fo/flow/InlineContainer.java index 4eba7fa47..04a69c377 100644 --- a/src/org/apache/fop/fo/flow/InlineContainer.java +++ b/src/org/apache/fop/fo/flow/InlineContainer.java @@ -9,7 +9,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; diff --git a/src/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/org/apache/fop/fo/flow/InstreamForeignObject.java index 3ec4b03b3..e05e989cc 100644 --- a/src/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -86,10 +86,10 @@ public class InstreamForeignObject extends FObj { * * @return the status of the layout */ - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); + return Status.OK; } if (this.marker == START) { @@ -192,10 +192,10 @@ public class InstreamForeignObject extends FObj { /* layout foreign object */ if (this.children.size() > 0) { FONode fo = (FONode)children.get(0); - Status status; + int status; // currently FONode must be an SVG - if ((status = - fo.layout(this.areaCurrent)).isIncomplete()) { + if (Status.isIncomplete((status = + fo.layout(this.areaCurrent)))) { return status; } @@ -209,33 +209,33 @@ public class InstreamForeignObject extends FObj { if (breakBefore == BreakBefore.PAGE || ((spaceBefore + areaCurrent.getEffectiveHeight()) > area.spaceLeft())) { - return new Status(Status.FORCE_PAGE_BREAK); + return Status.FORCE_PAGE_BREAK; } if (breakBefore == BreakBefore.ODD_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_ODD); + return Status.FORCE_PAGE_BREAK_ODD; } if (breakBefore == BreakBefore.EVEN_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_EVEN); + return Status.FORCE_PAGE_BREAK_EVEN; } } if (this.areaCurrent == null) { - return new Status(Status.OK); + return Status.OK; } if (area instanceof BlockArea) { BlockArea ba = (BlockArea)area; LineArea la = ba.getCurrentLineArea(); if (la == null) { - return new Status(Status.AREA_FULL_NONE); + return Status.AREA_FULL_NONE; } la.addPending(); if (areaCurrent.getEffectiveWidth() > la.getRemainingWidth()) { la = ba.createNextLineArea(); if (la == null) { - return new Status(Status.AREA_FULL_NONE); + return Status.AREA_FULL_NONE; } } la.addInlineArea(areaCurrent, this.getLinkSet()); @@ -278,22 +278,22 @@ public class InstreamForeignObject extends FObj { if (breakAfter == BreakAfter.PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK); + return Status.FORCE_PAGE_BREAK; } if (breakAfter == BreakAfter.ODD_PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_ODD); + return Status.FORCE_PAGE_BREAK_ODD; } if (breakAfter == BreakAfter.EVEN_PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_EVEN); + return Status.FORCE_PAGE_BREAK_EVEN; } areaCurrent = null; /* return status */ - return new Status(Status.OK); + return Status.OK; } } diff --git a/src/org/apache/fop/fo/flow/Leader.java b/src/org/apache/fop/fo/flow/Leader.java index 53a3d6436..0bc6a7c83 100644 --- a/src/org/apache/fop/fo/flow/Leader.java +++ b/src/org/apache/fop/fo/flow/Leader.java @@ -47,12 +47,12 @@ public class Leader extends FObjMixed { return "fo:leader"; } - public Status layout(Area area) throws FOPException { + public int 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); + return Status.OK; } else { blockArea = (BlockArea)area; } @@ -143,10 +143,10 @@ public class Leader extends FObjMixed { ruleStyle, leaderPatternWidth, leaderAlignment); if (succeeded == 1) { - return new Status(Status.OK); + return Status.OK; } else { // not sure that this is the correct Status here - return new Status(Status.AREA_FULL_SOME); + return Status.AREA_FULL_SOME; } } diff --git a/src/org/apache/fop/fo/flow/ListBlock.java b/src/org/apache/fop/fo/flow/ListBlock.java index 8c72b1bc6..139db6bab 100644 --- a/src/org/apache/fop/fo/flow/ListBlock.java +++ b/src/org/apache/fop/fo/flow/ListBlock.java @@ -49,7 +49,7 @@ public class ListBlock extends FObj { return "fo:list-block"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.marker == START) { // Common Accessibility Properties @@ -143,13 +143,13 @@ public class ListBlock extends FObj { 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); + return 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); + int status; + if (Status.isIncomplete((status = listItem.layout(blockArea)))) { + if (status == Status.AREA_FULL_NONE && i > 0) { + status = Status.AREA_FULL_SOME; } this.marker = i; blockArea.end(); @@ -172,7 +172,7 @@ public class ListBlock extends FObj { } blockArea.isLast(true); - return new Status(Status.OK); + return Status.OK; } } diff --git a/src/org/apache/fop/fo/flow/ListItem.java b/src/org/apache/fop/fo/flow/ListItem.java index a7b868216..088a52415 100644 --- a/src/org/apache/fop/fo/flow/ListItem.java +++ b/src/org/apache/fop/fo/flow/ListItem.java @@ -49,7 +49,7 @@ public class ListItem extends FObj { return "fo:list-item"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.marker == START) { // Common Accessibility Properties @@ -133,7 +133,7 @@ public class ListItem extends FObj { ListItemLabel label = (ListItemLabel)children.get(0); ListItemBody body = (ListItemBody)children.get(1); - Status status; + int status; // what follows doesn't yet take into account whether the // body failed completely or only got some text in @@ -143,13 +143,13 @@ public class ListItem extends FObj { area.getIDReferences().configureID(id, area); status = label.layout(blockArea); - if (status.isIncomplete()) { + if (Status.isIncomplete(status)) { return status; } } status = body.layout(blockArea); - if (status.isIncomplete()) { + if (Status.isIncomplete(status)) { blockArea.end(); area.addChild(blockArea); area.increaseHeight(blockArea.getHeight()); @@ -170,7 +170,7 @@ public class ListItem extends FObj { area.start(); } this.blockArea.isLast(true); - return new Status(Status.OK); + return Status.OK; } /** diff --git a/src/org/apache/fop/fo/flow/ListItemBody.java b/src/org/apache/fop/fo/flow/ListItemBody.java index fb4858926..9bc161dae 100644 --- a/src/org/apache/fop/fo/flow/ListItemBody.java +++ b/src/org/apache/fop/fo/flow/ListItemBody.java @@ -36,7 +36,7 @@ public class ListItemBody extends FObj { return "fo:list-item-body"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.marker == START) { // Common Accessibility Properties @@ -62,17 +62,17 @@ public class ListItemBody extends FObj { for (int i = this.marker; i < numChildren; i++) { FObj fo = (FObj)children.get(i); - Status status; - if ((status = fo.layout(area)).isIncomplete()) { + int status; + if (Status.isIncomplete((status = fo.layout(area)))) { this.marker = i; - if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - return new Status(Status.AREA_FULL_NONE); + if ((i == 0) && (status == Status.AREA_FULL_NONE)) { + return Status.AREA_FULL_NONE; } else { - return new Status(Status.AREA_FULL_SOME); + return Status.AREA_FULL_SOME; } } } - return new Status(Status.OK); + return Status.OK; } } diff --git a/src/org/apache/fop/fo/flow/ListItemLabel.java b/src/org/apache/fop/fo/flow/ListItemLabel.java index 8d4512f78..adaadf07c 100644 --- a/src/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/org/apache/fop/fo/flow/ListItemLabel.java @@ -36,7 +36,7 @@ public class ListItemLabel extends FObj { return "fo:list-item-label"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { int numChildren = this.children.size(); if (numChildren != 1) { @@ -62,7 +62,7 @@ public class ListItemLabel extends FObj { * of areas returned by each of the children of the fo:list-item-label. */ - Status status; + int 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 3773d3c45..5b113a1fa 100644 --- a/src/org/apache/fop/fo/flow/Marker.java +++ b/src/org/apache/fop/fo/flow/Marker.java @@ -49,16 +49,16 @@ public class Marker extends FObjMixed { return "fo:marker"; } - public Status layout(Area area) throws FOPException { + public int 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); + return Status.OK; } - public Status layoutMarker(Area area) throws FOPException { + public int layoutMarker(Area area) throws FOPException { if (this.marker == START) this.marker = 0; @@ -66,14 +66,14 @@ public class Marker extends FObjMixed { for (int i = this.marker; i < numChildren; i++) { FONode fo = (FONode)children.get(i); - Status status; - if ((status = fo.layout(area)).isIncomplete()) { + int status; + if (Status.isIncomplete((status = fo.layout(area)))) { this.marker = i; return status; } } - return new Status(Status.OK); + return Status.OK; } public String getMarkerClassName() { diff --git a/src/org/apache/fop/fo/flow/MultiCase.java b/src/org/apache/fop/fo/flow/MultiCase.java index 5dc5d56bb..86ffabbff 100644 --- a/src/org/apache/fop/fo/flow/MultiCase.java +++ b/src/org/apache/fop/fo/flow/MultiCase.java @@ -9,7 +9,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; @@ -38,7 +37,7 @@ public class MultiCase extends ToBeImplementedElement { return "fo:multi-case"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); diff --git a/src/org/apache/fop/fo/flow/MultiProperties.java b/src/org/apache/fop/fo/flow/MultiProperties.java index 8849f879f..afebcf0b3 100644 --- a/src/org/apache/fop/fo/flow/MultiProperties.java +++ b/src/org/apache/fop/fo/flow/MultiProperties.java @@ -9,7 +9,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; @@ -39,7 +38,7 @@ public class MultiProperties extends ToBeImplementedElement { return "fo:multi-properties"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); diff --git a/src/org/apache/fop/fo/flow/MultiPropertySet.java b/src/org/apache/fop/fo/flow/MultiPropertySet.java index ca501a260..82cc40b36 100644 --- a/src/org/apache/fop/fo/flow/MultiPropertySet.java +++ b/src/org/apache/fop/fo/flow/MultiPropertySet.java @@ -9,7 +9,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; @@ -39,7 +38,7 @@ public class MultiPropertySet extends ToBeImplementedElement { return "fo:multi-property-set"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // this.properties.get("id"); // this.properties.get("active-state"); diff --git a/src/org/apache/fop/fo/flow/MultiSwitch.java b/src/org/apache/fop/fo/flow/MultiSwitch.java index 1fec9402f..b454d36a3 100644 --- a/src/org/apache/fop/fo/flow/MultiSwitch.java +++ b/src/org/apache/fop/fo/flow/MultiSwitch.java @@ -9,7 +9,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; @@ -39,7 +38,7 @@ public class MultiSwitch extends ToBeImplementedElement { return "fo:multi-switch"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); diff --git a/src/org/apache/fop/fo/flow/MultiToggle.java b/src/org/apache/fop/fo/flow/MultiToggle.java index ef9cc2b09..35800df35 100644 --- a/src/org/apache/fop/fo/flow/MultiToggle.java +++ b/src/org/apache/fop/fo/flow/MultiToggle.java @@ -9,7 +9,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; @@ -39,7 +38,7 @@ public class MultiToggle extends ToBeImplementedElement { return "fo:multi-toggle"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java index 36eb3d9ee..ec02bd6e3 100644 --- a/src/org/apache/fop/fo/flow/PageNumber.java +++ b/src/org/apache/fop/fo/flow/PageNumber.java @@ -12,7 +12,6 @@ import org.apache.fop.fo.*; import org.apache.fop.layout.*; import org.apache.fop.datatypes.*; import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; public class PageNumber extends FObj { @@ -44,10 +43,10 @@ public class PageNumber extends FObj { return "fo:page-number"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (!(area instanceof BlockArea)) { log.warn("page-number outside block area"); - return new Status(Status.OK); + return Status.OK; } if (this.marker == START) { @@ -108,7 +107,7 @@ public class PageNumber extends FObj { red, green, blue, wrapOption, null, whiteSpaceCollapse, p.toCharArray(), 0, p.length(), ts, VerticalAlign.BASELINE); - return new Status(Status.OK); + return Status.OK; } } diff --git a/src/org/apache/fop/fo/flow/PageNumberCitation.java b/src/org/apache/fop/fo/flow/PageNumberCitation.java index 569d91407..bd5e21f2f 100644 --- a/src/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/org/apache/fop/fo/flow/PageNumberCitation.java @@ -104,10 +104,10 @@ public class PageNumberCitation extends FObj { return "fo:page-number-citation"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (!(area instanceof BlockArea)) { log.warn("page-number-citation outside block area"); - return new Status(Status.OK); + return Status.OK; } IDReferences idReferences = area.getIDReferences(); @@ -192,7 +192,7 @@ public class PageNumberCitation extends FObj { BlockArea blockArea = (BlockArea)area; LineArea la = blockArea.getCurrentLineArea(); if (la == null) { - return new Status(Status.AREA_FULL_NONE); + return Status.AREA_FULL_NONE; } la.changeFont(propMgr.getFontState(area.getFontInfo())); la.changeColor(red, green, blue); @@ -211,9 +211,9 @@ public class PageNumberCitation extends FObj { if (this.marker == -1) { - return new Status(Status.OK); + return Status.OK; } else { - return new Status(Status.AREA_FULL_NONE); + return 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 490410c1f..a9cdcd675 100644 --- a/src/org/apache/fop/fo/flow/RetrieveMarker.java +++ b/src/org/apache/fop/fo/flow/RetrieveMarker.java @@ -50,7 +50,7 @@ public class RetrieveMarker extends FObj { return "fo:retrieve-marker"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // locate qualifying areas by 'marker-class-name' and // 'retrieve-boundary'. Initially we will always check // the containing page @@ -73,15 +73,15 @@ public class RetrieveMarker extends FObj { bestMarker = searchPage(previousPage, false); currentPage = previousPage; } else { - return new Status(Status.OK); + return Status.OK; } } } else { - return new Status(Status.OK); + return Status.OK; } } - Status status = new Status(Status.OK); + int status = Status.OK; // 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 diff --git a/src/org/apache/fop/fo/flow/StaticContent.java b/src/org/apache/fop/fo/flow/StaticContent.java index 7cd81481a..a7d8de70e 100644 --- a/src/org/apache/fop/fo/flow/StaticContent.java +++ b/src/org/apache/fop/fo/flow/StaticContent.java @@ -39,7 +39,7 @@ public class StaticContent extends AbstractFlow { return "fo:static-content"; } - public Status layout(Area area, Region region) throws FOPException { + public int 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 @@ -69,19 +69,19 @@ public class StaticContent extends AbstractFlow { for (int i = 0; i < numChildren; i++) { FObj fo = (FObj)children.get(i); - Status status; - if ((status = fo.layout(area)).isIncomplete()) { + int status; + if (Status.isIncomplete((status = fo.layout(area)))) { // 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); + if ((i != 0) && (status == Status.AREA_FULL_NONE)) { + status = Status.AREA_FULL_SOME; } return (status); } } resetMarker(); - return new Status(Status.OK); + return 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 d7e263c7b..254a11bd3 100644 --- a/src/org/apache/fop/fo/flow/Table.java +++ b/src/org/apache/fop/fo/flow/Table.java @@ -65,9 +65,9 @@ public class Table extends FObj { return "fo:table"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); + return Status.OK; } if (this.marker == START) { @@ -142,15 +142,15 @@ public class Table extends FObj { this.marker = 0; if (breakBefore == BreakBefore.PAGE) { - return new Status(Status.FORCE_PAGE_BREAK); + return Status.FORCE_PAGE_BREAK; } if (breakBefore == BreakBefore.ODD_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_ODD); + return Status.FORCE_PAGE_BREAK_ODD; } if (breakBefore == BreakBefore.EVEN_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_EVEN); + return Status.FORCE_PAGE_BREAK_EVEN; } } @@ -203,28 +203,28 @@ public class Table extends FObj { 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); + return 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); + return 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); + return Status.OK; } - Status status; + int status; if (tableHeader != null &&!addedHeader) { - if ((status = - tableHeader.layout(areaContainer)).isIncomplete()) { + if (Status.isIncomplete((status = + tableHeader.layout(areaContainer)))) { tableHeader.resetMarker(); - return new Status(Status.AREA_FULL_NONE); + return Status.AREA_FULL_NONE; } addedHeader = true; tableHeader.resetMarker(); @@ -233,19 +233,19 @@ public class Table extends FObj { } if (tableFooter != null &&!this.omitFooterAtBreak &&!addedFooter) { - if ((status = - tableFooter.layout(areaContainer)).isIncomplete()) { - return new Status(Status.AREA_FULL_NONE); + if (Status.isIncomplete((status = + tableFooter.layout(areaContainer)))) { + return Status.AREA_FULL_NONE; } addedFooter = true; tableFooter.resetMarker(); } ((TableBody)fo).setColumns(columns); - if ((status = fo.layout(areaContainer)).isIncomplete()) { + if (Status.isIncomplete((status = fo.layout(areaContainer)))) { this.marker = i; if (bodyCount == 0 - && status.getCode() == Status.AREA_FULL_NONE) { + && status == Status.AREA_FULL_NONE) { if (tableHeader != null) tableHeader.removeLayout(areaContainer); if (tableFooter != null) @@ -268,7 +268,7 @@ public class Table extends FObj { + ((TableBody)fo).getHeight()); } setupColumnHeights(); - status = new Status(Status.AREA_FULL_SOME); + status = Status.AREA_FULL_SOME; } return status; } else { @@ -287,7 +287,7 @@ public class Table extends FObj { } if (tableFooter != null && this.omitFooterAtBreak) { - if (tableFooter.layout(areaContainer).isIncomplete()) { + if (Status.isIncomplete(tableFooter.layout(areaContainer))) { // 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 @@ -301,7 +301,7 @@ public class Table extends FObj { } tableFooter.removeLayout(areaContainer); tableFooter.resetMarker(); - return new Status(Status.AREA_FULL_SOME); + return Status.AREA_FULL_SOME; } } @@ -326,20 +326,20 @@ public class Table extends FObj { if (breakAfter == BreakAfter.PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK); + return Status.FORCE_PAGE_BREAK; } if (breakAfter == BreakAfter.ODD_PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_ODD); + return Status.FORCE_PAGE_BREAK_ODD; } if (breakAfter == BreakAfter.EVEN_PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_EVEN); + return Status.FORCE_PAGE_BREAK_EVEN; } - return new Status(Status.OK); + return Status.OK; } protected void setupColumnHeights() { diff --git a/src/org/apache/fop/fo/flow/TableAndCaption.java b/src/org/apache/fop/fo/flow/TableAndCaption.java index 96258035e..d0c56a35b 100644 --- a/src/org/apache/fop/fo/flow/TableAndCaption.java +++ b/src/org/apache/fop/fo/flow/TableAndCaption.java @@ -9,7 +9,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; @@ -39,7 +38,7 @@ public class TableAndCaption extends ToBeImplementedElement { return "fo:table-and-caption"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); diff --git a/src/org/apache/fop/fo/flow/TableCaption.java b/src/org/apache/fop/fo/flow/TableCaption.java index a6cb29286..9543f7421 100644 --- a/src/org/apache/fop/fo/flow/TableCaption.java +++ b/src/org/apache/fop/fo/flow/TableCaption.java @@ -9,7 +9,6 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; -import org.apache.fop.fo.flow.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; @@ -39,7 +38,7 @@ public class TableCaption extends ToBeImplementedElement { return "fo:table-caption"; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); diff --git a/src/org/apache/fop/fo/flow/TableCell.java b/src/org/apache/fop/fo/flow/TableCell.java index 1d8c786f2..e2474d818 100644 --- a/src/org/apache/fop/fo/flow/TableCell.java +++ b/src/org/apache/fop/fo/flow/TableCell.java @@ -201,10 +201,10 @@ public class TableCell extends FObj { } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { int originalAbsoluteHeight = area.getAbsoluteHeight(); if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); + return Status.OK; } if (this.marker == START) { @@ -270,16 +270,16 @@ public class TableCell extends FObj { // need to pass already processed content. this.marker = i; - Status status; - if ((status = fo.layout(cellArea)).isIncomplete()) { + int status; + if (Status.isIncomplete((status = fo.layout(cellArea)))) { // this.marker = i; - if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - return new Status(Status.AREA_FULL_NONE); + if ((i == 0) && (status == Status.AREA_FULL_NONE)) { + return Status.AREA_FULL_NONE; } else { // hani Elabed 11/21/2000 area.addChild(cellArea); // area.setAbsoluteHeight(cellArea.getAbsoluteHeight()); - return new Status(Status.AREA_FULL_SOME); + return Status.AREA_FULL_SOME; } } @@ -307,7 +307,7 @@ public class TableCell extends FObj { // area.setHeight(cellArea.getHeight()); // area.setAbsoluteHeight(originalAbsoluteHeight); - return new Status(Status.OK); + return Status.OK; } /** diff --git a/src/org/apache/fop/fo/flow/TableColumn.java b/src/org/apache/fop/fo/flow/TableColumn.java index 42a944b85..1e430c345 100644 --- a/src/org/apache/fop/fo/flow/TableColumn.java +++ b/src/org/apache/fop/fo/flow/TableColumn.java @@ -105,9 +105,9 @@ public class TableColumn extends FObj { setup = true; } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); + return Status.OK; } if (this.marker == START) { @@ -127,7 +127,7 @@ public class TableColumn extends FObj { areaContainer.setHeight(area.getHeight()); area.addChild(areaContainer); } - return new Status(Status.OK); + return Status.OK; } public void setColumnOffset(int columnOffset) { diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index a74da108a..45d497249 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -208,9 +208,9 @@ public class TableRow extends FObj { } } - public Status layout(Area area) throws FOPException { + public int layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); + return Status.OK; } // Layout the first area for this FO @@ -231,7 +231,7 @@ public class TableRow extends FObj { this.marker = 0; int breakStatus = propMgr.checkBreakBefore(area); if (breakStatus != Status.OK) - return new Status(breakStatus); + return breakStatus; } if (marker == 0) { // KDL: need to do this if thrown or if split? @@ -301,10 +301,10 @@ public class TableRow extends FObj { 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) + int status; + if (Status.isIncomplete((status = cell.layout(areaContainer)))) { + if ((keepTogether.getType() == KeepValue.KEEP_WITH_ALWAYS) + || (status == 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 @@ -312,8 +312,8 @@ public class TableRow extends FObj { // Remove spanning cells from RowSpanMgr? this.resetMarker(); this.removeID(area.getIDReferences()); - return new Status(Status.AREA_FULL_NONE); - } else if (status.getCode() == Status.AREA_FULL_SOME) { + return Status.AREA_FULL_NONE; + } else if (status == Status.AREA_FULL_SOME) { /* * Row is not keep-together, cell isn't spanning * and part of it fits. We can break the cell and @@ -379,35 +379,35 @@ public class TableRow extends FObj { // return new Status(Status.OK); if (someCellDidNotLayoutCompletely) { - return new Status(Status.AREA_FULL_SOME); + return Status.AREA_FULL_SOME; } else { if (rowSpanMgr.hasUnfinishedSpans()) { // Ignore break after if row span! - return new Status(Status.KEEP_WITH_NEXT); + return Status.KEEP_WITH_NEXT; } if (breakAfter == BreakAfter.PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK); + return Status.FORCE_PAGE_BREAK; } if (breakAfter == BreakAfter.ODD_PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_ODD); + return Status.FORCE_PAGE_BREAK_ODD; } if (breakAfter == BreakAfter.EVEN_PAGE) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_EVEN); + return Status.FORCE_PAGE_BREAK_EVEN; } if (breakAfter == BreakAfter.COLUMN) { this.marker = BREAK_AFTER; - return new Status(Status.FORCE_COLUMN_BREAK); + return Status.FORCE_COLUMN_BREAK; } if (keepWithNext.getType() != KeepValue.KEEP_WITH_AUTO) { - return new Status(Status.KEEP_WITH_NEXT); + return Status.KEEP_WITH_NEXT; } - return new Status(Status.OK); + return Status.OK; } } diff --git a/src/org/apache/fop/fo/pagination/PageSequence.java b/src/org/apache/fop/fo/pagination/PageSequence.java index 017bdae86..994a38995 100644 --- a/src/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/org/apache/fop/fo/pagination/PageSequence.java @@ -144,7 +144,7 @@ public class PageSequence extends FObj { } else { pageNumberType = EXPLICIT; try { - int pageStart = new Integer(ipnValue).intValue(); + int pageStart = Integer.parseInt(ipnValue); this.firstPageNumber = (pageStart > 0) ? pageStart : 1; } catch (NumberFormatException nfe) { throw new FOPException("The value '" + ipnValue @@ -271,25 +271,25 @@ public class PageSequence extends FObj { } // make pages and layout content - Status status = new Status(Status.OK); + int status = Status.OK; Page currentPage = null; do { boolean isBlankPage = false; // for this calculation we are already on the // blank page - if (status.getCode() == Status.FORCE_PAGE_BREAK_EVEN) { + if (status == Status.FORCE_PAGE_BREAK_EVEN) { if ((currentPageNumber % 2) == 1) { isBlankPage = true; } - } else if (status.getCode() == Status.FORCE_PAGE_BREAK_ODD) { + } else if (status == Status.FORCE_PAGE_BREAK_ODD) { if ((currentPageNumber % 2) == 0) { isBlankPage = true; } } currentPage = makePage(areaTree, isBlankPage, currentPage); status = flow.getStatus(); - } while (status.isIncomplete()); + } while (Status.isIncomplete(status)); // handle cases of 'force-page-count' which do not depend // on the presence of a following page sequence diff --git a/src/org/apache/fop/fo/pagination/RegionBody.java b/src/org/apache/fop/fo/pagination/RegionBody.java index 1271e3ae3..69383d4a4 100644 --- a/src/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/org/apache/fop/fo/pagination/RegionBody.java @@ -87,7 +87,11 @@ public class RegionBody extends Region { this.properties.get("column-count").getString(); int columnCount = 1; try { - columnCount = Integer.parseInt(columnCountAsString); + if( columnCountAsString.charAt(0) >= '0' && columnCountAsString.charAt(0)<= '9') { + columnCount = Integer.parseInt(columnCountAsString); + } else { + log.error("Bad value on region body 'column-count'"); + } } catch (NumberFormatException nfe) { log.error("Bad value on region body 'column-count'"); columnCount = 1; diff --git a/src/org/apache/fop/layout/BorderAndPadding.java b/src/org/apache/fop/layout/BorderAndPadding.java index ace036800..5afbf9aa0 100644 --- a/src/org/apache/fop/layout/BorderAndPadding.java +++ b/src/org/apache/fop/layout/BorderAndPadding.java @@ -16,35 +16,25 @@ public class BorderAndPadding implements Cloneable { public static final int RIGHT = 1; public static final int BOTTOM = 2; public static final int LEFT = 3; - - private static class ResolvedCondLength implements Cloneable { - int iLength; // Resolved length value - boolean bDiscard; - - ResolvedCondLength(CondLength length) { - bDiscard = length.isDiscard(); - iLength = length.mvalue(); - } - - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - + //ResolvedCondLength is long, mask wiht 0x100000000 != 0 is bDiscard + // mask wiht 0xFFFFFFFF is iLength + static final long bDiscard_MASK = 0x100000000L; + static final long iLength_MASK = 0xFFFFFFFFL; + private static final long new_ResolvedCondLength(CondLength length) { + return (length.isDiscard()?bDiscard_MASK:0) + length.mvalue(); } /** - * Return a full copy of the BorderAndPadding information. This clones all - * padding and border information. - * @return The copy. - */ + * Return a full copy of the BorderAndPadding information. This clones all + * padding and border information. + * @return The copy. + */ public Object clone() throws CloneNotSupportedException { BorderAndPadding bp = (BorderAndPadding) super.clone(); - bp.padding = (ResolvedCondLength[])padding.clone(); + bp.padding = new long[ padding.length]; // + System.arraycopy( padding, 0, bp.padding, 0, padding.length); bp.borderInfo = (BorderInfo[])borderInfo.clone(); - for (int i=0; i