diff options
author | Kelly Campbell <kellyc@apache.org> | 2001-02-23 06:00:29 +0000 |
---|---|---|
committer | Kelly Campbell <kellyc@apache.org> | 2001-02-23 06:00:29 +0000 |
commit | ddaf8b2ad8b8241641d9406805319709e17b2f0d (patch) | |
tree | fb9ec046012a7514c4ba31826468f717a577f39a /src/org/apache/fop | |
parent | 20eb35ecb4511689c56bdf21c73eb03591e37d67 (diff) | |
download | xmlgraphics-fop-ddaf8b2ad8b8241641d9406805319709e17b2f0d.tar.gz xmlgraphics-fop-ddaf8b2ad8b8241641d9406805319709e17b2f0d.zip |
Patch for list-block to support body-start and label-end
PR: 682
Obtained from:
Submitted by: Peter S. Housel <housel@acm.org>
Reviewed by:
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194086 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop')
-rw-r--r-- | src/org/apache/fop/datatypes/LinearCombinationLength.java | 89 | ||||
-rw-r--r-- | src/org/apache/fop/fo/FONode.java | 51 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/BodyStartFunction.java | 79 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/LabelEndFunction.java | 96 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/Numeric.java | 1 | ||||
-rw-r--r-- | src/org/apache/fop/fo/expr/PropertyParser.java | 4 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/Block.java | 13 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/ExternalGraphic.java | 11 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/InlineGraphic.java | 11 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/InstreamForeignObject.java | 11 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/ListBlock.java | 23 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/ListItem.java | 313 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/ListItemBody.java | 5 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/ListItemLabel.java | 5 |
14 files changed, 423 insertions, 289 deletions
diff --git a/src/org/apache/fop/datatypes/LinearCombinationLength.java b/src/org/apache/fop/datatypes/LinearCombinationLength.java new file mode 100644 index 000000000..71126cfea --- /dev/null +++ b/src/org/apache/fop/datatypes/LinearCombinationLength.java @@ -0,0 +1,89 @@ +/*-- $Id$ -- + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Fop" and "Apache Software Foundation" must not be used to + endorse or promote products derived from this software without prior + written permission. For written permission, please contact + apache@apache.org. + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + James Tauber <jtauber@jtauber.com>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + + */ +package org.apache.fop.datatypes; + +import java.util.Vector; +import org.apache.fop.messaging.MessageHandler; + +/** + * a percent specified length quantity in XSL + */ +public class LinearCombinationLength extends Length { + + protected Vector factors; + protected Vector lengths; + + public LinearCombinationLength() { + super(0); + factors = new Vector(); + lengths = new Vector(); + super.setIsComputed(false); + } + + public void addTerm(double factor, Length length) { + factors.addElement(new Double(factor)); + lengths.addElement(length); + } + + /** + * Return the computed value in millipoints. + */ + protected int computeValue() { + int result = 0; + int numFactors = factors.size(); + for(int i = 0; i < numFactors; ++i) { + result += (int)(((Double)factors.elementAt(i)).doubleValue() + * (double)((Length)lengths.elementAt(i)).mvalue()); + } + return result; + } + +} diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java index c0245c59e..a4d67c608 100644 --- a/src/org/apache/fop/fo/FONode.java +++ b/src/org/apache/fop/fo/FONode.java @@ -81,14 +81,8 @@ abstract public class FONode { */ protected int marker = START; - protected boolean isInLabel = false; - protected boolean isInListBody = false; protected boolean isInTableCell = false; - protected int bodyIndent; - protected int distanceBetweenStarts; - protected int labelSeparation; - protected int forcedStartOffset = 0; protected int forcedWidth = 0; @@ -101,24 +95,6 @@ abstract public class FONode { this.parent = parent; } - public void setIsInLabel() { - this.isInLabel = true; - // made recursive by Eric Schaeffer - for (int i = 0; i < this.children.size(); i++ ) { - FONode child = (FONode) this.children.elementAt(i); - child.setIsInLabel(); - } - } - - public void setIsInListBody() { - this.isInListBody = true; - // made recursive by Eric Schaeffer - for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode) this.children.elementAt(i); - child.setIsInListBody(); - } - } - public void setIsInTableCell() { this.isInTableCell = true; // made recursive by Eric Schaeffer @@ -128,33 +104,6 @@ abstract public class FONode { } } - public void setDistanceBetweenStarts(int distance) { - this.distanceBetweenStarts = distance; - // made recursive by Eric Schaeffer - for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode) this.children.elementAt(i); - child.setDistanceBetweenStarts(distance); - } - } - - public void setLabelSeparation(int separation) { - this.labelSeparation = separation; - // made recursive by Eric Schaeffer - for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode) this.children.elementAt(i); - child.setLabelSeparation(separation); - } - } - - public void setBodyIndent(int indent) { - this.bodyIndent = indent; - // made recursive by Eric Schaeffer - for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode) this.children.elementAt(i); - child.setBodyIndent(indent); - } - } - public void forceStartOffset(int offset) { this.forcedStartOffset = offset; // made recursive by Eric Schaeffer diff --git a/src/org/apache/fop/fo/expr/BodyStartFunction.java b/src/org/apache/fop/fo/expr/BodyStartFunction.java new file mode 100644 index 000000000..56a3a1fb4 --- /dev/null +++ b/src/org/apache/fop/fo/expr/BodyStartFunction.java @@ -0,0 +1,79 @@ +/*-- $Id$ -- + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "FOP" and "Apache Software Foundation" must not be used to + endorse or promote products derived from this software without prior + written permission. For written permission, please contact + apache@apache.org. + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + James Tauber <jtauber@jtauber.com>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + + */ +package org.apache.fop.fo.expr; + +import org.apache.fop.fo.Property; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.flow.ListItem; + +public class BodyStartFunction extends FunctionBase { + + public int nbArgs() { return 0; } + + public Property eval(Property[] args, PropertyInfo pInfo) + throws PropertyException + { + Numeric distance + = pInfo.getPropertyList().get("provisional-distance-between-starts").getNumeric(); + + FObj item = pInfo.getFO(); + while(item != null && !(item instanceof ListItem)) { + item = item.getParent(); + } + if(item == null) { + throw new PropertyException("body-start() called from outside an fo:list-item"); + } + + Numeric startIndent = item.properties.get("start-indent").getNumeric(); + + return new NumericProperty(distance.add(startIndent)); + } +} diff --git a/src/org/apache/fop/fo/expr/LabelEndFunction.java b/src/org/apache/fop/fo/expr/LabelEndFunction.java new file mode 100644 index 000000000..6ab37cec7 --- /dev/null +++ b/src/org/apache/fop/fo/expr/LabelEndFunction.java @@ -0,0 +1,96 @@ +/*-- $Id$ -- + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "FOP" and "Apache Software Foundation" must not be used to + endorse or promote products derived from this software without prior + written permission. For written permission, please contact + apache@apache.org. + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + James Tauber <jtauber@jtauber.com>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + + */ +package org.apache.fop.fo.expr; + +import org.apache.fop.datatypes.*; +import org.apache.fop.fo.Property; +import org.apache.fop.fo.LengthProperty; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.flow.ListItem; + +public class LabelEndFunction extends FunctionBase { + + public int nbArgs() { return 0; } + + public Property eval(Property[] args, PropertyInfo pInfo) + throws PropertyException { + + Length distance + = pInfo.getPropertyList() + .get("provisional-distance-between-starts").getLength(); + Length separation + = pInfo.getPropertyList() + .getNearestSpecified("provisional-label-separation").getLength(); + + FObj item = pInfo.getFO(); + while(item != null && !(item instanceof ListItem)) { + item = item.getParent(); + } + if(item == null) { + throw new PropertyException("label-end() called from outside an fo:list-item"); + } + Length startIndent = item.properties.get("start-indent").getLength(); + + LinearCombinationLength labelEnd = new LinearCombinationLength(); + + // Should be CONTAINING_REFAREA but that doesn't work + LengthBase base = new LengthBase(item, pInfo.getPropertyList(), + LengthBase.CONTAINING_BOX); + PercentLength refWidth = new PercentLength(1.0, base); + + labelEnd.addTerm(1.0, refWidth); + labelEnd.addTerm(-1.0, distance); + labelEnd.addTerm(-1.0, startIndent); + labelEnd.addTerm(1.0, separation); + + return new LengthProperty(labelEnd); + } +} diff --git a/src/org/apache/fop/fo/expr/Numeric.java b/src/org/apache/fop/fo/expr/Numeric.java index 12bcdbf49..f13ccbc76 100644 --- a/src/org/apache/fop/fo/expr/Numeric.java +++ b/src/org/apache/fop/fo/expr/Numeric.java @@ -54,6 +54,7 @@ package org.apache.fop.fo.expr; import org.apache.fop.fo.Property; import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.PercentLength; +import org.apache.fop.datatypes.LinearCombinationLength; import org.apache.fop.datatypes.MixedLength; import org.apache.fop.datatypes.TableColLength; import org.apache.fop.datatypes.PercentBase; diff --git a/src/org/apache/fop/fo/expr/PropertyParser.java b/src/org/apache/fop/fo/expr/PropertyParser.java index b10cf671c..004a507e7 100644 --- a/src/org/apache/fop/fo/expr/PropertyParser.java +++ b/src/org/apache/fop/fo/expr/PropertyParser.java @@ -85,6 +85,8 @@ public class PropertyParser extends PropertyTokenizer { functionTable.put("from-parent", new FromParentFunction()); functionTable.put("from-nearest-specified-value", new NearestSpecPropFunction()); functionTable.put("proportional-column-width", new PPColWidthFunction()); + functionTable.put("label-end", new LabelEndFunction()); + functionTable.put("body-start", new BodyStartFunction()); // NOTE: used from code generated for corresponding properties functionTable.put("_fop-property-value", new FopPropValFunction()); @@ -94,8 +96,6 @@ public class PropertyParser extends PropertyTokenizer { functionTable.put("system-font", new SystemFontFunction()); - functionTable.put("label-end", new LabelEndFunction()); - functionTable.put("body-start", new BodyStartFunction()); functionTable.put("merge-property-values", new MergePropsFunction()); ***/ } diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index ea66f10fa..e88e1f844 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -256,14 +256,6 @@ public class Block extends FObjMixed { if (area instanceof BlockArea) { area.end(); } - if (this.isInLabel) { - startIndent += bodyIndent; - endIndent += (area.getAllocationWidth() - - distanceBetweenStarts - startIndent) + - labelSeparation; - } else if (this.isInListBody) { - startIndent += bodyIndent + distanceBetweenStarts; - } if(area.getIDReferences() != null) area.getIDReferences().createID(id); @@ -358,11 +350,6 @@ public class Block extends FObjMixed { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { FONode fo = (FONode) children.elementAt(i); - if (this.isInListBody) { - fo.setIsInListBody(); - fo.setDistanceBetweenStarts(this.distanceBetweenStarts); - fo.setBodyIndent(this.bodyIndent); - } Status status; if ((status = fo.layout(blockArea)).isIncomplete()) { this.marker = i; diff --git a/src/org/apache/fop/fo/flow/ExternalGraphic.java b/src/org/apache/fop/fo/flow/ExternalGraphic.java index 5636fa70a..c67f4f189 100644 --- a/src/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/org/apache/fop/fo/flow/ExternalGraphic.java @@ -125,17 +125,6 @@ public class ExternalGraphic extends FObj { area.end(); } - if (this.isInLabel) { - startIndent += bodyIndent; - endIndent += (area.getAllocationWidth() - - distanceBetweenStarts - startIndent) + - labelSeparation; - } - - if (this.isInListBody) { - startIndent += bodyIndent + distanceBetweenStarts; - } - if (this.isInTableCell) { startIndent += forcedStartOffset; endIndent = area.getAllocationWidth() - forcedWidth - diff --git a/src/org/apache/fop/fo/flow/InlineGraphic.java b/src/org/apache/fop/fo/flow/InlineGraphic.java index ee585998c..5ed0edfe9 100644 --- a/src/org/apache/fop/fo/flow/InlineGraphic.java +++ b/src/org/apache/fop/fo/flow/InlineGraphic.java @@ -146,17 +146,6 @@ public class InlineGraphic extends FObj { area.end(); } - if (this.isInLabel) { - startIndent += bodyIndent; - endIndent += (area.getAllocationWidth() - - distanceBetweenStarts - startIndent) - + labelSeparation; - } - - if (this.isInListBody) { - startIndent += bodyIndent + distanceBetweenStarts; - } - if (this.isInTableCell) { startIndent += forcedStartOffset; endIndent = area.getAllocationWidth() - forcedWidth - diff --git a/src/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/org/apache/fop/fo/flow/InstreamForeignObject.java index 15c23853d..c7c109971 100644 --- a/src/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -250,17 +250,6 @@ public class InstreamForeignObject extends FObj { area.increaseHeight(areaCurrent.getEffectiveHeight()); } - if (this.isInLabel) { - startIndent += bodyIndent; -/* endIndent += (areaCurrent.getEffectiveWidth() - - distanceBetweenStarts - startIndent) - + labelSeparation;*/ - } - - if (this.isInListBody) { - startIndent += bodyIndent + distanceBetweenStarts; - } - if (this.isInTableCell) { startIndent += forcedStartOffset; /* endIndent = areaCurrent.getEffectiveWidth() - forcedWidth - diff --git a/src/org/apache/fop/fo/flow/ListBlock.java b/src/org/apache/fop/fo/flow/ListBlock.java index 962e9103e..b5ce9f2ad 100644 --- a/src/org/apache/fop/fo/flow/ListBlock.java +++ b/src/org/apache/fop/fo/flow/ListBlock.java @@ -87,8 +87,6 @@ public class ListBlock extends FObj { int endIndent; int spaceBefore; int spaceAfter; - int provisionalDistanceBetweenStarts; - int provisionalLabelSeparation; int spaceBetweenListRows = 0; ColorType backgroundColor; @@ -128,11 +126,6 @@ public class ListBlock extends FObj { "space-before.optimum").getLength().mvalue(); this.spaceAfter = this.properties.get( "space-after.optimum").getLength().mvalue(); - this.provisionalDistanceBetweenStarts = this.properties.get( - "provisional-distance-between-starts").getLength(). - mvalue(); - this.provisionalLabelSeparation = this.properties.get( - "provisional-label-separation").getLength().mvalue(); this.spaceBetweenListRows = 0; // not used at present this.backgroundColor = this.properties.get( "background-color").getColorType(); @@ -147,11 +140,6 @@ public class ListBlock extends FObj { area.addDisplaySpace(spaceBefore); } - if (this.isInListBody) { - startIndent += bodyIndent + distanceBetweenStarts; - bodyIndent = startIndent; - } - if (this.isInTableCell) { startIndent += forcedStartOffset; endIndent += area.getAllocationWidth() - forcedWidth - @@ -176,14 +164,10 @@ public class ListBlock extends FObj { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { if (!(children.elementAt(i) instanceof ListItem)) { - MessageHandler.errorln("WARNING: This version of FOP requires list-items inside list-blocks"); + MessageHandler.errorln("children of list-blocks must be list-items"); return new Status(Status.OK); } ListItem listItem = (ListItem) children.elementAt(i); - listItem.setDistanceBetweenStarts( - this.provisionalDistanceBetweenStarts); - listItem.setLabelSeparation(this.provisionalLabelSeparation); - listItem.setBodyIndent(this.bodyIndent); Status status; if ((status = listItem.layout(blockArea)).isIncomplete()) { if(status.getCode() == Status.AREA_FULL_NONE && i > 0) { @@ -214,9 +198,4 @@ public class ListBlock extends FObj { return new Status(Status.OK); } - public void setBodyIndent(int indent) { - if (! this.isInListBody) { - super.setBodyIndent(indent); - } - } } diff --git a/src/org/apache/fop/fo/flow/ListItem.java b/src/org/apache/fop/fo/flow/ListItem.java index b5a889642..4d80641df 100644 --- a/src/org/apache/fop/fo/flow/ListItem.java +++ b/src/org/apache/fop/fo/flow/ListItem.java @@ -1,35 +1,35 @@ /*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + Copyright (C) 1999 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must - include the following acknowledgment: "This product includes software - developed by the Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, if - and wherever such third-party acknowledgments normally appear. + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. 4. The names "FOP" and "Apache Software Foundation" must not be used to - endorse or promote products derived from this software without prior - written permission. For written permission, please contact - apache@apache.org. + endorse or promote products derived from this software without prior + written permission. For written permission, please contact + apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may - "Apache" appear in their name, without prior written permission of the - Apache Software Foundation. + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND @@ -64,149 +64,144 @@ import java.util.Enumeration; public class ListItem extends FObj { - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, PropertyList propertyList) - throws FOPException { - return new ListItem(parent, propertyList); - } - } - - public static FObj.Maker maker() { - return new ListItem.Maker(); - } - - FontState fs; - int align; - int alignLast; - int breakBefore; - int breakAfter; - int lineHeight; - int startIndent; - int endIndent; - int spaceBefore; - int spaceAfter; - String id; - - public ListItem(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:list-item"; - } - - public Status layout(Area area) throws FOPException { - if (this.marker == START) { - String fontFamily = - this.properties.get("font-family").getString(); - String fontStyle = - this.properties.get("font-style").getString(); - String fontWeight = - this.properties.get("font-weight").getString(); - int fontSize = - this.properties.get("font-size").getLength().mvalue(); - // font-variant support - // added by Eric SCHAEFFER - int fontVariant = - this.properties.get("font-variant").getEnum(); - - this.fs = new FontState(area.getFontInfo(), fontFamily, - fontStyle, fontWeight, fontSize, fontVariant); - - this.align = this.properties.get("text-align").getEnum(); - this.alignLast = - this.properties.get("text-align-last").getEnum(); - this.lineHeight = - this.properties.get("line-height").getLength().mvalue(); - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = - this.properties.get("end-indent").getLength().mvalue(); - this.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - this.id = - this.properties.get("id").getString(); - - 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); - } - - startIndent += this.bodyIndent; - - BlockArea blockArea = - new BlockArea(fs, area.getAllocationWidth(), - area.spaceLeft(), startIndent, endIndent, - 0, align, alignLast, lineHeight); - 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.elementAt(0); - ListItemBody body = (ListItemBody) children.elementAt(1); - - label.setDistanceBetweenStarts(this.distanceBetweenStarts); - label.setLabelSeparation(this.labelSeparation); - label.setBodyIndent(this.bodyIndent); - - body.setDistanceBetweenStarts(this.distanceBetweenStarts); - body.setBodyIndent(this.bodyIndent); - - /* this doesn't actually do anything */ - body.setLabelSeparation(this.labelSeparation); - - 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(); - } - return new Status(Status.OK); - } + public static class Maker extends FObj.Maker { + public FObj make(FObj parent, PropertyList propertyList) + throws FOPException { + return new ListItem(parent, propertyList); + } + } + + public static FObj.Maker maker() { + return new ListItem.Maker(); + } + + FontState fs; + int align; + int alignLast; + int breakBefore; + int breakAfter; + int lineHeight; + int startIndent; + int endIndent; + int spaceBefore; + int spaceAfter; + String id; + BlockArea blockArea; + + public ListItem(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "fo:list-item"; + } + + public Status layout(Area area) throws FOPException { + if (this.marker == START) { + String fontFamily = + this.properties.get("font-family").getString(); + String fontStyle = + this.properties.get("font-style").getString(); + String fontWeight = + this.properties.get("font-weight").getString(); + int fontSize = + this.properties.get("font-size").getLength().mvalue(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + this.align = this.properties.get("text-align").getEnum(); + this.alignLast = + this.properties.get("text-align-last").getEnum(); + this.lineHeight = + this.properties.get("line-height").getLength().mvalue(); + this.spaceBefore = + this.properties.get("space-before.optimum").getLength().mvalue(); + this.spaceAfter = + this.properties.get("space-after.optimum").getLength().mvalue(); + this.id = + this.properties.get("id").getString(); + + 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(fs, area.getAllocationWidth(), + area.spaceLeft(), 0, 0, + 0, align, alignLast, lineHeight); + 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.elementAt(0); + ListItemBody body = (ListItemBody) children.elementAt(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(); + } + 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 + } + } diff --git a/src/org/apache/fop/fo/flow/ListItemBody.java b/src/org/apache/fop/fo/flow/ListItemBody.java index b98b33db4..fd7b1dfd2 100644 --- a/src/org/apache/fop/fo/flow/ListItemBody.java +++ b/src/org/apache/fop/fo/flow/ListItemBody.java @@ -90,10 +90,7 @@ public class ListItemBody extends FObj { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { FObj fo = (FObj) children.elementAt(i); - fo.setIsInListBody(); - fo.setDistanceBetweenStarts(this.distanceBetweenStarts); - fo.setLabelSeparation(this.labelSeparation); - fo.setBodyIndent(this.bodyIndent); + Status status; if ((status = fo.layout(area)).isIncomplete()) { this.marker = i; diff --git a/src/org/apache/fop/fo/flow/ListItemLabel.java b/src/org/apache/fop/fo/flow/ListItemLabel.java index b06eb7d73..4e481cca3 100644 --- a/src/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/org/apache/fop/fo/flow/ListItemLabel.java @@ -92,11 +92,6 @@ public class ListItemLabel extends FObj { Block block = (Block) children.elementAt(0); - block.setIsInLabel(); - block.setDistanceBetweenStarts(this.distanceBetweenStarts); - block.setLabelSeparation(this.labelSeparation); - block.setBodyIndent(this.bodyIndent); - Status status; status = block.layout(area); area.addDisplaySpace(-block.getAreaHeight()); |