From: Finn Bock Date: Mon, 2 Feb 2004 16:08:27 +0000 (+0000) Subject: Phase 3 (last) of bug 26434. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~872 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=561211705ed00206139bddead7daf4049c87be78;p=xmlgraphics-fop.git Phase 3 (last) of bug 26434. - Move the property classes to fop.fo.properties. PR: 26434 git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197314 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/datatypes/AutoLength.java b/src/java/org/apache/fop/datatypes/AutoLength.java deleted file mode 100644 index cafe3a3d7..000000000 --- a/src/java/org/apache/fop/datatypes/AutoLength.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * $Id: AutoLength.java,v 1.3 2003/03/05 20:38:23 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.datatypes; - -import org.apache.fop.fo.LengthProperty; - -/** - * A length quantity in XSL which is specified as "auto". - */ -public class AutoLength extends LengthProperty { - - /** - * @see org.apache.fop.datatypes.Length#isAuto() - */ - public boolean isAuto() { - return true; - } - - // Should we do something intelligent here to set the actual size? - // Would need a reference object! - // protected void computeValue() { - // } - - /** - * @see org.apache.fop.fo.Property#getString() - */ - public String getString() { - return "auto"; - } - -} diff --git a/src/java/org/apache/fop/datatypes/CompoundDatatype.java b/src/java/org/apache/fop/datatypes/CompoundDatatype.java index 14e32b711..77473cef0 100644 --- a/src/java/org/apache/fop/datatypes/CompoundDatatype.java +++ b/src/java/org/apache/fop/datatypes/CompoundDatatype.java @@ -50,8 +50,8 @@ */ package org.apache.fop.datatypes; -import org.apache.fop.fo.Property; import org.apache.fop.fo.Constants; +import org.apache.fop.fo.properties.Property; /** * This interface is used as a base for compound datatypes. diff --git a/src/java/org/apache/fop/datatypes/FixedLength.java b/src/java/org/apache/fop/datatypes/FixedLength.java deleted file mode 100644 index 7572c1cf6..000000000 --- a/src/java/org/apache/fop/datatypes/FixedLength.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * $Id: FixedLength.java,v 1.4 2003/03/05 20:38:23 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.datatypes; - -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.expr.NumericProperty; - -/** - * a length quantity in XSL - */ -public class FixedLength extends LengthProperty { - - /** - * Set the length given - * @param numRelUnits the number of relative units - * @param iCurFontSize the current font size in base units. - */ - public FixedLength(double numRelUnits, int iCurFontSize) { - setComputedValue((int)(numRelUnits * (double)iCurFontSize)); - } - - /** - * Set the length given a number of units and a unit name. - * @param numUnits quantity of input units - * @param units input unit specifier (in, cm, etc.) - */ - public FixedLength(double numUnits, String units) { - convert(numUnits, units); - } - - /** - * @param baseUnits the length as a number of base units (millipoints) - */ - public FixedLength(int baseUnits) { - setComputedValue(baseUnits); - } - - /** - * Convert the given length to a dimensionless integer representing - * a whole number of base units (milli-points). - * @param dvalue quantity of input units - * @param unit input unit specifier (in, cm, etc.) - */ - protected void convert(double dvalue, String unit) { - - int assumedResolution = 1; // points/pixel - - if (unit.equals("in")) { - dvalue = dvalue * 72; - } else if (unit.equals("cm")) { - dvalue = dvalue * 28.3464567; - } else if (unit.equals("mm")) { - dvalue = dvalue * 2.83464567; - } else if (unit.equals("pt")) { - // Do nothing. - // dvalue = dvalue; - } else if (unit.equals("pc")) { - dvalue = dvalue * 12; - /* - * } else if (unit.equals("em")) { - * dvalue = dvalue * fontsize; - */ - } else if (unit.equals("px")) { - dvalue = dvalue * assumedResolution; - } else { - dvalue = 0; - //log.error("unknown length unit '" + unit - // + "'"); - } - setComputedValue((int)(dvalue * 1000)); - } - - /** - * @return Numeric equivalent of this - */ - public NumericProperty asNumeric() { - return new NumericProperty(this); - } -} - diff --git a/src/java/org/apache/fop/datatypes/LinearCombinationLength.java b/src/java/org/apache/fop/datatypes/LinearCombinationLength.java deleted file mode 100644 index a853417dd..000000000 --- a/src/java/org/apache/fop/datatypes/LinearCombinationLength.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * $Id: LinearCombinationLength.java,v 1.4 2003/03/05 20:38:24 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.datatypes; - -import java.util.Vector; - -import org.apache.fop.fo.LengthProperty; - -/** - * Class modelling lengths that are build up by combining other lengths - */ -public class LinearCombinationLength extends LengthProperty { - - /** Collection of factors (1-1 correspondence with {@link #lengths} */ - protected Vector factors; - /** Collection of Length objects (1-1 correspondence with {@link #factors} */ - protected Vector lengths; - - /** - * Constructor. Creates no content. Use {link #addTerm} to build content. - */ - public LinearCombinationLength() { - factors = new Vector(); - lengths = new Vector(); - } - - /** - * Add an item to this - * @param factor the factor to be added - * @param length the Length to be added - */ - public void addTerm(double factor, LengthProperty length) { - factors.addElement(new Double(factor)); - lengths.addElement(length); - } - - /** - * Sets the computed value in millipoints. - */ - protected void 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)).getValue()); - } - setComputedValue(result); - } - -} diff --git a/src/java/org/apache/fop/datatypes/MixedLength.java b/src/java/org/apache/fop/datatypes/MixedLength.java deleted file mode 100644 index bc7dd1536..000000000 --- a/src/java/org/apache/fop/datatypes/MixedLength.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * $Id: MixedLength.java,v 1.6 2003/03/05 20:38:23 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.datatypes; - -import java.util.Enumeration; -import java.util.Vector; - -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.expr.NumericProperty; -import org.apache.fop.fo.expr.PropertyException; - -/** - * A length quantity in XSL which is specified with a mixture - * of absolute and relative and/or percent components. - * The actual value may not be computable before layout is done. - */ -public class MixedLength extends LengthProperty { - - /** The collection of Length objects comprising this MixedLength object */ - private Vector lengths ; - - /** - * Constructor - * @param lengths the collection of Length objects which comprise the new - * MixedLength object - */ - public MixedLength(Vector lengths) { - this.lengths = lengths; - } - - /** - * Iterates through each internal component, computing and - * summarizing the values, then setting the value for this - */ - protected void computeValue() { - int computedValue = 0; - boolean bAllComputed = true; - Enumeration e = lengths.elements(); - while (e.hasMoreElements()) { - LengthProperty l = (LengthProperty) e.nextElement(); - computedValue += l.getValue(); - if (!l.isComputed()) { - bAllComputed = false; - } - } - setComputedValue(computedValue, bAllComputed); - } - - - public double getTableUnits() { - double tableUnits = 0.0; - Enumeration e = lengths.elements(); - while (e.hasMoreElements()) { - tableUnits += ((LengthProperty) e.nextElement()).getTableUnits(); - } - return tableUnits; - } - - public void resolveTableUnit(double dTableUnit) { - Enumeration e = lengths.elements(); - while (e.hasMoreElements()) { - ((LengthProperty) e.nextElement()).resolveTableUnit(dTableUnit); - } - } - - /** - * @return String equivalent of this - */ - public String toString() { - StringBuffer sbuf = new StringBuffer(); - Enumeration e = lengths.elements(); - while (e.hasMoreElements()) { - if (sbuf.length() > 0) { - sbuf.append('+'); - } - sbuf.append(e.nextElement().toString()); - } - return sbuf.toString(); - } - - /** - * @return Numeric equivalent of this - */ - public NumericProperty asNumeric() { - NumericProperty numeric = null; - for (Enumeration e = lengths.elements(); e.hasMoreElements();) { - LengthProperty l = (LengthProperty) e.nextElement(); - if (numeric == null) { - numeric = l.asNumeric(); - } else { - try { - NumericProperty sum = numeric.add(l.asNumeric()); - numeric = sum; - } catch (PropertyException pe) { - System.err.println( - "Can't convert MixedLength to Numeric: " + pe); - } - } - } - return numeric; - } -} - diff --git a/src/java/org/apache/fop/datatypes/PercentLength.java b/src/java/org/apache/fop/datatypes/PercentLength.java deleted file mode 100644 index 9d96e7989..000000000 --- a/src/java/org/apache/fop/datatypes/PercentLength.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * $Id: PercentLength.java,v 1.6 2003/03/05 20:38:23 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.datatypes; - -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.expr.NumericProperty; - -/** - * a percent specified length quantity in XSL - */ -public class PercentLength extends LengthProperty { - - /** - * The percentage itself, expressed as a decimal value, e.g. for 95%, set - * the value to .95 - */ - private double factor; - - /** - * A PercentBase implementation that contains the base length to which the - * {@link #factor} should be applied to compute the actual length - */ - private PercentBase lbase = null; - - /** - * Main constructor. Construct an object based on a factor (the percent, - * as a factor) and an object which has a method to return the Length which - * provides the "base" for the actual length that is modeled. - * @param factor the percentage factor, expressed as a decimal (e.g. use - * .95 to represent 95%) - * @param lbase base property to which the factor should be applied - */ - public PercentLength(double factor, PercentBase lbase) { - this.factor = factor; - this.lbase = lbase; - } - - /** - * Convenience constructor when only the factor is known - * @param factor the percentage factor, expressed as a decimal (e.g. use - * .95 to represent 95%) - */ - public PercentLength(double factor) { - this(factor, null); - } - - /** - * @param lbase the base to set - */ - public void setBaseLength(PercentBase lbase) { - this.lbase = lbase; - } - - /** - * @return the base - */ - public PercentBase getBaseLength() { - return this.lbase; - } - - /** - * Return the computed value in millipoints. This assumes that the - * base length has been resolved to an absolute length value. - */ - protected void computeValue() { - setComputedValue((int)(factor * (double)lbase.getBaseLength())); - } - - /** - * - * @return the factor - */ - public double value() { - return factor; - } - - /** - * @return the String equivalent of this - */ - public String toString() { - // TODO: What about the base value? - return (new Double(factor * 100.0).toString()) + "%"; - } - - /** - * @return new Numeric object that is equivalent to this - */ - public NumericProperty asNumeric() { - return new NumericProperty(this); - } - -} diff --git a/src/java/org/apache/fop/datatypes/TableColLength.java b/src/java/org/apache/fop/datatypes/TableColLength.java deleted file mode 100644 index 28b9ec436..000000000 --- a/src/java/org/apache/fop/datatypes/TableColLength.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * $Id: TableColLength.java,v 1.6 2003/03/05 20:38:24 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.datatypes; - -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.expr.NumericProperty; - -/** - * A table-column width specification, possibly including some - * number of proportional "column-units". The absolute size of a - * column-unit depends on the fixed and proportional sizes of all - * columns in the table, and on the overall size of the table. - * It can't be calculated until all columns have been specified and until - * the actual width of the table is known. Since this can be specified - * as a percent of its parent containing width, the calculation is done - * during layout. - * NOTE: this is only supposed to be allowed if table-layout=fixed. - */ -public class TableColLength extends LengthProperty { - - /** - * Number of table-column proportional units - */ - private double tcolUnits; - - /** - * Construct an object with tcolUnits of proportional measure. - * @param tcolUnits number of table-column proportional units - */ - public TableColLength(double tcolUnits) { - this.tcolUnits = tcolUnits; - } - - /** - * Override the method in Length - * @return the number of specified proportional table-column units. - */ - public double getTableUnits() { - return tcolUnits; - } - - /** - * Calculate the number of millipoints and set it. - * @param mpointsPerUnit density of millipoints per unit - */ - public void resolveTableUnit(double mpointsPerUnit) { - setComputedValue((int)(tcolUnits * mpointsPerUnit)); - } - - //If the table-unit can be resolved, set the computed value - /*protected void computeValue() { - if (tblUnitBase.canResolveUnit()) { - rslt += (int)(tcolUnits * (double)tblUnitBase.getUnitValue()); - setComputedValue(rslt); - } - }*/ - - /** - * Convert this to a String - * @return the string representation of this - */ - public String toString() { - return (Double.toString(tcolUnits) + " table-column-units"); - } - - /** - * Converts this to a new Numeric object - * @return the Numeric object - */ - public NumericProperty asNumeric() { - return new NumericProperty(this); - } -} - diff --git a/src/java/org/apache/fop/datatypes/ToBeImplementedProperty.java b/src/java/org/apache/fop/datatypes/ToBeImplementedProperty.java deleted file mode 100644 index 8cafe9cf6..000000000 --- a/src/java/org/apache/fop/datatypes/ToBeImplementedProperty.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * $Id: ToBeImplementedProperty.java,v 1.6 2003/03/05 20:38:23 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.datatypes; - -import org.apache.fop.fo.FObj; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.properties.PropertyMaker; - -public class ToBeImplementedProperty extends Property { - - public static class Maker extends PropertyMaker { - - public Maker(int propId) { - super(propId); - } - - public Property convertProperty(Property p, - PropertyList propertyList, FObj fo) { - if (p instanceof ToBeImplementedProperty) { - return p; - } - - ToBeImplementedProperty val = - new ToBeImplementedProperty(getPropId()); - return val; - } - } - - /** - * Constructor - * @param propName name of Property - */ - public ToBeImplementedProperty(int propId) { - - //XXX: (mjg@recalldesign.com) This is a bit of a kluge, perhaps an - //UnimplementedPropertyException or something similar should - //get thrown here instead. - -// Logger log = Hierarchy.getDefaultHierarchy().getLoggerFor("fop"); -// log.warn("property - \"" + propName -// + "\" is not implemented yet."); - } -} - diff --git a/src/java/org/apache/fop/fo/BoxPropShorthandParser.java b/src/java/org/apache/fop/fo/BoxPropShorthandParser.java index 4a35cba64..51c8f0610 100644 --- a/src/java/org/apache/fop/fo/BoxPropShorthandParser.java +++ b/src/java/org/apache/fop/fo/BoxPropShorthandParser.java @@ -50,6 +50,8 @@ */ package org.apache.fop.fo; +import org.apache.fop.fo.properties.ListProperty; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.PropertyMaker; /** diff --git a/src/java/org/apache/fop/fo/CharacterProperty.java b/src/java/org/apache/fop/fo/CharacterProperty.java deleted file mode 100644 index 4a95c8ad0..000000000 --- a/src/java/org/apache/fop/fo/CharacterProperty.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * $Id: CharacterProperty.java,v 1.3 2003/03/05 21:48:02 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import org.apache.fop.fo.properties.PropertyMaker; - -/** - * Superclass for properties that wrap a character value - */ -public class CharacterProperty extends Property { - - /** - * Inner class for creating instances of CharacterProperty - */ - public static class Maker extends PropertyMaker { - - /** - * @param propName name of property for which a Maker should be created - */ - public Maker(int propId) { - super(propId); - } - - public Property make(PropertyList propertyList, String value, - FObj fo) { - char c = value.charAt(0); - return new CharacterProperty(c); - } - - } // end Charakter.Maker - - private char character; - - /** - * @param character character value to be wrapped in this property - */ - public CharacterProperty(char character) { - this.character = character; - } - - /** - * @return this.character cast as an Object - */ - public Object getObject() { - return new Character(character); - } - - /** - * @return this.character - */ - public char getCharacter() { - return this.character; - } - - /** - * @return this.character cast as a String - */ - public String getString() { - return new Character(character).toString(); - } - -} diff --git a/src/java/org/apache/fop/fo/ColorTypeProperty.java b/src/java/org/apache/fop/fo/ColorTypeProperty.java deleted file mode 100644 index 125e1dbc4..000000000 --- a/src/java/org/apache/fop/fo/ColorTypeProperty.java +++ /dev/null @@ -1,809 +0,0 @@ -/* - * $Id: ColorTypeProperty.java,v 1.5 2003/03/05 21:48:02 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import java.awt.Color; -import java.util.StringTokenizer; - -import org.apache.fop.datatypes.ColorType; -import org.apache.fop.fo.properties.PropertyMaker; - -/** - * Superclass for properties that wrap ColorType values - */ -public class ColorTypeProperty extends Property implements ColorType { - /** - * the red component - */ - protected float red = 0f; - - /** - * the green component - */ - protected float green = 0f; - - /** - * the blue component - */ - protected float blue = 0f; - - /** - * the alpha component (indicator of opaque-ness) - * 0.0 - 1.0; 0.0 is completely transparent; 1.0 is completely opaque - * see definition at http://java.sun.com/j2se/1.3/docs/api/java/awt/Color.html - */ - protected float alpha = 1f; - - /** - * Inner class for creating instances of ColorTypeProperty - */ - public static class Maker extends PropertyMaker { - - /** - * @param propName name of property for which a Maker should be created - */ - public Maker(int propId) { - super(propId); - } - - public Property convertProperty(Property p, - PropertyList propertyList, FObj fo) { - if (p instanceof ColorTypeProperty) { - return p; - } - ColorTypeProperty val = p.getColorType(); - if (val != null) { - return val; - } - return convertPropertyDatatype(p, propertyList, fo); - } - - } - - /** - * Main constructor - * @param red red component - * @param green green component - * @param blue blue component - */ - public ColorTypeProperty(float red, float green, float blue) { - this.red = red; - this.green = green; - this.blue = blue; - } - - /** - * Set the colour given a particular String specifying either a - * colour name or #RGB or #RRGGBB - * @param value RGB value as String to be parsed - */ - public ColorTypeProperty(String value) { - if (value.startsWith("#")) { - try { - if (value.length() == 4) { - // note: divide by 15 so F = FF = 1 and so on - this.red = Integer.parseInt(value.substring(1, 2), 16) - / 15f; - this.green = Integer.parseInt(value.substring(2, 3), 16) - / 15f; - this.blue = Integer.parseInt(value.substring(3), 16) - / 15f; - } else if (value.length() == 7) { - // note: divide by 255 so FF = 1 - this.red = Integer.parseInt(value.substring(1, 3), 16) - / 255f; - this.green = Integer.parseInt(value.substring(3, 5), 16) - / 255f; - this.blue = Integer.parseInt(value.substring(5), 16) - / 255f; - } else { - this.red = 0; - this.green = 0; - this.blue = 0; - //log.error("unknown colour format. Must be #RGB or #RRGGBB"); - } - } catch (Exception e) { - this.red = 0; - this.green = 0; - this.blue = 0; - //log.error("unknown colour format. Must be #RGB or #RRGGBB"); - } - } else if (value.startsWith("rgb(")) { - int poss = value.indexOf("("); - int pose = value.indexOf(")"); - if (poss != -1 && pose != -1) { - value = value.substring(poss + 1, pose); - StringTokenizer st = new StringTokenizer(value, ","); - try { - if (st.hasMoreTokens()) { - String str = st.nextToken().trim(); - if (str.endsWith("%")) { - this.red = - Integer.parseInt(str.substring(0, str.length() - 1)) - * 2.55f; - } else { - this.red = Integer.parseInt(str) / 255f; - } - } - if (st.hasMoreTokens()) { - String str = st.nextToken().trim(); - if (str.endsWith("%")) { - this.green = - Integer.parseInt(str.substring(0, str.length() - 1)) - * 2.55f; - } else { - this.green = Integer.parseInt(str) / 255f; - } - } - if (st.hasMoreTokens()) { - String str = st.nextToken().trim(); - if (str.endsWith("%")) { - this.blue = - Integer.parseInt(str.substring(0, str.length() - 1)) - * 2.55f; - } else { - this.blue = Integer.parseInt(str) / 255f; - } - } - } catch (Exception e) { - this.red = 0; - this.green = 0; - this.blue = 0; - //log.error("unknown colour format. Must be #RGB or #RRGGBB"); - } - } - } else if (value.startsWith("url(")) { - // refers to a gradient - } else { - if (value.toLowerCase().equals("transparent")) { - this.red = 0; - this.green = 0; - this.blue = 0; - this.alpha = 0; - } else { - boolean found = false; - for (int count = 0; count < NAMES.length; count++) { - if (value.toLowerCase().equals(NAMES[count])) { - this.red = VALUES[count][0] / 255f; - this.green = VALUES[count][1] / 255f; - this.blue = VALUES[count][2] / 255f; - found = true; - break; - } - } - if (!found) { - this.red = 0; - this.green = 0; - this.blue = 0; - //log.error("unknown colour name: " - // + value); - } - } - } - } - - /** - * Returns the blue component of the color. - * @return float a value between 0.0 and 1.0 - */ - public float getBlue() { - return this.blue; - } - - /** - * Returns the green component of the color. - * @return float a value between 0.0 and 1.0 - */ - public float getGreen() { - return this.green; - } - - /** - * Returns the red component of the color. - * @return float a value between 0.0 and 1.0 - */ - public float getRed() { - return this.red; - } - - /** - * Returns the alpha (degree of opaque-ness) component of the color. - * @return float a value between 0.0 (fully transparent) and 1.0 (fully opaque) - */ - public float getAlpha() { - return this.alpha; - } - - /** - * Returns an AWT instance of this color - * @return float the AWT color represented by this ColorType instance - */ - public Color getAWTColor() { - return new Color(this.red, this.green, this.blue, this.alpha); - } - - /** - * @param floatValue value (between 0.0 and 1.0) of color channel - * @return integer equivalent (between 0 and 255) - */ - public static int convertChannelToInteger (float floatValue) { - if (floatValue > 1.0) { - floatValue = 1.0f; - } - if (floatValue < 0) { - floatValue = 0; - } - return (int) (floatValue * 255); - } - - /** - * @see java.lang.Object#toString() - */ - public String toString() { - StringBuffer sbuf = new StringBuffer(8); - sbuf.append('#'); - String s = Integer.toHexString((int)(red * 255.0)); - if (s.length() == 1) { - sbuf.append('0'); - } - sbuf.append(s); - s = Integer.toHexString((int)(green * 255.0)); - if (s.length() == 1) { - sbuf.append('0'); - } - sbuf.append(s); - s = Integer.toHexString((int)(blue * 255.0)); - if (s.length() == 1) { - sbuf.append('0'); - } - sbuf.append(s); - return sbuf.toString(); - } - - /** The names of the predefined colors */ - protected static final String[] NAMES = { - "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", - "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", - "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", - "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", - "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", - "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", - "darkorchid", "darkred", "darksalmon", "darkseagreen", - "darkslateblue", "darkslategray", "darkslategrey", "darkturquoise", - "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey", - "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", - "gainsboro", "lightpink", "lightsalmon", "lightseagreen", - "lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue", - "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", - "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", - "mediumseagreen", "mediumslateblue", "mediumspringgreen", - "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", - "mistyrose", "moccasin", "navajowhite", "navy", "oldlace", "olive", - "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", - "palegreen", "paleturquoise", "palevioletred", "papayawhip", - "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "red", - "rosybrown", "royalblue", "saddlebrown", "salmon", "ghostwhite", - "gold", "goldenrod", "gray", "grey", "green", "greenyellow", - "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", - "lavender", "lavenderblush", "lawngreen", "lemonchiffon", - "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow", - "lightgray", "lightgreen", "lightgrey", "sandybrown", "seagreen", - "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", - "slategrey", "snow", "springgreen", "steelblue", "tan", "teal", - "thistle", "tomato", "turquoise", "violet", "wheat", "white", - "whitesmoke", "yellow", "yellowgreen" - }; - - /** The color values for the predefined colors */ - protected static final int[][] VALUES = { - { - 240, 248, 255 - }, { - 250, 235, 215 - }, { - 0, 255, 255 - }, { - 127, 255, 212 - }, { - 240, 255, 255 - }, { - 245, 245, 220 - }, { - 255, 228, 196 - }, { - 0, 0, 0 - }, { - 255, 235, 205 - }, { - 0, 0, 255 - }, { - 138, 43, 226 - }, { - 165, 42, 42 - }, { - 222, 184, 135 - }, { - 95, 158, 160 - }, { - 127, 255, 0 - }, { - 210, 105, 30 - }, { - 255, 127, 80 - }, { - 100, 149, 237 - }, { - 255, 248, 220 - }, { - 220, 20, 60 - }, { - 0, 255, 255 - }, { - 0, 0, 139 - }, { - 0, 139, 139 - }, { - 184, 134, 11 - }, { - 169, 169, 169 - }, { - 0, 100, 0 - }, { - 169, 169, 169 - }, { - 189, 183, 107 - }, { - 139, 0, 139 - }, { - 85, 107, 47 - }, { - 255, 140, 0 - }, { - 153, 50, 204 - }, { - 139, 0, 0 - }, { - 233, 150, 122 - }, { - 143, 188, 143 - }, { - 72, 61, 139 - }, { - 47, 79, 79 - }, { - 47, 79, 79 - }, { - 0, 206, 209 - }, { - 148, 0, 211 - }, { - 255, 20, 147 - }, { - 0, 191, 255 - }, { - 105, 105, 105 - }, { - 105, 105, 105 - }, { - 30, 144, 255 - }, { - 178, 34, 34 - }, { - 255, 250, 240 - }, { - 34, 139, 34 - }, { - 255, 0, 255 - }, { - 220, 220, 220 - }, { - 255, 182, 193 - }, { - 255, 160, 122 - }, { - 32, 178, 170 - }, { - 135, 206, 250 - }, { - 119, 136, 153 - }, { - 119, 136, 153 - }, { - 176, 196, 222 - }, { - 255, 255, 224 - }, { - 0, 255, 0 - }, { - 50, 205, 50 - }, { - 250, 240, 230 - }, { - 255, 0, 255 - }, { - 128, 0, 0 - }, { - 102, 205, 170 - }, { - 0, 0, 205 - }, { - 186, 85, 211 - }, { - 147, 112, 219 - }, { - 60, 179, 113 - }, { - 123, 104, 238 - }, { - 0, 250, 154 - }, { - 72, 209, 204 - }, { - 199, 21, 133 - }, { - 25, 25, 112 - }, { - 245, 255, 250 - }, { - 255, 228, 225 - }, { - 255, 228, 181 - }, { - 255, 222, 173 - }, { - 0, 0, 128 - }, { - 253, 245, 230 - }, { - 128, 128, 0 - }, { - 107, 142, 35 - }, { - 255, 165, 0 - }, { - 255, 69, 0 - }, { - 218, 112, 214 - }, { - 238, 232, 170 - }, { - 152, 251, 152 - }, { - 175, 238, 238 - }, { - 219, 112, 147 - }, { - 255, 239, 213 - }, { - 255, 218, 185 - }, { - 205, 133, 63 - }, { - 255, 192, 203 - }, { - 221, 160, 221 - }, { - 176, 224, 230 - }, { - 128, 0, 128 - }, { - 255, 0, 0 - }, { - 188, 143, 143 - }, { - 65, 105, 225 - }, { - 139, 69, 19 - }, { - 250, 128, 114 - }, { - 248, 248, 255 - }, { - 255, 215, 0 - }, { - 218, 165, 32 - }, { - 128, 128, 128 - }, { - 128, 128, 128 - }, { - 0, 128, 0 - }, { - 173, 255, 47 - }, { - 240, 255, 240 - }, { - 255, 105, 180 - }, { - 205, 92, 92 - }, { - 75, 0, 130 - }, { - 255, 255, 240 - }, { - 240, 230, 140 - }, { - 230, 230, 250 - }, { - 255, 240, 245 - }, { - 124, 252, 0 - }, { - 255, 250, 205 - }, { - 173, 216, 230 - }, { - 240, 128, 128 - }, { - 224, 255, 255 - }, { - 250, 250, 210 - }, { - 211, 211, 211 - }, { - 144, 238, 144 - }, { - 211, 211, 211 - }, { - 244, 164, 96 - }, { - 46, 139, 87 - }, { - 255, 245, 238 - }, { - 160, 82, 45 - }, { - 192, 192, 192 - }, { - 135, 206, 235 - }, { - 106, 90, 205 - }, { - 112, 128, 144 - }, { - 112, 128, 144 - }, { - 255, 250, 250 - }, { - 0, 255, 127 - }, { - 70, 130, 180 - }, { - 210, 180, 140 - }, { - 0, 128, 128 - }, { - 216, 191, 216 - }, { - 255, 99, 71 - }, { - 64, 224, 208 - }, { - 238, 130, 238 - }, { - 245, 222, 179 - }, { - 255, 255, 255 - }, { - 245, 245, 245 - }, { - 255, 255, 0 - }, { - 154, 205, 50 - } - }; - - /* - * aliceblue rgb(240, 248, 255) - * antiquewhite rgb(250, 235, 215) - * aqua rgb( 0, 255, 255) - * aquamarine rgb(127, 255, 212) - * azure rgb(240, 255, 255) - * beige rgb(245, 245, 220) - * bisque rgb(255, 228, 196) - * black rgb( 0, 0, 0) - * blanchedalmond rgb(255, 235, 205) - * blue rgb( 0, 0, 255) - * blueviolet rgb(138, 43, 226) - * brown rgb(165, 42, 42) - * burlywood rgb(222, 184, 135) - * cadetblue rgb( 95, 158, 160) - * chartreuse rgb(127, 255, 0) - * chocolate rgb(210, 105, 30) - * coral rgb(255, 127, 80) - * cornflowerblue rgb(100, 149, 237) - * cornsilk rgb(255, 248, 220) - * crimson rgb(220, 20, 60) - * cyan rgb( 0, 255, 255) - * darkblue rgb( 0, 0, 139) - * darkcyan rgb( 0, 139, 139) - * darkgoldenrod rgb(184, 134, 11) - * darkgray rgb(169, 169, 169) - * darkgreen rgb( 0, 100, 0) - * darkgrey rgb(169, 169, 169) - * darkkhaki rgb(189, 183, 107) - * darkmagenta rgb(139, 0, 139) - * darkolivegreen rgb( 85, 107, 47) - * darkorange rgb(255, 140, 0) - * darkorchid rgb(153, 50, 204) - * darkred rgb(139, 0, 0) - * darksalmon rgb(233, 150, 122) - * darkseagreen rgb(143, 188, 143) - * darkslateblue rgb( 72, 61, 139) - * darkslategray rgb( 47, 79, 79) - * darkslategrey rgb( 47, 79, 79) - * darkturquoise rgb( 0, 206, 209) - * darkviolet rgb(148, 0, 211) - * deeppink rgb(255, 20, 147) - * deepskyblue rgb( 0, 191, 255) - * dimgray rgb(105, 105, 105) - * dimgrey rgb(105, 105, 105) - * dodgerblue rgb( 30, 144, 255) - * firebrick rgb(178, 34, 34) - * floralwhite rgb(255, 250, 240) - * forestgreen rgb( 34, 139, 34) - * fuchsia rgb(255, 0, 255) - * gainsboro rgb(220, 220, 220) - * lightpink rgb(255, 182, 193) - * lightsalmon rgb(255, 160, 122) - * lightseagreen rgb( 32, 178, 170) - * lightskyblue rgb(135, 206, 250) - * lightslategray rgb(119, 136, 153) - * lightslategrey rgb(119, 136, 153) - * lightsteelblue rgb(176, 196, 222) - * lightyellow rgb(255, 255, 224) - * lime rgb( 0, 255, 0) - * limegreen rgb( 50, 205, 50) - * linen rgb(250, 240, 230) - * magenta rgb(255, 0, 255) - * maroon rgb(128, 0, 0) - * mediumaquamarine rgb(102, 205, 170) - * mediumblue rgb( 0, 0, 205) - * mediumorchid rgb(186, 85, 211) - * mediumpurple rgb(147, 112, 219) - * mediumseagreen rgb( 60, 179, 113) - * mediumslateblue rgb(123, 104, 238) - * mediumspringgreen rgb( 0, 250, 154) - * mediumturquoise rgb( 72, 209, 204) - * mediumvioletred rgb(199, 21, 133) - * midnightblue rgb( 25, 25, 112) - * mintcream rgb(245, 255, 250) - * mistyrose rgb(255, 228, 225) - * moccasin rgb(255, 228, 181) - * navajowhite rgb(255, 222, 173) - * navy rgb( 0, 0, 128) - * oldlace rgb(253, 245, 230) - * olive rgb(128, 128, 0) - * olivedrab rgb(107, 142, 35) - * orange rgb(255, 165, 0) - * orangered rgb(255, 69, 0) - * orchid rgb(218, 112, 214) - * palegoldenrod rgb(238, 232, 170) - * palegreen rgb(152, 251, 152) - * paleturquoise rgb(175, 238, 238) - * palevioletred rgb(219, 112, 147) - * papayawhip rgb(255, 239, 213) - * peachpuff rgb(255, 218, 185) - * peru rgb(205, 133, 63) - * pink rgb(255, 192, 203) - * plum rgb(221, 160, 221) - * powderblue rgb(176, 224, 230) - * purple rgb(128, 0, 128) - * red rgb(255, 0, 0) - * rosybrown rgb(188, 143, 143) - * royalblue rgb( 65, 105, 225) - * saddlebrown rgb(139, 69, 19) - * salmon rgb(250, 128, 114) - * ghostwhite rgb(248, 248, 255) - * gold rgb(255, 215, 0) - * goldenrod rgb(218, 165, 32) - * gray rgb(128, 128, 128) - * grey rgb(128, 128, 128) - * green rgb( 0, 128, 0) - * greenyellow rgb(173, 255, 47) - * honeydew rgb(240, 255, 240) - * hotpink rgb(255, 105, 180) - * indianred rgb(205, 92, 92) - * indigo rgb( 75, 0, 130) - * ivory rgb(255, 255, 240) - * khaki rgb(240, 230, 140) - * lavender rgb(230, 230, 250) - * lavenderblush rgb(255, 240, 245) - * lawngreen rgb(124, 252, 0) - * lemonchiffon rgb(255, 250, 205) - * lightblue rgb(173, 216, 230) - * lightcoral rgb(240, 128, 128) - * lightcyan rgb(224, 255, 255) - * lightgoldenrodyellow rgb(250, 250, 210) - * lightgray rgb(211, 211, 211) - * lightgreen rgb(144, 238, 144) - * lightgrey rgb(211, 211, 211) - * sandybrown rgb(244, 164, 96) - * seagreen rgb( 46, 139, 87) - * seashell rgb(255, 245, 238) - * sienna rgb(160, 82, 45) - * silver rgb(192, 192, 192) - * skyblue rgb(135, 206, 235) - * slateblue rgb(106, 90, 205) - * slategray rgb(112, 128, 144) - * slategrey rgb(112, 128, 144) - * snow rgb(255, 250, 250) - * springgreen rgb( 0, 255, 127) - * steelblue rgb( 70, 130, 180) - * tan rgb(210, 180, 140) - * teal rgb( 0, 128, 128) - * thistle rgb(216, 191, 216) - * tomato rgb(255, 99, 71) - * turquoise rgb( 64, 224, 208) - * violet rgb(238, 130, 238) - * wheat rgb(245, 222, 179) - * white rgb(255, 255, 255) - * whitesmoke rgb(245, 245, 245) - * yellow rgb(255, 255, 0) - * yellowgreen rgb(154, 205, 50) - */ - - /** - * Can't convert to any other types - * @return this.colorType - */ - public ColorTypeProperty getColorType() { - return this; - } - - /** - * @return this.colorType cast as an Object - */ - public Object getObject() { - return this; - } -} - diff --git a/src/java/org/apache/fop/fo/CondLengthProperty.java b/src/java/org/apache/fop/fo/CondLengthProperty.java deleted file mode 100644 index aa2260a41..000000000 --- a/src/java/org/apache/fop/fo/CondLengthProperty.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * $Id: CondLengthProperty.java,v 1.5 2003/03/05 21:48:01 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.CompoundDatatype; -import org.apache.fop.fo.properties.CompoundPropertyMaker; - -/** - * Superclass for properties that have conditional lengths - */ -public class CondLengthProperty extends Property implements CompoundDatatype { - private Property length; - private Property conditionality; - - /** - * Inner class for creating instances of CondLengthProperty - */ - public static class Maker extends CompoundPropertyMaker { - - /** - * @param name of property for which a Maker should be created - */ - public Maker(int propId) { - super(propId); - } - - /** - * Create a new empty instance of CondLengthProperty. - * @return the new instance. - */ - public Property makeNewProperty() { - return new CondLengthProperty(); - } - - /** - * @see CompoundPropertyMaker#convertProperty - */ - public Property convertProperty(Property p, PropertyList propertyList, FObj fo) - throws FOPException - { - if (p instanceof KeepProperty) { - return p; - } - return super.convertProperty(p, propertyList, fo); - } - } - - /** - * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean) - */ - public void setComponent(int cmpId, Property cmpnValue, - boolean bIsDefault) { - if (cmpId == CP_LENGTH) { - length = cmpnValue; - } else if (cmpId == CP_CONDITIONALITY) { - conditionality = cmpnValue; - } - } - - /** - * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) - */ - public Property getComponent(int cmpId) { - if (cmpId == CP_LENGTH) { - return length; - } else if (cmpId == CP_CONDITIONALITY) { - return conditionality; - } else { - return null; - } - } - - /** - * Returns the conditionality. - * @return the conditionality - */ - public Property getConditionality() { - return this.conditionality; - } - - /** - * Returns the length. - * @return the length - */ - public Property getLengthComponent() { - return this.length; - } - - /** - * Indicates if the length can be discarded on certain conditions. - * @return true if the length can be discarded. - */ - public boolean isDiscard() { - return this.conditionality.getEnum() == Constants.DISCARD; - } - - /** - * Returns the computed length value. - * @return the length in millipoints - */ - public int getLengthValue() { - return this.length.getLength().getValue(); - } - - public String toString() { - return "CondLength[" + (isDiscard() ? "discard, " : "") + - length.getObject().toString() + "]"; - } - - - /** - * @return this.condLength - */ - public CondLengthProperty getCondLength() { - return this; - } - - /** - * TODO: Should we allow this? - * @return this.condLength cast as a Length - */ - public LengthProperty getLength() { - return length.getLength(); - } - - /** - * @return this.condLength cast as an Object - */ - public Object getObject() { - return this; - } - -} diff --git a/src/java/org/apache/fop/fo/EnumProperty.java b/src/java/org/apache/fop/fo/EnumProperty.java deleted file mode 100644 index 5d09de9c7..000000000 --- a/src/java/org/apache/fop/fo/EnumProperty.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * $Id: EnumProperty.java,v 1.8 2003/03/05 21:48:01 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.properties.PropertyMaker; - -/** - * Superclass for properties that wrap an enumeration value - */ -public class EnumProperty extends Property { - - /** - * Inner class for creating EnumProperty instances - */ - public static class Maker extends PropertyMaker { - - /** - * @param propName name of property for which a Maker should be created - */ - public Maker(int propId) { - super(propId); - } - - /** - * Called by subclass if no match found. - * @param value string containing the value to be checked - * @return null (indicates that an appropriate match was not found) - */ - public Property checkEnumValues(String value) { - //log.error("Unknown enumerated value for property '" - // + getPropName() + "': " + value); - return super.checkEnumValues(value); - } - - protected Property findConstant(String value) { - return null; - } - - public Property convertProperty(Property p, - PropertyList propertyList, - FObj fo) throws FOPException { - if (p instanceof EnumProperty) { - return p; - } else { - return super.convertProperty(p, propertyList, fo); - } - } - } - - private int value; - - /** - * @param explicitValue enumerated value to be set for this property - */ - public EnumProperty(int explicitValue) { - this.value = explicitValue; - } - - /** - * @return this.value - */ - public int getEnum() { - return this.value; - } - - /** - * @return this.value cast as an Object - */ - public Object getObject() { - // TODO return String value: property must reference maker - // return maker.getEnumValue(this.value); - return new Integer(this.value); - } - -} - diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index ddb892e6c..a24243527 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -54,13 +54,26 @@ import java.util.HashMap; import java.util.Map; import org.apache.fop.datatypes.LengthBase; -import org.apache.fop.datatypes.ToBeImplementedProperty; import org.apache.fop.fo.properties.BorderWidthPropertyMaker; +import org.apache.fop.fo.properties.CharacterProperty; +import org.apache.fop.fo.properties.ColorTypeProperty; +import org.apache.fop.fo.properties.CondLengthProperty; import org.apache.fop.fo.properties.CorrespondingPropertyMaker; import org.apache.fop.fo.properties.DimensionPropertyMaker; +import org.apache.fop.fo.properties.EnumProperty; import org.apache.fop.fo.properties.IndentPropertyMaker; +import org.apache.fop.fo.properties.KeepProperty; +import org.apache.fop.fo.properties.LengthPairProperty; +import org.apache.fop.fo.properties.LengthProperty; +import org.apache.fop.fo.properties.LengthRangeProperty; import org.apache.fop.fo.properties.LineHeightPropertyMaker; +import org.apache.fop.fo.properties.ListProperty; +import org.apache.fop.fo.properties.NumberProperty; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.PropertyMaker; +import org.apache.fop.fo.properties.SpaceProperty; +import org.apache.fop.fo.properties.StringProperty; +import org.apache.fop.fo.properties.ToBeImplementedProperty; /** * This class creates and returns an array of Property.Maker instances diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 8576e29b9..6d61dce3b 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -59,6 +59,7 @@ import java.util.Set; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.flow.Marker; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.PropertyMaker; import org.xml.sax.Attributes; import org.xml.sax.Locator; diff --git a/src/java/org/apache/fop/fo/GenericShorthandParser.java b/src/java/org/apache/fop/fo/GenericShorthandParser.java index 8591c9832..ad6300795 100644 --- a/src/java/org/apache/fop/fo/GenericShorthandParser.java +++ b/src/java/org/apache/fop/fo/GenericShorthandParser.java @@ -52,6 +52,8 @@ package org.apache.fop.fo; import java.util.Enumeration; +import org.apache.fop.fo.properties.ListProperty; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.PropertyMaker; public class GenericShorthandParser implements ShorthandParser { diff --git a/src/java/org/apache/fop/fo/KeepProperty.java b/src/java/org/apache/fop/fo/KeepProperty.java deleted file mode 100644 index a7d659dc3..000000000 --- a/src/java/org/apache/fop/fo/KeepProperty.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * $Id: KeepProperty.java,v 1.3 2003/03/05 21:48:01 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.CompoundDatatype; -import org.apache.fop.fo.properties.CompoundPropertyMaker; - -/** - * Superclass for properties that wrap Keep values - */ -public class KeepProperty extends Property implements CompoundDatatype { - private Property withinLine; - private Property withinColumn; - private Property withinPage; - - /** - * Inner class for creating instances of KeepProperty - */ - public static class Maker extends CompoundPropertyMaker { - - /** - * @param name name of property for which Maker should be created - */ - protected Maker(int propId) { - super(propId); - } - - /** - * Create a new empty instance of KeepProperty. - * @return the new instance. - */ - public Property makeNewProperty() { - return new KeepProperty(); - } - - /** - * @see CompoundPropertyMaker#convertProperty - */ - public Property convertProperty(Property p, PropertyList propertyList, FObj fo) - throws FOPException - { - if (p instanceof KeepProperty) { - return p; - } - return super.convertProperty(p, propertyList, fo); - } - } - - /** - * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean) - */ - public void setComponent(int cmpId, Property cmpnValue, - boolean bIsDefault) { - if (cmpId == CP_WITHIN_LINE) { - setWithinLine(cmpnValue, bIsDefault); - } else if (cmpId == CP_WITHIN_COLUMN) { - setWithinColumn(cmpnValue, bIsDefault); - } else if (cmpId == CP_WITHIN_PAGE) { - setWithinPage(cmpnValue, bIsDefault); - } - } - - /** - * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) - */ - public Property getComponent(int cmpId) { - if (cmpId == CP_WITHIN_LINE) { - return getWithinLine(); - } else if (cmpId == CP_WITHIN_COLUMN) { - return getWithinColumn(); - } else if (cmpId == CP_WITHIN_PAGE) { - return getWithinPage(); - } else { - return null; - } - } - - /** - * @param withinLine withinLine property to set - * @param bIsDefault not used (??) - */ - public void setWithinLine(Property withinLine, boolean bIsDefault) { - this.withinLine = withinLine; - } - - /** - * @param withinColumn withinColumn property to set - * @param bIsDefault not used (??) - */ - protected void setWithinColumn(Property withinColumn, - boolean bIsDefault) { - this.withinColumn = withinColumn; - } - - /** - * @param withinPage withinPage property to set - * @param bIsDefault not used (??) - */ - public void setWithinPage(Property withinPage, boolean bIsDefault) { - this.withinPage = withinPage; - } - - /** - * @return the withinLine property - */ - public Property getWithinLine() { - return this.withinLine; - } - - /** - * @return the withinColumn property - */ - public Property getWithinColumn() { - return this.withinColumn; - } - - /** - * @return the withinPage property - */ - public Property getWithinPage() { - return this.withinPage; - } - - /** - * Not sure what to do here. There isn't really a meaningful single value. - * @return String representation - */ - public String toString() { - return "Keep[" + - "withinLine:" + getWithinLine().getObject() + - ", withinColumn:" + getWithinColumn().getObject() + - ", withinPage:" + getWithinPage().getObject() + "]"; - } - - /** - * @return this.keep - */ - public KeepProperty getKeep() { - return this; - } - - /** - * @return this.keep cast as Object - */ - public Object getObject() { - return this; - } - -} diff --git a/src/java/org/apache/fop/fo/LengthPairProperty.java b/src/java/org/apache/fop/fo/LengthPairProperty.java deleted file mode 100644 index e56bcab2b..000000000 --- a/src/java/org/apache/fop/fo/LengthPairProperty.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * $Id: LengthPairProperty.java,v 1.3 2003/03/05 21:48:02 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.CompoundDatatype; -import org.apache.fop.fo.properties.CompoundPropertyMaker; - -/** - * Superclass for properties wrapping a LengthPair value - */ -public class LengthPairProperty extends Property implements CompoundDatatype { - private Property ipd; - private Property bpd; - - /** - * Inner class for creating instances of LengthPairProperty - */ - public static class Maker extends CompoundPropertyMaker { - - /** - * @param name name of property for which this Maker should be created - */ - protected Maker(int propId) { - super(propId); - } - - /** - * Create a new empty instance of LengthPairProperty. - * @return the new instance. - */ - public Property makeNewProperty() { - return new LengthPairProperty(); - } - - /** - * @see CompoundPropertyMaker#convertProperty - */ - public Property convertProperty(Property p, PropertyList propertyList, FObj fo) - throws FOPException - { - if (p instanceof LengthPairProperty) { - return p; - } - return super.convertProperty(p, propertyList, fo); - } - } - - /** - * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean) - */ - public void setComponent(int cmpId, Property cmpnValue, - boolean bIsDefault) { - if (cmpId == CP_BLOCK_PROGRESSION_DIRECTION) { - bpd = cmpnValue; - } else if (cmpId == CP_INLINE_PROGRESSION_DIRECTION) { - ipd = cmpnValue; - } - } - - /** - * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) - */ - public Property getComponent(int cmpId) { - if (cmpId == CP_BLOCK_PROGRESSION_DIRECTION) { - return getBPD(); - } else if (cmpId == CP_INLINE_PROGRESSION_DIRECTION) { - return getIPD(); - } else { - return null; // SHOULDN'T HAPPEN - } - } - - /** - * @return Property holding the ipd length - */ - public Property getIPD() { - return this.ipd; - } - - /** - * @return Property holding the bpd length - */ - public Property getBPD() { - return this.bpd; - } - - public String toString() { - return "LengthPair[" + - "ipd:" + getIPD().getObject() + - ", bpd:" + getBPD().getObject() + "]"; - } - - /** - * @return this.lengthPair - */ - public LengthPairProperty getLengthPair() { - return this; - } - - /** - * @return this.lengthPair cast as an Object - */ - public Object getObject() { - return this; - } - -} diff --git a/src/java/org/apache/fop/fo/LengthProperty.java b/src/java/org/apache/fop/fo/LengthProperty.java deleted file mode 100644 index fd69848ce..000000000 --- a/src/java/org/apache/fop/fo/LengthProperty.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * $Id: LengthProperty.java,v 1.7 2003/03/05 21:48:01 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.AutoLength; -import org.apache.fop.datatypes.Length; -import org.apache.fop.fo.expr.NumericProperty; -import org.apache.fop.fo.properties.PropertyMaker; - -/** - * Superclass for properties wrapping a Length value. - */ -public class LengthProperty extends Property implements Length { - /** Holds the length in millipoints. */ - protected int millipoints = 0; - /** Indicates if the value has been computed, or not. */ - protected boolean bIsComputed = false; - - /** - * Inner class for making instances of LengthProperty - */ - public static class Maker extends PropertyMaker { - private boolean autoOk = false; - - /** - * @param name name of property for which Maker should be created - */ - public Maker(int propId) { - super(propId); - } - - /** - * protected Property checkPropertyKeywords(String value) { - * if (isAutoLengthAllowed() && value.equals("auto")) { - * return new LengthProperty(Length.AUTO); - * } - * return null; - * } - */ - - /** - * @return false (auto-length is not allowed for Length values) - */ - protected boolean isAutoLengthAllowed() { - return autoOk; - } - - /** - * Set the auto length flag. - * @param inherited - */ - public void setAutoOk(boolean autoOk) { - this.autoOk = autoOk; - } - - /** - * @see Property.Maker#convertProperty - */ - public Property convertProperty(Property p, - PropertyList propertyList, - FObj fo) throws FOPException { - Property prop = super.convertProperty(p, propertyList, fo); - if (prop != null) { - return prop; - } - if (isAutoLengthAllowed()) { - String pval = p.getString(); - if (pval != null && pval.equals("auto")) { - return new AutoLength(); - } - } - if (p instanceof LengthProperty) { - return p; - } - LengthProperty val = p.getLength(); - if (val != null) { - return val; - } - return convertPropertyDatatype(p, propertyList, fo); - } - - } - - - /** - * Returns the length in 1/1000ths of a point (millipoints) - * @return the length in millipoints - */ - public int getValue() { - if (!bIsComputed) { - computeValue(); - } - return millipoints; - } - - /** - * Computes the value. - */ - protected void computeValue() { - } - - - /** - * Sets the computed value. - * @param millipoints the length in millipoints - */ - protected void setComputedValue(int millipoints) { - setComputedValue(millipoints, true); - } - - /** - * Sets the computed value. - * @param millipoints the length in millipoints - * @param bSetComputed True if the isComputed flag should be set. - */ - protected void setComputedValue(int millipoints, boolean bSetComputed) { - this.millipoints = millipoints; - this.bIsComputed = bSetComputed; - } - - /** - * Indicates if the length has the "auto" value. - * @return True if the length is set to "auto" - */ - public boolean isAuto() { - return false; - } - - /** - * Indicates if the length has been computed. - * @return True if the length has been computed - */ - public boolean isComputed() { - return this.bIsComputed; - } - - /** - * Return the number of table units which are included in this - * length specification. - * This will always be 0 unless the property specification used - * the proportional-column-width() function (only only table - * column FOs). - *

If this value is not 0, the actual value of the Length cannot - * be known without looking at all of the columns in the table to - * determine the value of a "table-unit". - * @return The number of table units which are included in this - * length specification. - */ - public double getTableUnits() { - return 0.0; - } - - public void resolveTableUnit(double dTableUnit) { - } - - /** - * @return null (cannot be converted to a Numeric ??) - */ - public NumericProperty asNumeric() { - return null; - } - - /** - * @see java.lang.Object#toString() - */ - public String toString() { - String s = millipoints + "mpt"; - return s; - } - - /** - * @return this.lenght cast as a Numeric - */ - public NumericProperty getNumeric() { - return asNumeric() ; - } - - /** - * @return this.length - */ - public LengthProperty getLength() { - return this; - } - - /** - * @return this.length cast as an Object - */ - public Object getObject() { - return this; - } - -} - diff --git a/src/java/org/apache/fop/fo/LengthRangeProperty.java b/src/java/org/apache/fop/fo/LengthRangeProperty.java deleted file mode 100644 index 218cf5514..000000000 --- a/src/java/org/apache/fop/fo/LengthRangeProperty.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * $Id: LengthRangeProperty.java,v 1.5 2003/03/05 21:48:02 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.CompoundDatatype; -import org.apache.fop.fo.properties.CompoundPropertyMaker; - -/** - * Superclass for properties that contain LengthRange values - */ -public class LengthRangeProperty extends Property implements CompoundDatatype { - private Property minimum; - private Property optimum; - private Property maximum; - private static final int MINSET = 1; - private static final int OPTSET = 2; - private static final int MAXSET = 4; - private int bfSet = 0; // bit field - private boolean bChecked = false; - - /** - * Inner class for a Maker for LengthProperty objects - */ - public static class Maker extends CompoundPropertyMaker { - - /** - * @param name name of property for which to create Maker - */ - protected Maker(int propId) { - super(propId); - } - - /** - * Create a new empty instance of LengthRangeProperty. - * @return the new instance. - */ - public Property makeNewProperty() { - return new LengthRangeProperty(); - } - - /** - * @see CompoundPropertyMaker#convertProperty - */ - public Property convertProperty(Property p, PropertyList propertyList, FObj fo) - throws FOPException - { - if (p instanceof LengthRangeProperty) { - return p; - } - return super.convertProperty(p, propertyList, fo); - } - } - - - - /** - * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean) - */ - public void setComponent(int cmpId, Property cmpnValue, - boolean bIsDefault) { - if (cmpId == CP_MINIMUM) { - setMinimum(cmpnValue, bIsDefault); - } else if (cmpId == CP_OPTIMUM) { - setOptimum(cmpnValue, bIsDefault); - } else if (cmpId == CP_MAXIMUM) { - setMaximum(cmpnValue, bIsDefault); - } - } - - /** - * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) - */ - public Property getComponent(int cmpId) { - if (cmpId == CP_MINIMUM) { - return getMinimum(); - } else if (cmpId == CP_OPTIMUM) { - return getOptimum(); - } else if (cmpId == CP_MAXIMUM) { - return getMaximum(); - } else { - return null; // SHOULDN'T HAPPEN - } - } - - /** - * Set minimum value to min. - * @param minimum A Length value specifying the minimum value for this - * LengthRange. - * @param bIsDefault If true, this is set as a "default" value - * and not a user-specified explicit value. - */ - protected void setMinimum(Property minimum, boolean bIsDefault) { - this.minimum = minimum; - if (!bIsDefault) { - bfSet |= MINSET; - } - } - - - /** - * Set maximum value to max if it is >= optimum or optimum isn't set. - * @param max A Length value specifying the maximum value for this - * @param bIsDefault If true, this is set as a "default" value - * and not a user-specified explicit value. - */ - protected void setMaximum(Property max, boolean bIsDefault) { - maximum = max; - if (!bIsDefault) { - bfSet |= MAXSET; - } - } - - - /** - * Set the optimum value. - * @param opt A Length value specifying the optimum value for this - * @param bIsDefault If true, this is set as a "default" value - * and not a user-specified explicit value. - */ - protected void setOptimum(Property opt, boolean bIsDefault) { - optimum = opt; - if (!bIsDefault) { - bfSet |= OPTSET; - } - } - - // Minimum is prioritaire, if explicit - private void checkConsistency() { - if (bChecked) { - return; - } - // Make sure max >= min - // Must also control if have any allowed enum values! - - /** - * ******************* - * if (minimum.mvalue() > maximum.mvalue()) { - * if ((bfSet&MINSET)!=0) { - * // if minimum is explicit, force max to min - * if ((bfSet&MAXSET)!=0) { - * // Warning: min>max, resetting max to min - * log.error("forcing max to min in LengthRange"); - * } - * maximum = minimum ; - * } - * else { - * minimum = maximum; // minimum was default value - * } - * } - * // Now make sure opt <= max and opt >= min - * if (optimum.mvalue() > maximum.mvalue()) { - * if ((bfSet&OPTSET)!=0) { - * if ((bfSet&MAXSET)!=0) { - * // Warning: opt > max, resetting opt to max - * log.error("forcing opt to max in LengthRange"); - * optimum = maximum ; - * } - * else { - * maximum = optimum; // maximum was default value - * } - * } - * else { - * // opt is default and max is explicit or default - * optimum = maximum ; - * } - * } - * else if (optimum.mvalue() < minimum.mvalue()) { - * if ((bfSet&MINSET)!=0) { - * // if minimum is explicit, force opt to min - * if ((bfSet&OPTSET)!=0) { - * log.error("forcing opt to min in LengthRange"); - * } - * optimum = minimum ; - * } - * else { - * minimum = optimum; // minimum was default value - * } - * } - * *******$******* - */ - bChecked = true; - } - - /** - * @return minimum length - */ - public Property getMinimum() { - checkConsistency(); - return this.minimum; - } - - /** - * @return maximum length - */ - public Property getMaximum() { - checkConsistency(); - return this.maximum; - } - - /** - * @return optimum length - */ - public Property getOptimum() { - checkConsistency(); - return this.optimum; - } - - public String toString() { - return "LengthRange[" + - "min:" + getMinimum().getObject() + - ", max:" + getMaximum().getObject() + - ", opt:" + getOptimum().getObject() + "]"; - } - - /** - * @return this.lengthRange - */ - public LengthRangeProperty getLengthRange() { - return this; - } - - /** - * @return this.lengthRange cast as an Object - */ - public Object getObject() { - return this; - } - -} diff --git a/src/java/org/apache/fop/fo/ListProperty.java b/src/java/org/apache/fop/fo/ListProperty.java deleted file mode 100644 index 1ec8b9d9d..000000000 --- a/src/java/org/apache/fop/fo/ListProperty.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * $Id: ListProperty.java,v 1.3 2003/03/05 21:48:01 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import java.util.Vector; - -import org.apache.fop.fo.properties.PropertyMaker; - -/** - * Superclass for properties that are lists of other properties - */ -public class ListProperty extends Property { - - /** - * Inner class for creating instances of ListProperty - */ - public static class Maker extends PropertyMaker { - - /** - * @param name name of property for which Maker should be created - */ - public Maker(int propId) { - super(propId); - } - - /** - * @see Property.Maker#convertProperty - */ - public Property convertProperty(Property p, - PropertyList propertyList, FObj fo) { - if (p instanceof ListProperty) { - return p; - } else { - return new ListProperty(p); - } - } - - } - - /** Vector containing the list of sub-properties */ - protected Vector list; - - /** - * @param prop the first Property to be added to the list - */ - public ListProperty(Property prop) { - list = new Vector(); - list.addElement(prop); - } - - /** - * Add a new property to the list - * @param prop Property to be added to the list - */ - public void addProperty(Property prop) { - list.addElement(prop); - } - - /** - * @return this.list - */ - public Vector getList() { - return list; - } - - /** - * @return this.list cast as an Object - */ - public Object getObject() { - return list; - } - -} diff --git a/src/java/org/apache/fop/fo/NumberProperty.java b/src/java/org/apache/fop/fo/NumberProperty.java deleted file mode 100644 index 9288cb8d7..000000000 --- a/src/java/org/apache/fop/fo/NumberProperty.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * $Id: NumberProperty.java,v 1.6 2003/03/05 21:48:01 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import org.apache.fop.fo.expr.NumericProperty; -import org.apache.fop.fo.properties.PropertyMaker; - -/** - * Class for handling numeric properties - */ -public class NumberProperty extends Property { - - /** - * Inner class for making NumberProperty objects - */ - public static class Maker extends PropertyMaker { - - /** - * Constructor for NumberProperty.Maker - * @param propName the name of the property - */ - public Maker(int propId) { - super(propId); - } - - /** - * @see Property.Maker#convertProperty - */ - public Property convertProperty(Property p, - PropertyList propertyList, FObj fo) { - if (p instanceof NumberProperty) { - return p; - } - Number val = p.getNumber(); - if (val != null) { - return new NumberProperty(val); - } - return convertPropertyDatatype(p, propertyList, fo); - } - - } - - private Number number; - - /** - * Constructor for Number input - * @param num Number object value for property - */ - public NumberProperty(Number num) { - this.number = num; - } - - /** - * Constructor for double input - * @param num double numeric value for property - */ - public NumberProperty(double num) { - this.number = new Double(num); - } - - /** - * Constructor for integer input - * @param num integer numeric value for property - */ - public NumberProperty(int num) { - this.number = new Integer(num); - } - - /** - * @return this.number cast as a Number - */ - public Number getNumber() { - return this.number; - } - - /** - * public Double getDouble() { - * return new Double(this.number.doubleValue()); - * } - * public Integer getInteger() { - * return new Integer(this.number.intValue()); - * } - */ - - /** - * @return this.number cast as an Object - */ - public Object getObject() { - return this.number; - } - - /** - * Convert NumberProperty to Numeric object - * @return Numeric object corresponding to this - */ - public NumericProperty getNumeric() { - return new NumericProperty(this.number); - } - - /** - * Convert NumberProperty to a ColorType. Not sure why this is needed. - * @return ColorType that corresponds to black - */ - public ColorTypeProperty getColorType() { - // Convert numeric value to color ??? - // Convert to hexadecimal and then try to make it into a color? - return new ColorTypeProperty((float)0.0, (float)0.0, (float)0.0); - } - -} diff --git a/src/java/org/apache/fop/fo/Property.java b/src/java/org/apache/fop/fo/Property.java deleted file mode 100644 index 80b68d4ed..000000000 --- a/src/java/org/apache/fop/fo/Property.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * $Id: Property.java,v 1.22 2003/03/05 21:48:02 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import org.apache.fop.fo.expr.NumericProperty; -import java.util.Vector; - -/** - * Base class for all property objects - * @author unascribed - */ -public class Property { - - /** - * The original specified value for properties which inherit - * specified values. - */ - private String specVal; - - /** - * Set the original value specified for the property attribute. - * @param specVal The specified value. - */ - public void setSpecifiedValue(String specVal) { - this.specVal = specVal; - } - - /** - * Return the original value specified for the property attribute. - * @return The specified value as a String. - */ - public String getSpecifiedValue() { - return specVal; - } - -/* - * This section contains accessor functions for all possible Property datatypes - */ - - - /** - * This method expects to be overridden by subclasses - * @return Length property value - */ - public LengthProperty getLength() { - return null; - } - - /** - * This method expects to be overridden by subclasses - * @return ColorType property value - */ - public ColorTypeProperty getColorType() { - return null; - } - - /** - * This method expects to be overridden by subclasses - * @return CondLength property value - */ - public CondLengthProperty getCondLength() { - return null; - } - - /** - * This method expects to be overridden by subclasses - * @return LenghtRange property value - */ - public LengthRangeProperty getLengthRange() { - return null; - } - - /** - * This method expects to be overridden by subclasses - * @return LengthPair property value - */ - public LengthPairProperty getLengthPair() { - return null; - } - - /** - * This method expects to be overridden by subclasses - * @return Space property value - */ - public SpaceProperty getSpace() { - return null; - } - - /** - * This method expects to be overridden by subclasses - * @return Keep property value - */ - public KeepProperty getKeep() { - return null; - } - - /** - * This method expects to be overridden by subclasses - * @return integer equivalent of enumerated property value - */ - public int getEnum() { - return 0; - } - - /** - * This method expects to be overridden by subclasses - * @return char property value - */ - public char getCharacter() { - return 0; - } - - /** - * This method expects to be overridden by subclasses - * @return collection of other property (sub-property) objects - */ - public Vector getList() { - return null; - } - - /** - * This method expects to be overridden by subclasses - * @return Number property value - */ - public Number getNumber() { - return null; - } - - /** - * This method expects to be overridden by subclasses - * @return Numeric property value - */ - public NumericProperty getNumeric() { - return null; - } - - /** - * This method expects to be overridden by subclasses - * @return NCname property value - */ - public String getNCname() { - return null; - } - - /** - * This method expects to be overridden by subclasses - * @return Object property value - */ - public Object getObject() { - return null; - } - - /** - * This method expects to be overridden by subclasses. - * @return String property value - */ - public String getString() { - return null; - } - - /** - * Return a string representation of the property value. Only used - * for debugging. - */ - public String toString() { - return getString(); - } -} diff --git a/src/java/org/apache/fop/fo/PropertyList.java b/src/java/org/apache/fop/fo/PropertyList.java index 68c843da7..39f989e0a 100644 --- a/src/java/org/apache/fop/fo/PropertyList.java +++ b/src/java/org/apache/fop/fo/PropertyList.java @@ -56,6 +56,7 @@ import org.xml.sax.Attributes; // FOP import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.PropertyMaker; /** diff --git a/src/java/org/apache/fop/fo/PropertyManager.java b/src/java/org/apache/fop/fo/PropertyManager.java index 467254442..4c25add9e 100644 --- a/src/java/org/apache/fop/fo/PropertyManager.java +++ b/src/java/org/apache/fop/fo/PropertyManager.java @@ -52,6 +52,7 @@ package org.apache.fop.fo; // FOP import org.apache.fop.fonts.Font; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonMarginInline; diff --git a/src/java/org/apache/fop/fo/ShorthandParser.java b/src/java/org/apache/fop/fo/ShorthandParser.java index b690abe95..5d9f901ec 100644 --- a/src/java/org/apache/fop/fo/ShorthandParser.java +++ b/src/java/org/apache/fop/fo/ShorthandParser.java @@ -50,6 +50,8 @@ */ package org.apache.fop.fo; +import org.apache.fop.fo.properties.ListProperty; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.PropertyMaker; /** diff --git a/src/java/org/apache/fop/fo/SpaceProperty.java b/src/java/org/apache/fop/fo/SpaceProperty.java deleted file mode 100644 index 7f2c15425..000000000 --- a/src/java/org/apache/fop/fo/SpaceProperty.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * $Id: SpaceProperty.java,v 1.5 2003/03/05 21:48:01 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.properties.CompoundPropertyMaker; - -/** - * Base class used for handling properties of the fo:space-before and - * fo:space-after variety. It is extended by org.apache.fop.fo.properties.GenericSpace, - * which is extended by many other properties. - */ -public class SpaceProperty extends LengthRangeProperty { - private Property precedence; - private Property conditionality; - - /** - * Inner class used to create new instances of SpaceProperty - */ - public static class Maker extends CompoundPropertyMaker { - - /** - * @param name name of the property whose Maker is to be created - */ - protected Maker(int propId) { - super(propId); - } - - /** - * Create a new empty instance of SpaceProperty. - * @return the new instance. - */ - public Property makeNewProperty() { - return new SpaceProperty(); - } - - /** - * @see CompoundPropertyMaker#convertProperty - */ - public Property convertProperty(Property p, - PropertyList propertyList, - FObj fo) throws FOPException { - if (p instanceof SpaceProperty) { - return p; - } - return super.convertProperty(p, propertyList, fo); - } - } - - - - /** - * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean) - */ - public void setComponent(int cmpId, Property cmpnValue, - boolean bIsDefault) { - if (cmpId == CP_PRECEDENCE) { - setPrecedence(cmpnValue, bIsDefault); - } else if (cmpId == CP_CONDITIONALITY) { - setConditionality(cmpnValue, bIsDefault); - } else { - super.setComponent(cmpId, cmpnValue, bIsDefault); - } - } - - /** - * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) - */ - public Property getComponent(int cmpId) { - if (cmpId == CP_PRECEDENCE) { - return getPrecedence(); - } else if (cmpId == CP_CONDITIONALITY) { - return getConditionality(); - } else { - return super.getComponent(cmpId); - } - } - - /** - * - * @param precedence precedence Property to set - * @param bIsDefault (is not used anywhere) - */ - protected void setPrecedence(Property precedence, boolean bIsDefault) { - this.precedence = precedence; - } - - /** - * - * @param conditionality conditionality Property to set - * @param bIsDefault (is not used anywhere) - */ - protected void setConditionality(Property conditionality, - boolean bIsDefault) { - this.conditionality = conditionality; - } - - /** - * @return precedence Property - */ - public Property getPrecedence() { - return this.precedence; - } - - /** - * @return conditionality Property - */ - public Property getConditionality() { - return this.conditionality; - } - - public String toString() { - return "Space[" + - "min:" + getMinimum().getObject() + - ", max:" + getMaximum().getObject() + - ", opt:" + getOptimum().getObject() + - ", precedence:" + precedence.getObject() + - ", conditionality:" + conditionality.getObject() + "]"; - } - - /** - * @return the Space (datatype) object contained here - */ - public SpaceProperty getSpace() { - return this; - } - - /** - * Space extends LengthRange. - * @return the Space (datatype) object contained here - */ - public LengthRangeProperty getLengthRange() { - return this; - } - - /** - * @return the Space (datatype) object contained here - */ - public Object getObject() { - return this; - } - -} diff --git a/src/java/org/apache/fop/fo/StringProperty.java b/src/java/org/apache/fop/fo/StringProperty.java deleted file mode 100644 index 612e419b5..000000000 --- a/src/java/org/apache/fop/fo/StringProperty.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * $Id: StringProperty.java,v 1.4 2003/03/05 21:48:01 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 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 . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fo; - -import org.apache.fop.fo.properties.PropertyMaker; - -/** - * Exists primarily as a container for its Maker inner class, which is - * extended by many string-based FO property classes. - */ -public class StringProperty extends Property { - - /** - * Inner class for making instances of StringProperty - */ - public static class Maker extends PropertyMaker { - - /** - * @param propName name of property for which to create a Maker - */ - public Maker(int propId) { - super(propId); - } - - /** - * Make a new StringProperty object - * @param propertyList not used - * @param value String value of the new object - * @param fo not used - * @return the StringProperty object - */ - public Property make(PropertyList propertyList, String value, - FObj fo) { - // Work around the fact that most String properties are not - // specified as actual String literals (with "" or '') since - // the attribute values themselves are Strings! - // If the value starts with ' or ", make sure it also ends with - // this character - // Otherwise, just take the whole value as the String - int vlen = value.length() - 1; - if (vlen > 0) { - char q1 = value.charAt(0); - if (q1 == '"' || q1 == '\'') { - if (value.charAt(vlen) == q1) { - return new StringProperty(value.substring(1, vlen)); - } - System.err.println("Warning String-valued property starts with quote" - + " but doesn't end with quote: " - + value); - // fall through and use the entire value, including first quote - } - String str = checkValueKeywords(value); - if (str != null) { - value = str; - } - } - return new StringProperty(value); - } - - } // end String.Maker - - private String str; - - /** - * @param str String value to place in this object - */ - public StringProperty(String str) { - this.str = str; - // System.err.println("Set StringProperty: " + str); - } - - /** - * @return the Object equivalent of this property - */ - public Object getObject() { - return this.str; - } - - /** - * @return the String equivalent of this property - */ - public String getString() { - return this.str; - } - -} diff --git a/src/java/org/apache/fop/fo/expr/AbsFunction.java b/src/java/org/apache/fop/fo/expr/AbsFunction.java index f29bb8c6c..a6494eb5b 100644 --- a/src/java/org/apache/fop/fo/expr/AbsFunction.java +++ b/src/java/org/apache/fop/fo/expr/AbsFunction.java @@ -50,7 +50,7 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; +import org.apache.fop.fo.properties.Property; /** * Class modelling the abs Number Function. See Sec. 5.10.1 of the XSL-FO spec. diff --git a/src/java/org/apache/fop/fo/expr/BodyStartFunction.java b/src/java/org/apache/fop/fo/expr/BodyStartFunction.java index 69416d770..d5abfd064 100644 --- a/src/java/org/apache/fop/fo/expr/BodyStartFunction.java +++ b/src/java/org/apache/fop/fo/expr/BodyStartFunction.java @@ -51,9 +51,9 @@ package org.apache.fop.fo.expr; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.Property; import org.apache.fop.fo.FONode; import org.apache.fop.fo.flow.ListItem; +import org.apache.fop.fo.properties.Property; /** * Class corresponding to the body-start Property Value function. See Sec. diff --git a/src/java/org/apache/fop/fo/expr/CeilingFunction.java b/src/java/org/apache/fop/fo/expr/CeilingFunction.java index f43544e38..5ec166b8e 100644 --- a/src/java/org/apache/fop/fo/expr/CeilingFunction.java +++ b/src/java/org/apache/fop/fo/expr/CeilingFunction.java @@ -50,8 +50,8 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.NumberProperty; +import org.apache.fop.fo.properties.NumberProperty; +import org.apache.fop.fo.properties.Property; class CeilingFunction extends FunctionBase { diff --git a/src/java/org/apache/fop/fo/expr/FloorFunction.java b/src/java/org/apache/fop/fo/expr/FloorFunction.java index 48913dd95..aafcc36e3 100644 --- a/src/java/org/apache/fop/fo/expr/FloorFunction.java +++ b/src/java/org/apache/fop/fo/expr/FloorFunction.java @@ -50,8 +50,8 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.NumberProperty; +import org.apache.fop.fo.properties.NumberProperty; +import org.apache.fop.fo.properties.Property; class FloorFunction extends FunctionBase { diff --git a/src/java/org/apache/fop/fo/expr/FopPropValFunction.java b/src/java/org/apache/fop/fo/expr/FopPropValFunction.java index 2d2581587..2d65461df 100644 --- a/src/java/org/apache/fop/fo/expr/FopPropValFunction.java +++ b/src/java/org/apache/fop/fo/expr/FopPropValFunction.java @@ -50,8 +50,8 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; import org.apache.fop.fo.FOPropertyMapping; +import org.apache.fop.fo.properties.Property; /** diff --git a/src/java/org/apache/fop/fo/expr/FromParentFunction.java b/src/java/org/apache/fop/fo/expr/FromParentFunction.java index c6bf0dd5f..654aa2ce8 100644 --- a/src/java/org/apache/fop/fo/expr/FromParentFunction.java +++ b/src/java/org/apache/fop/fo/expr/FromParentFunction.java @@ -50,8 +50,8 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; import org.apache.fop.fo.FOPropertyMapping; +import org.apache.fop.fo.properties.Property; /** diff --git a/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java b/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java index e6241ff16..3a798660f 100644 --- a/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java +++ b/src/java/org/apache/fop/fo/expr/FromTableColumnFunction.java @@ -50,7 +50,7 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; +import org.apache.fop.fo.properties.Property; /** * Class modelling the from-table-column Property Value function. See Sec. diff --git a/src/java/org/apache/fop/fo/expr/Function.java b/src/java/org/apache/fop/fo/expr/Function.java index 0910ec173..a66523d8b 100644 --- a/src/java/org/apache/fop/fo/expr/Function.java +++ b/src/java/org/apache/fop/fo/expr/Function.java @@ -50,7 +50,7 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; +import org.apache.fop.fo.properties.Property; import org.apache.fop.datatypes.PercentBase; /** diff --git a/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java b/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java index 08c8d96d4..31ef3a763 100644 --- a/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java +++ b/src/java/org/apache/fop/fo/expr/InheritedPropFunction.java @@ -50,8 +50,8 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; import org.apache.fop.fo.FOPropertyMapping; +import org.apache.fop.fo.properties.Property; /** * Class modelling the inherited-property-value Property Value function. See diff --git a/src/java/org/apache/fop/fo/expr/LabelEndFunction.java b/src/java/org/apache/fop/fo/expr/LabelEndFunction.java index e44b29951..7b2277511 100644 --- a/src/java/org/apache/fop/fo/expr/LabelEndFunction.java +++ b/src/java/org/apache/fop/fo/expr/LabelEndFunction.java @@ -51,13 +51,13 @@ package org.apache.fop.fo.expr; import org.apache.fop.datatypes.LengthBase; -import org.apache.fop.datatypes.LinearCombinationLength; -import org.apache.fop.datatypes.PercentLength; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.LengthProperty; import org.apache.fop.fo.FONode; import org.apache.fop.fo.flow.ListItem; +import org.apache.fop.fo.properties.LengthProperty; +import org.apache.fop.fo.properties.LinearCombinationLength; +import org.apache.fop.fo.properties.PercentLength; +import org.apache.fop.fo.properties.Property; /** * Class modelling the label-end Property Value function. See Sec. 5.10.4 of the diff --git a/src/java/org/apache/fop/fo/expr/MaxFunction.java b/src/java/org/apache/fop/fo/expr/MaxFunction.java index 40c8a407a..1127bcc97 100644 --- a/src/java/org/apache/fop/fo/expr/MaxFunction.java +++ b/src/java/org/apache/fop/fo/expr/MaxFunction.java @@ -50,7 +50,7 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; +import org.apache.fop.fo.properties.Property; /** * Class for managing the "max" Number Function. See Sec. 5.10.1 in the XSL-FO diff --git a/src/java/org/apache/fop/fo/expr/MinFunction.java b/src/java/org/apache/fop/fo/expr/MinFunction.java index cdb9f25a3..6ddaa0ba3 100644 --- a/src/java/org/apache/fop/fo/expr/MinFunction.java +++ b/src/java/org/apache/fop/fo/expr/MinFunction.java @@ -50,7 +50,7 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; +import org.apache.fop.fo.properties.Property; /** * Class for managing the "min" Number Function. See Sec. 5.10.1 in the XSL-FO diff --git a/src/java/org/apache/fop/fo/expr/NCnameProperty.java b/src/java/org/apache/fop/fo/expr/NCnameProperty.java index 7fff73df2..7fd8801de 100644 --- a/src/java/org/apache/fop/fo/expr/NCnameProperty.java +++ b/src/java/org/apache/fop/fo/expr/NCnameProperty.java @@ -50,7 +50,7 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; +import org.apache.fop.fo.properties.Property; import org.apache.fop.datatypes.ColorType; /** diff --git a/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java b/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java index 6ac4dc743..a52a4a0c4 100644 --- a/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java +++ b/src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java @@ -50,8 +50,8 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; import org.apache.fop.fo.FOPropertyMapping; +import org.apache.fop.fo.properties.Property; /** * Class modelling the from-nearest-specified-value function. See Sec. 5.10.4 diff --git a/src/java/org/apache/fop/fo/expr/NumericProperty.java b/src/java/org/apache/fop/fo/expr/NumericProperty.java index 3d9028cba..70de2fa44 100644 --- a/src/java/org/apache/fop/fo/expr/NumericProperty.java +++ b/src/java/org/apache/fop/fo/expr/NumericProperty.java @@ -53,14 +53,14 @@ package org.apache.fop.fo.expr; import java.util.Vector; import org.apache.fop.datatypes.PercentBase; -import org.apache.fop.datatypes.FixedLength; -import org.apache.fop.datatypes.TableColLength; -import org.apache.fop.datatypes.PercentLength; -import org.apache.fop.datatypes.MixedLength; - -import org.apache.fop.fo.ColorTypeProperty; -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.Property; + +import org.apache.fop.fo.properties.ColorTypeProperty; +import org.apache.fop.fo.properties.FixedLength; +import org.apache.fop.fo.properties.LengthProperty; +import org.apache.fop.fo.properties.MixedLength; +import org.apache.fop.fo.properties.PercentLength; +import org.apache.fop.fo.properties.Property; +import org.apache.fop.fo.properties.TableColLength; public class NumericProperty extends Property { // Bit fields diff --git a/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java b/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java index 4d2ce74fc..06edf8d41 100644 --- a/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java +++ b/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java @@ -51,8 +51,8 @@ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; -import org.apache.fop.datatypes.TableColLength; +import org.apache.fop.fo.properties.Property; +import org.apache.fop.fo.properties.TableColLength; /** * Class modelling the proportional-column-width function. See Sec. 5.10.4 of diff --git a/src/java/org/apache/fop/fo/expr/PropertyParser.java b/src/java/org/apache/fop/fo/expr/PropertyParser.java index 4a2bcca09..a26630277 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyParser.java +++ b/src/java/org/apache/fop/fo/expr/PropertyParser.java @@ -50,15 +50,15 @@ */ package org.apache.fop.fo.expr; -import org.apache.fop.datatypes.FixedLength; import org.apache.fop.datatypes.PercentBase; -import org.apache.fop.datatypes.PercentLength; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.ColorTypeProperty; -import org.apache.fop.fo.ListProperty; -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.NumberProperty; -import org.apache.fop.fo.StringProperty; +import org.apache.fop.fo.properties.ColorTypeProperty; +import org.apache.fop.fo.properties.FixedLength; +import org.apache.fop.fo.properties.LengthProperty; +import org.apache.fop.fo.properties.ListProperty; +import org.apache.fop.fo.properties.NumberProperty; +import org.apache.fop.fo.properties.PercentLength; +import org.apache.fop.fo.properties.Property; +import org.apache.fop.fo.properties.StringProperty; import java.util.HashMap; diff --git a/src/java/org/apache/fop/fo/expr/RGBColorFunction.java b/src/java/org/apache/fop/fo/expr/RGBColorFunction.java index 00b58a359..69d92c9c0 100644 --- a/src/java/org/apache/fop/fo/expr/RGBColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/RGBColorFunction.java @@ -51,8 +51,8 @@ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.ColorTypeProperty; +import org.apache.fop.fo.properties.ColorTypeProperty; +import org.apache.fop.fo.properties.Property; import org.apache.fop.datatypes.PercentBase; class RGBColorFunction extends FunctionBase { diff --git a/src/java/org/apache/fop/fo/expr/RoundFunction.java b/src/java/org/apache/fop/fo/expr/RoundFunction.java index 1877c87f2..3980704d1 100644 --- a/src/java/org/apache/fop/fo/expr/RoundFunction.java +++ b/src/java/org/apache/fop/fo/expr/RoundFunction.java @@ -51,8 +51,8 @@ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.NumberProperty; +import org.apache.fop.fo.properties.NumberProperty; +import org.apache.fop.fo.properties.Property; class RoundFunction extends FunctionBase { public int nbArgs() { diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index 06141c983..3e51896be 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java @@ -58,7 +58,7 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.FOTreeVisitor; -import org.apache.fop.fo.LengthProperty; +import org.apache.fop.fo.properties.LengthProperty; import org.apache.fop.image.ImageFactory; import org.apache.fop.image.FopImage; // Java diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java index bcb745399..e7cb39d1e 100644 --- a/src/java/org/apache/fop/fo/flow/Leader.java +++ b/src/java/org/apache/fop/fo/flow/Leader.java @@ -52,7 +52,6 @@ package org.apache.fop.fo.flow; import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.Length; -import org.apache.fop.datatypes.PercentLength; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOTreeVisitor; import org.apache.fop.fo.FObjMixed; @@ -62,6 +61,7 @@ import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.fo.properties.PercentLength; import org.apache.fop.fonts.Font; /** diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java index ad531aa6f..1a621b39c 100644 --- a/src/java/org/apache/fop/fo/flow/Table.java +++ b/src/java/org/apache/fop/fo/flow/Table.java @@ -59,7 +59,6 @@ import org.xml.sax.Attributes; // FOP import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.ColorType; -import org.apache.fop.fo.LengthRangeProperty; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.FOTreeVisitor; @@ -69,6 +68,7 @@ import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.fo.properties.LengthRangeProperty; /** * Class modelling the fo:table object. See Sec. 6.7.3 of the XSL-FO Standard. diff --git a/src/java/org/apache/fop/fo/flow/TableColumn.java b/src/java/org/apache/fop/fo/flow/TableColumn.java index 4d6eb7a78..76a960771 100644 --- a/src/java/org/apache/fop/fo/flow/TableColumn.java +++ b/src/java/org/apache/fop/fo/flow/TableColumn.java @@ -60,10 +60,10 @@ import org.apache.fop.datatypes.Length; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.FOTreeVisitor; -import org.apache.fop.fo.Property; import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonBorderAndPadding; +import org.apache.fop.fo.properties.Property; /** * Class modelling the fo:table-column object. See Sec. 6.7.4 of the XSL-FO diff --git a/src/java/org/apache/fop/fo/flow/TableRow.java b/src/java/org/apache/fop/fo/flow/TableRow.java index 39bac72ed..a8806d8d9 100644 --- a/src/java/org/apache/fop/fo/flow/TableRow.java +++ b/src/java/org/apache/fop/fo/flow/TableRow.java @@ -59,7 +59,6 @@ import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.KeepValue; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.Property; import org.apache.fop.fo.FOTreeVisitor; import org.apache.fop.fo.Constants; @@ -68,6 +67,7 @@ import org.apache.fop.fo.properties.CommonAural; import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.fo.properties.Property; /** diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java index fd89cc670..1a55e7838 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java @@ -57,9 +57,9 @@ import org.apache.fop.datatypes.FODimension; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOTreeVisitor; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.Property; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.properties.CommonMarginBlock; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.FOPropertyMapping; /** diff --git a/src/java/org/apache/fop/fo/pagination/Title.java b/src/java/org/apache/fop/fo/pagination/Title.java index 3fbe8c67b..6036893fc 100644 --- a/src/java/org/apache/fop/fo/pagination/Title.java +++ b/src/java/org/apache/fop/fo/pagination/Title.java @@ -53,16 +53,16 @@ package org.apache.fop.fo.pagination; // FOP import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.Length; -import org.apache.fop.fo.EnumProperty; import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.FONode; -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.Property; import org.apache.fop.fo.FOTreeVisitor; import org.apache.fop.fo.properties.CommonAccessibility; import org.apache.fop.fo.properties.CommonAural; import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonBorderAndPadding; +import org.apache.fop.fo.properties.EnumProperty; +import org.apache.fop.fo.properties.LengthProperty; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fonts.Font; import org.apache.fop.fo.properties.CommonMarginInline; diff --git a/src/java/org/apache/fop/fo/properties/AutoLength.java b/src/java/org/apache/fop/fo/properties/AutoLength.java new file mode 100644 index 000000000..0730a289c --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/AutoLength.java @@ -0,0 +1,78 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + + +/** + * A length quantity in XSL which is specified as "auto". + */ +public class AutoLength extends LengthProperty { + + /** + * @see org.apache.fop.datatypes.Length#isAuto() + */ + public boolean isAuto() { + return true; + } + + // Should we do something intelligent here to set the actual size? + // Would need a reference object! + // protected void computeValue() { + // } + + /** + * @see org.apache.fop.fo.Property#getString() + */ + public String getString() { + return "auto"; + } + +} diff --git a/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java b/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java index 637a62845..ff6849696 100644 --- a/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java @@ -52,8 +52,6 @@ package org.apache.fop.fo.properties; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.Property; import org.apache.fop.fo.PropertyList; /** diff --git a/src/java/org/apache/fop/fo/properties/CharacterProperty.java b/src/java/org/apache/fop/fo/properties/CharacterProperty.java new file mode 100644 index 000000000..4931887b4 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/CharacterProperty.java @@ -0,0 +1,111 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; + +/** + * Superclass for properties that wrap a character value + */ +public class CharacterProperty extends Property { + + /** + * Inner class for creating instances of CharacterProperty + */ + public static class Maker extends PropertyMaker { + + /** + * @param propName name of property for which a Maker should be created + */ + public Maker(int propId) { + super(propId); + } + + public Property make(PropertyList propertyList, String value, + FObj fo) { + char c = value.charAt(0); + return new CharacterProperty(c); + } + + } // end Charakter.Maker + + private char character; + + /** + * @param character character value to be wrapped in this property + */ + public CharacterProperty(char character) { + this.character = character; + } + + /** + * @return this.character cast as an Object + */ + public Object getObject() { + return new Character(character); + } + + /** + * @return this.character + */ + public char getCharacter() { + return this.character; + } + + /** + * @return this.character cast as a String + */ + public String getString() { + return new Character(character).toString(); + } + +} diff --git a/src/java/org/apache/fop/fo/properties/ColorTypeProperty.java b/src/java/org/apache/fop/fo/properties/ColorTypeProperty.java new file mode 100644 index 000000000..f85154ef9 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/ColorTypeProperty.java @@ -0,0 +1,810 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import java.awt.Color; +import java.util.StringTokenizer; + +import org.apache.fop.datatypes.ColorType; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; + +/** + * Superclass for properties that wrap ColorType values + */ +public class ColorTypeProperty extends Property implements ColorType { + /** + * the red component + */ + protected float red = 0f; + + /** + * the green component + */ + protected float green = 0f; + + /** + * the blue component + */ + protected float blue = 0f; + + /** + * the alpha component (indicator of opaque-ness) + * 0.0 - 1.0; 0.0 is completely transparent; 1.0 is completely opaque + * see definition at http://java.sun.com/j2se/1.3/docs/api/java/awt/Color.html + */ + protected float alpha = 1f; + + /** + * Inner class for creating instances of ColorTypeProperty + */ + public static class Maker extends PropertyMaker { + + /** + * @param propName name of property for which a Maker should be created + */ + public Maker(int propId) { + super(propId); + } + + public Property convertProperty(Property p, + PropertyList propertyList, FObj fo) { + if (p instanceof ColorTypeProperty) { + return p; + } + ColorTypeProperty val = p.getColorType(); + if (val != null) { + return val; + } + return convertPropertyDatatype(p, propertyList, fo); + } + + } + + /** + * Main constructor + * @param red red component + * @param green green component + * @param blue blue component + */ + public ColorTypeProperty(float red, float green, float blue) { + this.red = red; + this.green = green; + this.blue = blue; + } + + /** + * Set the colour given a particular String specifying either a + * colour name or #RGB or #RRGGBB + * @param value RGB value as String to be parsed + */ + public ColorTypeProperty(String value) { + if (value.startsWith("#")) { + try { + if (value.length() == 4) { + // note: divide by 15 so F = FF = 1 and so on + this.red = Integer.parseInt(value.substring(1, 2), 16) + / 15f; + this.green = Integer.parseInt(value.substring(2, 3), 16) + / 15f; + this.blue = Integer.parseInt(value.substring(3), 16) + / 15f; + } else if (value.length() == 7) { + // note: divide by 255 so FF = 1 + this.red = Integer.parseInt(value.substring(1, 3), 16) + / 255f; + this.green = Integer.parseInt(value.substring(3, 5), 16) + / 255f; + this.blue = Integer.parseInt(value.substring(5), 16) + / 255f; + } else { + this.red = 0; + this.green = 0; + this.blue = 0; + //log.error("unknown colour format. Must be #RGB or #RRGGBB"); + } + } catch (Exception e) { + this.red = 0; + this.green = 0; + this.blue = 0; + //log.error("unknown colour format. Must be #RGB or #RRGGBB"); + } + } else if (value.startsWith("rgb(")) { + int poss = value.indexOf("("); + int pose = value.indexOf(")"); + if (poss != -1 && pose != -1) { + value = value.substring(poss + 1, pose); + StringTokenizer st = new StringTokenizer(value, ","); + try { + if (st.hasMoreTokens()) { + String str = st.nextToken().trim(); + if (str.endsWith("%")) { + this.red = + Integer.parseInt(str.substring(0, str.length() - 1)) + * 2.55f; + } else { + this.red = Integer.parseInt(str) / 255f; + } + } + if (st.hasMoreTokens()) { + String str = st.nextToken().trim(); + if (str.endsWith("%")) { + this.green = + Integer.parseInt(str.substring(0, str.length() - 1)) + * 2.55f; + } else { + this.green = Integer.parseInt(str) / 255f; + } + } + if (st.hasMoreTokens()) { + String str = st.nextToken().trim(); + if (str.endsWith("%")) { + this.blue = + Integer.parseInt(str.substring(0, str.length() - 1)) + * 2.55f; + } else { + this.blue = Integer.parseInt(str) / 255f; + } + } + } catch (Exception e) { + this.red = 0; + this.green = 0; + this.blue = 0; + //log.error("unknown colour format. Must be #RGB or #RRGGBB"); + } + } + } else if (value.startsWith("url(")) { + // refers to a gradient + } else { + if (value.toLowerCase().equals("transparent")) { + this.red = 0; + this.green = 0; + this.blue = 0; + this.alpha = 0; + } else { + boolean found = false; + for (int count = 0; count < NAMES.length; count++) { + if (value.toLowerCase().equals(NAMES[count])) { + this.red = VALUES[count][0] / 255f; + this.green = VALUES[count][1] / 255f; + this.blue = VALUES[count][2] / 255f; + found = true; + break; + } + } + if (!found) { + this.red = 0; + this.green = 0; + this.blue = 0; + //log.error("unknown colour name: " + // + value); + } + } + } + } + + /** + * Returns the blue component of the color. + * @return float a value between 0.0 and 1.0 + */ + public float getBlue() { + return this.blue; + } + + /** + * Returns the green component of the color. + * @return float a value between 0.0 and 1.0 + */ + public float getGreen() { + return this.green; + } + + /** + * Returns the red component of the color. + * @return float a value between 0.0 and 1.0 + */ + public float getRed() { + return this.red; + } + + /** + * Returns the alpha (degree of opaque-ness) component of the color. + * @return float a value between 0.0 (fully transparent) and 1.0 (fully opaque) + */ + public float getAlpha() { + return this.alpha; + } + + /** + * Returns an AWT instance of this color + * @return float the AWT color represented by this ColorType instance + */ + public Color getAWTColor() { + return new Color(this.red, this.green, this.blue, this.alpha); + } + + /** + * @param floatValue value (between 0.0 and 1.0) of color channel + * @return integer equivalent (between 0 and 255) + */ + public static int convertChannelToInteger (float floatValue) { + if (floatValue > 1.0) { + floatValue = 1.0f; + } + if (floatValue < 0) { + floatValue = 0; + } + return (int) (floatValue * 255); + } + + /** + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuffer sbuf = new StringBuffer(8); + sbuf.append('#'); + String s = Integer.toHexString((int)(red * 255.0)); + if (s.length() == 1) { + sbuf.append('0'); + } + sbuf.append(s); + s = Integer.toHexString((int)(green * 255.0)); + if (s.length() == 1) { + sbuf.append('0'); + } + sbuf.append(s); + s = Integer.toHexString((int)(blue * 255.0)); + if (s.length() == 1) { + sbuf.append('0'); + } + sbuf.append(s); + return sbuf.toString(); + } + + /** The names of the predefined colors */ + protected static final String[] NAMES = { + "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", + "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", + "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", + "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", + "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", + "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", + "darkorchid", "darkred", "darksalmon", "darkseagreen", + "darkslateblue", "darkslategray", "darkslategrey", "darkturquoise", + "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey", + "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", + "gainsboro", "lightpink", "lightsalmon", "lightseagreen", + "lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue", + "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", + "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", + "mediumseagreen", "mediumslateblue", "mediumspringgreen", + "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", + "mistyrose", "moccasin", "navajowhite", "navy", "oldlace", "olive", + "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", + "palegreen", "paleturquoise", "palevioletred", "papayawhip", + "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "red", + "rosybrown", "royalblue", "saddlebrown", "salmon", "ghostwhite", + "gold", "goldenrod", "gray", "grey", "green", "greenyellow", + "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", + "lavender", "lavenderblush", "lawngreen", "lemonchiffon", + "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow", + "lightgray", "lightgreen", "lightgrey", "sandybrown", "seagreen", + "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", + "slategrey", "snow", "springgreen", "steelblue", "tan", "teal", + "thistle", "tomato", "turquoise", "violet", "wheat", "white", + "whitesmoke", "yellow", "yellowgreen" + }; + + /** The color values for the predefined colors */ + protected static final int[][] VALUES = { + { + 240, 248, 255 + }, { + 250, 235, 215 + }, { + 0, 255, 255 + }, { + 127, 255, 212 + }, { + 240, 255, 255 + }, { + 245, 245, 220 + }, { + 255, 228, 196 + }, { + 0, 0, 0 + }, { + 255, 235, 205 + }, { + 0, 0, 255 + }, { + 138, 43, 226 + }, { + 165, 42, 42 + }, { + 222, 184, 135 + }, { + 95, 158, 160 + }, { + 127, 255, 0 + }, { + 210, 105, 30 + }, { + 255, 127, 80 + }, { + 100, 149, 237 + }, { + 255, 248, 220 + }, { + 220, 20, 60 + }, { + 0, 255, 255 + }, { + 0, 0, 139 + }, { + 0, 139, 139 + }, { + 184, 134, 11 + }, { + 169, 169, 169 + }, { + 0, 100, 0 + }, { + 169, 169, 169 + }, { + 189, 183, 107 + }, { + 139, 0, 139 + }, { + 85, 107, 47 + }, { + 255, 140, 0 + }, { + 153, 50, 204 + }, { + 139, 0, 0 + }, { + 233, 150, 122 + }, { + 143, 188, 143 + }, { + 72, 61, 139 + }, { + 47, 79, 79 + }, { + 47, 79, 79 + }, { + 0, 206, 209 + }, { + 148, 0, 211 + }, { + 255, 20, 147 + }, { + 0, 191, 255 + }, { + 105, 105, 105 + }, { + 105, 105, 105 + }, { + 30, 144, 255 + }, { + 178, 34, 34 + }, { + 255, 250, 240 + }, { + 34, 139, 34 + }, { + 255, 0, 255 + }, { + 220, 220, 220 + }, { + 255, 182, 193 + }, { + 255, 160, 122 + }, { + 32, 178, 170 + }, { + 135, 206, 250 + }, { + 119, 136, 153 + }, { + 119, 136, 153 + }, { + 176, 196, 222 + }, { + 255, 255, 224 + }, { + 0, 255, 0 + }, { + 50, 205, 50 + }, { + 250, 240, 230 + }, { + 255, 0, 255 + }, { + 128, 0, 0 + }, { + 102, 205, 170 + }, { + 0, 0, 205 + }, { + 186, 85, 211 + }, { + 147, 112, 219 + }, { + 60, 179, 113 + }, { + 123, 104, 238 + }, { + 0, 250, 154 + }, { + 72, 209, 204 + }, { + 199, 21, 133 + }, { + 25, 25, 112 + }, { + 245, 255, 250 + }, { + 255, 228, 225 + }, { + 255, 228, 181 + }, { + 255, 222, 173 + }, { + 0, 0, 128 + }, { + 253, 245, 230 + }, { + 128, 128, 0 + }, { + 107, 142, 35 + }, { + 255, 165, 0 + }, { + 255, 69, 0 + }, { + 218, 112, 214 + }, { + 238, 232, 170 + }, { + 152, 251, 152 + }, { + 175, 238, 238 + }, { + 219, 112, 147 + }, { + 255, 239, 213 + }, { + 255, 218, 185 + }, { + 205, 133, 63 + }, { + 255, 192, 203 + }, { + 221, 160, 221 + }, { + 176, 224, 230 + }, { + 128, 0, 128 + }, { + 255, 0, 0 + }, { + 188, 143, 143 + }, { + 65, 105, 225 + }, { + 139, 69, 19 + }, { + 250, 128, 114 + }, { + 248, 248, 255 + }, { + 255, 215, 0 + }, { + 218, 165, 32 + }, { + 128, 128, 128 + }, { + 128, 128, 128 + }, { + 0, 128, 0 + }, { + 173, 255, 47 + }, { + 240, 255, 240 + }, { + 255, 105, 180 + }, { + 205, 92, 92 + }, { + 75, 0, 130 + }, { + 255, 255, 240 + }, { + 240, 230, 140 + }, { + 230, 230, 250 + }, { + 255, 240, 245 + }, { + 124, 252, 0 + }, { + 255, 250, 205 + }, { + 173, 216, 230 + }, { + 240, 128, 128 + }, { + 224, 255, 255 + }, { + 250, 250, 210 + }, { + 211, 211, 211 + }, { + 144, 238, 144 + }, { + 211, 211, 211 + }, { + 244, 164, 96 + }, { + 46, 139, 87 + }, { + 255, 245, 238 + }, { + 160, 82, 45 + }, { + 192, 192, 192 + }, { + 135, 206, 235 + }, { + 106, 90, 205 + }, { + 112, 128, 144 + }, { + 112, 128, 144 + }, { + 255, 250, 250 + }, { + 0, 255, 127 + }, { + 70, 130, 180 + }, { + 210, 180, 140 + }, { + 0, 128, 128 + }, { + 216, 191, 216 + }, { + 255, 99, 71 + }, { + 64, 224, 208 + }, { + 238, 130, 238 + }, { + 245, 222, 179 + }, { + 255, 255, 255 + }, { + 245, 245, 245 + }, { + 255, 255, 0 + }, { + 154, 205, 50 + } + }; + + /* + * aliceblue rgb(240, 248, 255) + * antiquewhite rgb(250, 235, 215) + * aqua rgb( 0, 255, 255) + * aquamarine rgb(127, 255, 212) + * azure rgb(240, 255, 255) + * beige rgb(245, 245, 220) + * bisque rgb(255, 228, 196) + * black rgb( 0, 0, 0) + * blanchedalmond rgb(255, 235, 205) + * blue rgb( 0, 0, 255) + * blueviolet rgb(138, 43, 226) + * brown rgb(165, 42, 42) + * burlywood rgb(222, 184, 135) + * cadetblue rgb( 95, 158, 160) + * chartreuse rgb(127, 255, 0) + * chocolate rgb(210, 105, 30) + * coral rgb(255, 127, 80) + * cornflowerblue rgb(100, 149, 237) + * cornsilk rgb(255, 248, 220) + * crimson rgb(220, 20, 60) + * cyan rgb( 0, 255, 255) + * darkblue rgb( 0, 0, 139) + * darkcyan rgb( 0, 139, 139) + * darkgoldenrod rgb(184, 134, 11) + * darkgray rgb(169, 169, 169) + * darkgreen rgb( 0, 100, 0) + * darkgrey rgb(169, 169, 169) + * darkkhaki rgb(189, 183, 107) + * darkmagenta rgb(139, 0, 139) + * darkolivegreen rgb( 85, 107, 47) + * darkorange rgb(255, 140, 0) + * darkorchid rgb(153, 50, 204) + * darkred rgb(139, 0, 0) + * darksalmon rgb(233, 150, 122) + * darkseagreen rgb(143, 188, 143) + * darkslateblue rgb( 72, 61, 139) + * darkslategray rgb( 47, 79, 79) + * darkslategrey rgb( 47, 79, 79) + * darkturquoise rgb( 0, 206, 209) + * darkviolet rgb(148, 0, 211) + * deeppink rgb(255, 20, 147) + * deepskyblue rgb( 0, 191, 255) + * dimgray rgb(105, 105, 105) + * dimgrey rgb(105, 105, 105) + * dodgerblue rgb( 30, 144, 255) + * firebrick rgb(178, 34, 34) + * floralwhite rgb(255, 250, 240) + * forestgreen rgb( 34, 139, 34) + * fuchsia rgb(255, 0, 255) + * gainsboro rgb(220, 220, 220) + * lightpink rgb(255, 182, 193) + * lightsalmon rgb(255, 160, 122) + * lightseagreen rgb( 32, 178, 170) + * lightskyblue rgb(135, 206, 250) + * lightslategray rgb(119, 136, 153) + * lightslategrey rgb(119, 136, 153) + * lightsteelblue rgb(176, 196, 222) + * lightyellow rgb(255, 255, 224) + * lime rgb( 0, 255, 0) + * limegreen rgb( 50, 205, 50) + * linen rgb(250, 240, 230) + * magenta rgb(255, 0, 255) + * maroon rgb(128, 0, 0) + * mediumaquamarine rgb(102, 205, 170) + * mediumblue rgb( 0, 0, 205) + * mediumorchid rgb(186, 85, 211) + * mediumpurple rgb(147, 112, 219) + * mediumseagreen rgb( 60, 179, 113) + * mediumslateblue rgb(123, 104, 238) + * mediumspringgreen rgb( 0, 250, 154) + * mediumturquoise rgb( 72, 209, 204) + * mediumvioletred rgb(199, 21, 133) + * midnightblue rgb( 25, 25, 112) + * mintcream rgb(245, 255, 250) + * mistyrose rgb(255, 228, 225) + * moccasin rgb(255, 228, 181) + * navajowhite rgb(255, 222, 173) + * navy rgb( 0, 0, 128) + * oldlace rgb(253, 245, 230) + * olive rgb(128, 128, 0) + * olivedrab rgb(107, 142, 35) + * orange rgb(255, 165, 0) + * orangered rgb(255, 69, 0) + * orchid rgb(218, 112, 214) + * palegoldenrod rgb(238, 232, 170) + * palegreen rgb(152, 251, 152) + * paleturquoise rgb(175, 238, 238) + * palevioletred rgb(219, 112, 147) + * papayawhip rgb(255, 239, 213) + * peachpuff rgb(255, 218, 185) + * peru rgb(205, 133, 63) + * pink rgb(255, 192, 203) + * plum rgb(221, 160, 221) + * powderblue rgb(176, 224, 230) + * purple rgb(128, 0, 128) + * red rgb(255, 0, 0) + * rosybrown rgb(188, 143, 143) + * royalblue rgb( 65, 105, 225) + * saddlebrown rgb(139, 69, 19) + * salmon rgb(250, 128, 114) + * ghostwhite rgb(248, 248, 255) + * gold rgb(255, 215, 0) + * goldenrod rgb(218, 165, 32) + * gray rgb(128, 128, 128) + * grey rgb(128, 128, 128) + * green rgb( 0, 128, 0) + * greenyellow rgb(173, 255, 47) + * honeydew rgb(240, 255, 240) + * hotpink rgb(255, 105, 180) + * indianred rgb(205, 92, 92) + * indigo rgb( 75, 0, 130) + * ivory rgb(255, 255, 240) + * khaki rgb(240, 230, 140) + * lavender rgb(230, 230, 250) + * lavenderblush rgb(255, 240, 245) + * lawngreen rgb(124, 252, 0) + * lemonchiffon rgb(255, 250, 205) + * lightblue rgb(173, 216, 230) + * lightcoral rgb(240, 128, 128) + * lightcyan rgb(224, 255, 255) + * lightgoldenrodyellow rgb(250, 250, 210) + * lightgray rgb(211, 211, 211) + * lightgreen rgb(144, 238, 144) + * lightgrey rgb(211, 211, 211) + * sandybrown rgb(244, 164, 96) + * seagreen rgb( 46, 139, 87) + * seashell rgb(255, 245, 238) + * sienna rgb(160, 82, 45) + * silver rgb(192, 192, 192) + * skyblue rgb(135, 206, 235) + * slateblue rgb(106, 90, 205) + * slategray rgb(112, 128, 144) + * slategrey rgb(112, 128, 144) + * snow rgb(255, 250, 250) + * springgreen rgb( 0, 255, 127) + * steelblue rgb( 70, 130, 180) + * tan rgb(210, 180, 140) + * teal rgb( 0, 128, 128) + * thistle rgb(216, 191, 216) + * tomato rgb(255, 99, 71) + * turquoise rgb( 64, 224, 208) + * violet rgb(238, 130, 238) + * wheat rgb(245, 222, 179) + * white rgb(255, 255, 255) + * whitesmoke rgb(245, 245, 245) + * yellow rgb(255, 255, 0) + * yellowgreen rgb(154, 205, 50) + */ + + /** + * Can't convert to any other types + * @return this.colorType + */ + public ColorTypeProperty getColorType() { + return this; + } + + /** + * @return this.colorType cast as an Object + */ + public Object getObject() { + return this; + } +} + diff --git a/src/java/org/apache/fop/fo/properties/CommonBorderAndPadding.java b/src/java/org/apache/fop/fo/properties/CommonBorderAndPadding.java index aa72ad6de..80ff56d61 100644 --- a/src/java/org/apache/fop/fo/properties/CommonBorderAndPadding.java +++ b/src/java/org/apache/fop/fo/properties/CommonBorderAndPadding.java @@ -52,7 +52,6 @@ package org.apache.fop.fo.properties; import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.CondLengthProperty; /** * Stores all common border and padding properties. diff --git a/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java b/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java index 9a1168072..96cc148e7 100644 --- a/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java @@ -53,9 +53,7 @@ package org.apache.fop.fo.properties; import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.CompoundDatatype; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.EnumProperty; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.Property; import org.apache.fop.fo.PropertyList; /** diff --git a/src/java/org/apache/fop/fo/properties/CondLengthProperty.java b/src/java/org/apache/fop/fo/properties/CondLengthProperty.java new file mode 100644 index 000000000..6eca74439 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/CondLengthProperty.java @@ -0,0 +1,184 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.CompoundDatatype; +import org.apache.fop.fo.Constants; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; + +/** + * Superclass for properties that have conditional lengths + */ +public class CondLengthProperty extends Property implements CompoundDatatype { + private Property length; + private Property conditionality; + + /** + * Inner class for creating instances of CondLengthProperty + */ + public static class Maker extends CompoundPropertyMaker { + + /** + * @param name of property for which a Maker should be created + */ + public Maker(int propId) { + super(propId); + } + + /** + * Create a new empty instance of CondLengthProperty. + * @return the new instance. + */ + public Property makeNewProperty() { + return new CondLengthProperty(); + } + + /** + * @see CompoundPropertyMaker#convertProperty + */ + public Property convertProperty(Property p, PropertyList propertyList, FObj fo) + throws FOPException + { + if (p instanceof KeepProperty) { + return p; + } + return super.convertProperty(p, propertyList, fo); + } + } + + /** + * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean) + */ + public void setComponent(int cmpId, Property cmpnValue, + boolean bIsDefault) { + if (cmpId == CP_LENGTH) { + length = cmpnValue; + } else if (cmpId == CP_CONDITIONALITY) { + conditionality = cmpnValue; + } + } + + /** + * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) + */ + public Property getComponent(int cmpId) { + if (cmpId == CP_LENGTH) { + return length; + } else if (cmpId == CP_CONDITIONALITY) { + return conditionality; + } else { + return null; + } + } + + /** + * Returns the conditionality. + * @return the conditionality + */ + public Property getConditionality() { + return this.conditionality; + } + + /** + * Returns the length. + * @return the length + */ + public Property getLengthComponent() { + return this.length; + } + + /** + * Indicates if the length can be discarded on certain conditions. + * @return true if the length can be discarded. + */ + public boolean isDiscard() { + return this.conditionality.getEnum() == Constants.DISCARD; + } + + /** + * Returns the computed length value. + * @return the length in millipoints + */ + public int getLengthValue() { + return this.length.getLength().getValue(); + } + + public String toString() { + return "CondLength[" + (isDiscard() ? "discard, " : "") + + length.getObject().toString() + "]"; + } + + + /** + * @return this.condLength + */ + public CondLengthProperty getCondLength() { + return this; + } + + /** + * TODO: Should we allow this? + * @return this.condLength cast as a Length + */ + public LengthProperty getLength() { + return length.getLength(); + } + + /** + * @return this.condLength cast as an Object + */ + public Object getObject() { + return this; + } + +} diff --git a/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java b/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java index 568e3a599..6852b77ae 100644 --- a/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java @@ -52,7 +52,6 @@ package org.apache.fop.fo.properties; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.Property; import org.apache.fop.fo.PropertyList; /** diff --git a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java index c1c324cde..50d03ea20 100644 --- a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java @@ -52,7 +52,6 @@ package org.apache.fop.fo.properties; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.Property; import org.apache.fop.fo.PropertyList; /** diff --git a/src/java/org/apache/fop/fo/properties/EnumProperty.java b/src/java/org/apache/fop/fo/properties/EnumProperty.java new file mode 100644 index 000000000..600cd8cb0 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/EnumProperty.java @@ -0,0 +1,126 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; + +/** + * Superclass for properties that wrap an enumeration value + */ +public class EnumProperty extends Property { + + /** + * Inner class for creating EnumProperty instances + */ + public static class Maker extends PropertyMaker { + + /** + * @param propName name of property for which a Maker should be created + */ + public Maker(int propId) { + super(propId); + } + + /** + * Called by subclass if no match found. + * @param value string containing the value to be checked + * @return null (indicates that an appropriate match was not found) + */ + public Property checkEnumValues(String value) { + //log.error("Unknown enumerated value for property '" + // + getPropName() + "': " + value); + return super.checkEnumValues(value); + } + + protected Property findConstant(String value) { + return null; + } + + public Property convertProperty(Property p, + PropertyList propertyList, + FObj fo) throws FOPException { + if (p instanceof EnumProperty) { + return p; + } else { + return super.convertProperty(p, propertyList, fo); + } + } + } + + private int value; + + /** + * @param explicitValue enumerated value to be set for this property + */ + public EnumProperty(int explicitValue) { + this.value = explicitValue; + } + + /** + * @return this.value + */ + public int getEnum() { + return this.value; + } + + /** + * @return this.value cast as an Object + */ + public Object getObject() { + // TODO return String value: property must reference maker + // return maker.getEnumValue(this.value); + return new Integer(this.value); + } + +} + diff --git a/src/java/org/apache/fop/fo/properties/FixedLength.java b/src/java/org/apache/fop/fo/properties/FixedLength.java new file mode 100644 index 000000000..c6f2a4b1d --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/FixedLength.java @@ -0,0 +1,127 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.fo.expr.NumericProperty; + +/** + * a length quantity in XSL + */ +public class FixedLength extends LengthProperty { + + /** + * Set the length given + * @param numRelUnits the number of relative units + * @param iCurFontSize the current font size in base units. + */ + public FixedLength(double numRelUnits, int iCurFontSize) { + setComputedValue((int)(numRelUnits * (double)iCurFontSize)); + } + + /** + * Set the length given a number of units and a unit name. + * @param numUnits quantity of input units + * @param units input unit specifier (in, cm, etc.) + */ + public FixedLength(double numUnits, String units) { + convert(numUnits, units); + } + + /** + * @param baseUnits the length as a number of base units (millipoints) + */ + public FixedLength(int baseUnits) { + setComputedValue(baseUnits); + } + + /** + * Convert the given length to a dimensionless integer representing + * a whole number of base units (milli-points). + * @param dvalue quantity of input units + * @param unit input unit specifier (in, cm, etc.) + */ + protected void convert(double dvalue, String unit) { + + int assumedResolution = 1; // points/pixel + + if (unit.equals("in")) { + dvalue = dvalue * 72; + } else if (unit.equals("cm")) { + dvalue = dvalue * 28.3464567; + } else if (unit.equals("mm")) { + dvalue = dvalue * 2.83464567; + } else if (unit.equals("pt")) { + // Do nothing. + // dvalue = dvalue; + } else if (unit.equals("pc")) { + dvalue = dvalue * 12; + /* + * } else if (unit.equals("em")) { + * dvalue = dvalue * fontsize; + */ + } else if (unit.equals("px")) { + dvalue = dvalue * assumedResolution; + } else { + dvalue = 0; + //log.error("unknown length unit '" + unit + // + "'"); + } + setComputedValue((int)(dvalue * 1000)); + } + + /** + * @return Numeric equivalent of this + */ + public NumericProperty asNumeric() { + return new NumericProperty(this); + } +} + diff --git a/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java b/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java index 7a19e784e..80344e2b2 100644 --- a/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java @@ -51,9 +51,7 @@ package org.apache.fop.fo.properties; import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.FixedLength; import org.apache.fop.fo.FOPropertyMapping; -import org.apache.fop.fo.Property; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.NumericProperty; diff --git a/src/java/org/apache/fop/fo/properties/KeepProperty.java b/src/java/org/apache/fop/fo/properties/KeepProperty.java new file mode 100644 index 000000000..fb34f7de3 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/KeepProperty.java @@ -0,0 +1,199 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.CompoundDatatype; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; + +/** + * Superclass for properties that wrap Keep values + */ +public class KeepProperty extends Property implements CompoundDatatype { + private Property withinLine; + private Property withinColumn; + private Property withinPage; + + /** + * Inner class for creating instances of KeepProperty + */ + public static class Maker extends CompoundPropertyMaker { + + /** + * @param name name of property for which Maker should be created + */ + public Maker(int propId) { + super(propId); + } + + /** + * Create a new empty instance of KeepProperty. + * @return the new instance. + */ + public Property makeNewProperty() { + return new KeepProperty(); + } + + /** + * @see CompoundPropertyMaker#convertProperty + */ + public Property convertProperty(Property p, PropertyList propertyList, FObj fo) + throws FOPException + { + if (p instanceof KeepProperty) { + return p; + } + return super.convertProperty(p, propertyList, fo); + } + } + + /** + * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean) + */ + public void setComponent(int cmpId, Property cmpnValue, + boolean bIsDefault) { + if (cmpId == CP_WITHIN_LINE) { + setWithinLine(cmpnValue, bIsDefault); + } else if (cmpId == CP_WITHIN_COLUMN) { + setWithinColumn(cmpnValue, bIsDefault); + } else if (cmpId == CP_WITHIN_PAGE) { + setWithinPage(cmpnValue, bIsDefault); + } + } + + /** + * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) + */ + public Property getComponent(int cmpId) { + if (cmpId == CP_WITHIN_LINE) { + return getWithinLine(); + } else if (cmpId == CP_WITHIN_COLUMN) { + return getWithinColumn(); + } else if (cmpId == CP_WITHIN_PAGE) { + return getWithinPage(); + } else { + return null; + } + } + + /** + * @param withinLine withinLine property to set + * @param bIsDefault not used (??) + */ + public void setWithinLine(Property withinLine, boolean bIsDefault) { + this.withinLine = withinLine; + } + + /** + * @param withinColumn withinColumn property to set + * @param bIsDefault not used (??) + */ + protected void setWithinColumn(Property withinColumn, + boolean bIsDefault) { + this.withinColumn = withinColumn; + } + + /** + * @param withinPage withinPage property to set + * @param bIsDefault not used (??) + */ + public void setWithinPage(Property withinPage, boolean bIsDefault) { + this.withinPage = withinPage; + } + + /** + * @return the withinLine property + */ + public Property getWithinLine() { + return this.withinLine; + } + + /** + * @return the withinColumn property + */ + public Property getWithinColumn() { + return this.withinColumn; + } + + /** + * @return the withinPage property + */ + public Property getWithinPage() { + return this.withinPage; + } + + /** + * Not sure what to do here. There isn't really a meaningful single value. + * @return String representation + */ + public String toString() { + return "Keep[" + + "withinLine:" + getWithinLine().getObject() + + ", withinColumn:" + getWithinColumn().getObject() + + ", withinPage:" + getWithinPage().getObject() + "]"; + } + + /** + * @return this.keep + */ + public KeepProperty getKeep() { + return this; + } + + /** + * @return this.keep cast as Object + */ + public Object getObject() { + return this; + } + +} diff --git a/src/java/org/apache/fop/fo/properties/LengthPairProperty.java b/src/java/org/apache/fop/fo/properties/LengthPairProperty.java new file mode 100644 index 000000000..861346b3d --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/LengthPairProperty.java @@ -0,0 +1,157 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.CompoundDatatype; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; + +/** + * Superclass for properties wrapping a LengthPair value + */ +public class LengthPairProperty extends Property implements CompoundDatatype { + private Property ipd; + private Property bpd; + + /** + * Inner class for creating instances of LengthPairProperty + */ + public static class Maker extends CompoundPropertyMaker { + + /** + * @param name name of property for which this Maker should be created + */ + public Maker(int propId) { + super(propId); + } + + /** + * Create a new empty instance of LengthPairProperty. + * @return the new instance. + */ + public Property makeNewProperty() { + return new LengthPairProperty(); + } + + /** + * @see CompoundPropertyMaker#convertProperty + */ + public Property convertProperty(Property p, PropertyList propertyList, FObj fo) + throws FOPException + { + if (p instanceof LengthPairProperty) { + return p; + } + return super.convertProperty(p, propertyList, fo); + } + } + + /** + * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean) + */ + public void setComponent(int cmpId, Property cmpnValue, + boolean bIsDefault) { + if (cmpId == CP_BLOCK_PROGRESSION_DIRECTION) { + bpd = cmpnValue; + } else if (cmpId == CP_INLINE_PROGRESSION_DIRECTION) { + ipd = cmpnValue; + } + } + + /** + * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) + */ + public Property getComponent(int cmpId) { + if (cmpId == CP_BLOCK_PROGRESSION_DIRECTION) { + return getBPD(); + } else if (cmpId == CP_INLINE_PROGRESSION_DIRECTION) { + return getIPD(); + } else { + return null; // SHOULDN'T HAPPEN + } + } + + /** + * @return Property holding the ipd length + */ + public Property getIPD() { + return this.ipd; + } + + /** + * @return Property holding the bpd length + */ + public Property getBPD() { + return this.bpd; + } + + public String toString() { + return "LengthPair[" + + "ipd:" + getIPD().getObject() + + ", bpd:" + getBPD().getObject() + "]"; + } + + /** + * @return this.lengthPair + */ + public LengthPairProperty getLengthPair() { + return this; + } + + /** + * @return this.lengthPair cast as an Object + */ + public Object getObject() { + return this; + } + +} diff --git a/src/java/org/apache/fop/fo/properties/LengthProperty.java b/src/java/org/apache/fop/fo/properties/LengthProperty.java new file mode 100644 index 000000000..2588f6f64 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/LengthProperty.java @@ -0,0 +1,242 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.Length; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; +import org.apache.fop.fo.expr.NumericProperty; + +/** + * Superclass for properties wrapping a Length value. + */ +public class LengthProperty extends Property implements Length { + /** Holds the length in millipoints. */ + protected int millipoints = 0; + /** Indicates if the value has been computed, or not. */ + protected boolean bIsComputed = false; + + /** + * Inner class for making instances of LengthProperty + */ + public static class Maker extends PropertyMaker { + private boolean autoOk = false; + + /** + * @param name name of property for which Maker should be created + */ + public Maker(int propId) { + super(propId); + } + + /** + * protected Property checkPropertyKeywords(String value) { + * if (isAutoLengthAllowed() && value.equals("auto")) { + * return new LengthProperty(Length.AUTO); + * } + * return null; + * } + */ + + /** + * @return false (auto-length is not allowed for Length values) + */ + protected boolean isAutoLengthAllowed() { + return autoOk; + } + + /** + * Set the auto length flag. + * @param inherited + */ + public void setAutoOk(boolean autoOk) { + this.autoOk = autoOk; + } + + /** + * @see Property.Maker#convertProperty + */ + public Property convertProperty(Property p, + PropertyList propertyList, + FObj fo) throws FOPException { + Property prop = super.convertProperty(p, propertyList, fo); + if (prop != null) { + return prop; + } + if (isAutoLengthAllowed()) { + String pval = p.getString(); + if (pval != null && pval.equals("auto")) { + return new AutoLength(); + } + } + if (p instanceof LengthProperty) { + return p; + } + LengthProperty val = p.getLength(); + if (val != null) { + return val; + } + return convertPropertyDatatype(p, propertyList, fo); + } + + } + + + /** + * Returns the length in 1/1000ths of a point (millipoints) + * @return the length in millipoints + */ + public int getValue() { + if (!bIsComputed) { + computeValue(); + } + return millipoints; + } + + /** + * Computes the value. + */ + protected void computeValue() { + } + + + /** + * Sets the computed value. + * @param millipoints the length in millipoints + */ + protected void setComputedValue(int millipoints) { + setComputedValue(millipoints, true); + } + + /** + * Sets the computed value. + * @param millipoints the length in millipoints + * @param bSetComputed True if the isComputed flag should be set. + */ + protected void setComputedValue(int millipoints, boolean bSetComputed) { + this.millipoints = millipoints; + this.bIsComputed = bSetComputed; + } + + /** + * Indicates if the length has the "auto" value. + * @return True if the length is set to "auto" + */ + public boolean isAuto() { + return false; + } + + /** + * Indicates if the length has been computed. + * @return True if the length has been computed + */ + public boolean isComputed() { + return this.bIsComputed; + } + + /** + * Return the number of table units which are included in this + * length specification. + * This will always be 0 unless the property specification used + * the proportional-column-width() function (only only table + * column FOs). + *

If this value is not 0, the actual value of the Length cannot + * be known without looking at all of the columns in the table to + * determine the value of a "table-unit". + * @return The number of table units which are included in this + * length specification. + */ + public double getTableUnits() { + return 0.0; + } + + public void resolveTableUnit(double dTableUnit) { + } + + /** + * @return null (cannot be converted to a Numeric ??) + */ + public NumericProperty asNumeric() { + return null; + } + + /** + * @see java.lang.Object#toString() + */ + public String toString() { + String s = millipoints + "mpt"; + return s; + } + + /** + * @return this.lenght cast as a Numeric + */ + public NumericProperty getNumeric() { + return asNumeric() ; + } + + /** + * @return this.length + */ + public LengthProperty getLength() { + return this; + } + + /** + * @return this.length cast as an Object + */ + public Object getObject() { + return this; + } + +} + diff --git a/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java b/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java new file mode 100644 index 000000000..3907d0f99 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java @@ -0,0 +1,279 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.CompoundDatatype; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; + +/** + * Superclass for properties that contain LengthRange values + */ +public class LengthRangeProperty extends Property implements CompoundDatatype { + private Property minimum; + private Property optimum; + private Property maximum; + private static final int MINSET = 1; + private static final int OPTSET = 2; + private static final int MAXSET = 4; + private int bfSet = 0; // bit field + private boolean bChecked = false; + + /** + * Inner class for a Maker for LengthProperty objects + */ + public static class Maker extends CompoundPropertyMaker { + + /** + * @param name name of property for which to create Maker + */ + public Maker(int propId) { + super(propId); + } + + /** + * Create a new empty instance of LengthRangeProperty. + * @return the new instance. + */ + public Property makeNewProperty() { + return new LengthRangeProperty(); + } + + /** + * @see CompoundPropertyMaker#convertProperty + */ + public Property convertProperty(Property p, PropertyList propertyList, FObj fo) + throws FOPException + { + if (p instanceof LengthRangeProperty) { + return p; + } + return super.convertProperty(p, propertyList, fo); + } + } + + + + /** + * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean) + */ + public void setComponent(int cmpId, Property cmpnValue, + boolean bIsDefault) { + if (cmpId == CP_MINIMUM) { + setMinimum(cmpnValue, bIsDefault); + } else if (cmpId == CP_OPTIMUM) { + setOptimum(cmpnValue, bIsDefault); + } else if (cmpId == CP_MAXIMUM) { + setMaximum(cmpnValue, bIsDefault); + } + } + + /** + * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) + */ + public Property getComponent(int cmpId) { + if (cmpId == CP_MINIMUM) { + return getMinimum(); + } else if (cmpId == CP_OPTIMUM) { + return getOptimum(); + } else if (cmpId == CP_MAXIMUM) { + return getMaximum(); + } else { + return null; // SHOULDN'T HAPPEN + } + } + + /** + * Set minimum value to min. + * @param minimum A Length value specifying the minimum value for this + * LengthRange. + * @param bIsDefault If true, this is set as a "default" value + * and not a user-specified explicit value. + */ + protected void setMinimum(Property minimum, boolean bIsDefault) { + this.minimum = minimum; + if (!bIsDefault) { + bfSet |= MINSET; + } + } + + + /** + * Set maximum value to max if it is >= optimum or optimum isn't set. + * @param max A Length value specifying the maximum value for this + * @param bIsDefault If true, this is set as a "default" value + * and not a user-specified explicit value. + */ + protected void setMaximum(Property max, boolean bIsDefault) { + maximum = max; + if (!bIsDefault) { + bfSet |= MAXSET; + } + } + + + /** + * Set the optimum value. + * @param opt A Length value specifying the optimum value for this + * @param bIsDefault If true, this is set as a "default" value + * and not a user-specified explicit value. + */ + protected void setOptimum(Property opt, boolean bIsDefault) { + optimum = opt; + if (!bIsDefault) { + bfSet |= OPTSET; + } + } + + // Minimum is prioritaire, if explicit + private void checkConsistency() { + if (bChecked) { + return; + } + // Make sure max >= min + // Must also control if have any allowed enum values! + + /** + * ******************* + * if (minimum.mvalue() > maximum.mvalue()) { + * if ((bfSet&MINSET)!=0) { + * // if minimum is explicit, force max to min + * if ((bfSet&MAXSET)!=0) { + * // Warning: min>max, resetting max to min + * log.error("forcing max to min in LengthRange"); + * } + * maximum = minimum ; + * } + * else { + * minimum = maximum; // minimum was default value + * } + * } + * // Now make sure opt <= max and opt >= min + * if (optimum.mvalue() > maximum.mvalue()) { + * if ((bfSet&OPTSET)!=0) { + * if ((bfSet&MAXSET)!=0) { + * // Warning: opt > max, resetting opt to max + * log.error("forcing opt to max in LengthRange"); + * optimum = maximum ; + * } + * else { + * maximum = optimum; // maximum was default value + * } + * } + * else { + * // opt is default and max is explicit or default + * optimum = maximum ; + * } + * } + * else if (optimum.mvalue() < minimum.mvalue()) { + * if ((bfSet&MINSET)!=0) { + * // if minimum is explicit, force opt to min + * if ((bfSet&OPTSET)!=0) { + * log.error("forcing opt to min in LengthRange"); + * } + * optimum = minimum ; + * } + * else { + * minimum = optimum; // minimum was default value + * } + * } + * *******$******* + */ + bChecked = true; + } + + /** + * @return minimum length + */ + public Property getMinimum() { + checkConsistency(); + return this.minimum; + } + + /** + * @return maximum length + */ + public Property getMaximum() { + checkConsistency(); + return this.maximum; + } + + /** + * @return optimum length + */ + public Property getOptimum() { + checkConsistency(); + return this.optimum; + } + + public String toString() { + return "LengthRange[" + + "min:" + getMinimum().getObject() + + ", max:" + getMaximum().getObject() + + ", opt:" + getOptimum().getObject() + "]"; + } + + /** + * @return this.lengthRange + */ + public LengthRangeProperty getLengthRange() { + return this; + } + + /** + * @return this.lengthRange cast as an Object + */ + public Object getObject() { + return this; + } + +} diff --git a/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java b/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java index b5bf98a76..743786194 100644 --- a/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java @@ -51,10 +51,7 @@ package org.apache.fop.fo.properties; import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.PercentLength; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.Property; import org.apache.fop.fo.PropertyList; /** diff --git a/src/java/org/apache/fop/fo/properties/LinearCombinationLength.java b/src/java/org/apache/fop/fo/properties/LinearCombinationLength.java new file mode 100644 index 000000000..898bf45ee --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/LinearCombinationLength.java @@ -0,0 +1,99 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import java.util.Vector; + +import org.apache.fop.datatypes.Length; + +/** + * Class modelling lengths that are build up by combining other lengths + */ +public class LinearCombinationLength extends LengthProperty { + + /** Collection of factors (1-1 correspondence with {@link #lengths} */ + protected Vector factors; + /** Collection of Length objects (1-1 correspondence with {@link #factors} */ + protected Vector lengths; + + /** + * Constructor. Creates no content. Use {link #addTerm} to build content. + */ + public LinearCombinationLength() { + factors = new Vector(); + lengths = new Vector(); + } + + /** + * Add an item to this + * @param factor the factor to be added + * @param length the Length to be added + */ + public void addTerm(double factor, LengthProperty length) { + factors.addElement(new Double(factor)); + lengths.addElement(length); + } + + /** + * Sets the computed value in millipoints. + */ + protected void 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)).getValue()); + } + setComputedValue(result); + } + +} diff --git a/src/java/org/apache/fop/fo/properties/ListProperty.java b/src/java/org/apache/fop/fo/properties/ListProperty.java new file mode 100644 index 000000000..7ed6ac0f4 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/ListProperty.java @@ -0,0 +1,122 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import java.util.Vector; + +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; + +/** + * Superclass for properties that are lists of other properties + */ +public class ListProperty extends Property { + + /** + * Inner class for creating instances of ListProperty + */ + public static class Maker extends PropertyMaker { + + /** + * @param name name of property for which Maker should be created + */ + public Maker(int propId) { + super(propId); + } + + /** + * @see Property.Maker#convertProperty + */ + public Property convertProperty(Property p, + PropertyList propertyList, FObj fo) { + if (p instanceof ListProperty) { + return p; + } else { + return new ListProperty(p); + } + } + + } + + /** Vector containing the list of sub-properties */ + protected Vector list; + + /** + * @param prop the first Property to be added to the list + */ + public ListProperty(Property prop) { + list = new Vector(); + list.addElement(prop); + } + + /** + * Add a new property to the list + * @param prop Property to be added to the list + */ + public void addProperty(Property prop) { + list.addElement(prop); + } + + /** + * @return this.list + */ + public Vector getList() { + return list; + } + + /** + * @return this.list cast as an Object + */ + public Object getObject() { + return list; + } + +} diff --git a/src/java/org/apache/fop/fo/properties/MixedLength.java b/src/java/org/apache/fop/fo/properties/MixedLength.java new file mode 100644 index 000000000..971991121 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/MixedLength.java @@ -0,0 +1,150 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import java.util.Enumeration; +import java.util.Vector; + +import org.apache.fop.fo.expr.NumericProperty; +import org.apache.fop.fo.expr.PropertyException; + +/** + * A length quantity in XSL which is specified with a mixture + * of absolute and relative and/or percent components. + * The actual value may not be computable before layout is done. + */ +public class MixedLength extends LengthProperty { + + /** The collection of Length objects comprising this MixedLength object */ + private Vector lengths ; + + /** + * Constructor + * @param lengths the collection of Length objects which comprise the new + * MixedLength object + */ + public MixedLength(Vector lengths) { + this.lengths = lengths; + } + + /** + * Iterates through each internal component, computing and + * summarizing the values, then setting the value for this + */ + protected void computeValue() { + int computedValue = 0; + boolean bAllComputed = true; + Enumeration e = lengths.elements(); + while (e.hasMoreElements()) { + LengthProperty l = (LengthProperty) e.nextElement(); + computedValue += l.getValue(); + if (!l.isComputed()) { + bAllComputed = false; + } + } + setComputedValue(computedValue, bAllComputed); + } + + + public double getTableUnits() { + double tableUnits = 0.0; + Enumeration e = lengths.elements(); + while (e.hasMoreElements()) { + tableUnits += ((LengthProperty) e.nextElement()).getTableUnits(); + } + return tableUnits; + } + + public void resolveTableUnit(double dTableUnit) { + Enumeration e = lengths.elements(); + while (e.hasMoreElements()) { + ((LengthProperty) e.nextElement()).resolveTableUnit(dTableUnit); + } + } + + /** + * @return String equivalent of this + */ + public String toString() { + StringBuffer sbuf = new StringBuffer(); + Enumeration e = lengths.elements(); + while (e.hasMoreElements()) { + if (sbuf.length() > 0) { + sbuf.append('+'); + } + sbuf.append(e.nextElement().toString()); + } + return sbuf.toString(); + } + + /** + * @return Numeric equivalent of this + */ + public NumericProperty asNumeric() { + NumericProperty numeric = null; + for (Enumeration e = lengths.elements(); e.hasMoreElements();) { + LengthProperty l = (LengthProperty) e.nextElement(); + if (numeric == null) { + numeric = l.asNumeric(); + } else { + try { + NumericProperty sum = numeric.add(l.asNumeric()); + numeric = sum; + } catch (PropertyException pe) { + System.err.println( + "Can't convert MixedLength to Numeric: " + pe); + } + } + } + return numeric; + } +} + diff --git a/src/java/org/apache/fop/fo/properties/NumberProperty.java b/src/java/org/apache/fop/fo/properties/NumberProperty.java new file mode 100644 index 000000000..cccb86ddf --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/NumberProperty.java @@ -0,0 +1,159 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; +import org.apache.fop.fo.expr.NumericProperty; + +/** + * Class for handling numeric properties + */ +public class NumberProperty extends Property { + + /** + * Inner class for making NumberProperty objects + */ + public static class Maker extends PropertyMaker { + + /** + * Constructor for NumberProperty.Maker + * @param propName the name of the property + */ + public Maker(int propId) { + super(propId); + } + + /** + * @see Property.Maker#convertProperty + */ + public Property convertProperty(Property p, + PropertyList propertyList, FObj fo) { + if (p instanceof NumberProperty) { + return p; + } + Number val = p.getNumber(); + if (val != null) { + return new NumberProperty(val); + } + return convertPropertyDatatype(p, propertyList, fo); + } + + } + + private Number number; + + /** + * Constructor for Number input + * @param num Number object value for property + */ + public NumberProperty(Number num) { + this.number = num; + } + + /** + * Constructor for double input + * @param num double numeric value for property + */ + public NumberProperty(double num) { + this.number = new Double(num); + } + + /** + * Constructor for integer input + * @param num integer numeric value for property + */ + public NumberProperty(int num) { + this.number = new Integer(num); + } + + /** + * @return this.number cast as a Number + */ + public Number getNumber() { + return this.number; + } + + /** + * public Double getDouble() { + * return new Double(this.number.doubleValue()); + * } + * public Integer getInteger() { + * return new Integer(this.number.intValue()); + * } + */ + + /** + * @return this.number cast as an Object + */ + public Object getObject() { + return this.number; + } + + /** + * Convert NumberProperty to Numeric object + * @return Numeric object corresponding to this + */ + public NumericProperty getNumeric() { + return new NumericProperty(this.number); + } + + /** + * Convert NumberProperty to a ColorType. Not sure why this is needed. + * @return ColorType that corresponds to black + */ + public ColorTypeProperty getColorType() { + // Convert numeric value to color ??? + // Convert to hexadecimal and then try to make it into a color? + return new ColorTypeProperty((float)0.0, (float)0.0, (float)0.0); + } + +} diff --git a/src/java/org/apache/fop/fo/properties/PercentLength.java b/src/java/org/apache/fop/fo/properties/PercentLength.java new file mode 100644 index 000000000..7d58df8d2 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/PercentLength.java @@ -0,0 +1,140 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.datatypes.PercentBase; +import org.apache.fop.fo.expr.NumericProperty; + +/** + * a percent specified length quantity in XSL + */ +public class PercentLength extends LengthProperty { + + /** + * The percentage itself, expressed as a decimal value, e.g. for 95%, set + * the value to .95 + */ + private double factor; + + /** + * A PercentBase implementation that contains the base length to which the + * {@link #factor} should be applied to compute the actual length + */ + private PercentBase lbase = null; + + /** + * Main constructor. Construct an object based on a factor (the percent, + * as a factor) and an object which has a method to return the Length which + * provides the "base" for the actual length that is modeled. + * @param factor the percentage factor, expressed as a decimal (e.g. use + * .95 to represent 95%) + * @param lbase base property to which the factor should be applied + */ + public PercentLength(double factor, PercentBase lbase) { + this.factor = factor; + this.lbase = lbase; + } + + /** + * Convenience constructor when only the factor is known + * @param factor the percentage factor, expressed as a decimal (e.g. use + * .95 to represent 95%) + */ + public PercentLength(double factor) { + this(factor, null); + } + + /** + * @param lbase the base to set + */ + public void setBaseLength(PercentBase lbase) { + this.lbase = lbase; + } + + /** + * @return the base + */ + public PercentBase getBaseLength() { + return this.lbase; + } + + /** + * Return the computed value in millipoints. This assumes that the + * base length has been resolved to an absolute length value. + */ + protected void computeValue() { + setComputedValue((int)(factor * (double)lbase.getBaseLength())); + } + + /** + * + * @return the factor + */ + public double value() { + return factor; + } + + /** + * @return the String equivalent of this + */ + public String toString() { + // TODO: What about the base value? + return (new Double(factor * 100.0).toString()) + "%"; + } + + /** + * @return new Numeric object that is equivalent to this + */ + public NumericProperty asNumeric() { + return new NumericProperty(this); + } + +} diff --git a/src/java/org/apache/fop/fo/properties/Property.java b/src/java/org/apache/fop/fo/properties/Property.java new file mode 100644 index 000000000..855f60a00 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/Property.java @@ -0,0 +1,217 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.fo.expr.NumericProperty; + +import java.util.Vector; + +/** + * Base class for all property objects + * @author unascribed + */ +public class Property { + + /** + * The original specified value for properties which inherit + * specified values. + */ + private String specVal; + + /** + * Set the original value specified for the property attribute. + * @param specVal The specified value. + */ + public void setSpecifiedValue(String specVal) { + this.specVal = specVal; + } + + /** + * Return the original value specified for the property attribute. + * @return The specified value as a String. + */ + public String getSpecifiedValue() { + return specVal; + } + +/* + * This section contains accessor functions for all possible Property datatypes + */ + + + /** + * This method expects to be overridden by subclasses + * @return Length property value + */ + public LengthProperty getLength() { + return null; + } + + /** + * This method expects to be overridden by subclasses + * @return ColorType property value + */ + public ColorTypeProperty getColorType() { + return null; + } + + /** + * This method expects to be overridden by subclasses + * @return CondLength property value + */ + public CondLengthProperty getCondLength() { + return null; + } + + /** + * This method expects to be overridden by subclasses + * @return LenghtRange property value + */ + public LengthRangeProperty getLengthRange() { + return null; + } + + /** + * This method expects to be overridden by subclasses + * @return LengthPair property value + */ + public LengthPairProperty getLengthPair() { + return null; + } + + /** + * This method expects to be overridden by subclasses + * @return Space property value + */ + public SpaceProperty getSpace() { + return null; + } + + /** + * This method expects to be overridden by subclasses + * @return Keep property value + */ + public KeepProperty getKeep() { + return null; + } + + /** + * This method expects to be overridden by subclasses + * @return integer equivalent of enumerated property value + */ + public int getEnum() { + return 0; + } + + /** + * This method expects to be overridden by subclasses + * @return char property value + */ + public char getCharacter() { + return 0; + } + + /** + * This method expects to be overridden by subclasses + * @return collection of other property (sub-property) objects + */ + public Vector getList() { + return null; + } + + /** + * This method expects to be overridden by subclasses + * @return Number property value + */ + public Number getNumber() { + return null; + } + + /** + * This method expects to be overridden by subclasses + * @return Numeric property value + */ + public NumericProperty getNumeric() { + return null; + } + + /** + * This method expects to be overridden by subclasses + * @return NCname property value + */ + public String getNCname() { + return null; + } + + /** + * This method expects to be overridden by subclasses + * @return Object property value + */ + public Object getObject() { + return null; + } + + /** + * This method expects to be overridden by subclasses. + * @return String property value + */ + public String getString() { + return null; + } + + /** + * Return a string representation of the property value. Only used + * for debugging. + */ + public String toString() { + return getString(); + } +} diff --git a/src/java/org/apache/fop/fo/properties/PropertyMaker.java b/src/java/org/apache/fop/fo/properties/PropertyMaker.java index 77465a58b..0c130b190 100644 --- a/src/java/org/apache/fop/fo/properties/PropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/PropertyMaker.java @@ -59,8 +59,6 @@ import org.apache.fop.datatypes.LengthBase; import org.apache.fop.datatypes.PercentBase; import org.apache.fop.fo.FOPropertyMapping; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.ListProperty; -import org.apache.fop.fo.Property; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ShorthandParser; import org.apache.fop.fo.expr.PropertyInfo; diff --git a/src/java/org/apache/fop/fo/properties/SpaceProperty.java b/src/java/org/apache/fop/fo/properties/SpaceProperty.java new file mode 100644 index 000000000..c67e8042a --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/SpaceProperty.java @@ -0,0 +1,192 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; + +/** + * Base class used for handling properties of the fo:space-before and + * fo:space-after variety. It is extended by org.apache.fop.fo.properties.GenericSpace, + * which is extended by many other properties. + */ +public class SpaceProperty extends LengthRangeProperty { + private Property precedence; + private Property conditionality; + + /** + * Inner class used to create new instances of SpaceProperty + */ + public static class Maker extends CompoundPropertyMaker { + + /** + * @param name name of the property whose Maker is to be created + */ + public Maker(int propId) { + super(propId); + } + + /** + * Create a new empty instance of SpaceProperty. + * @return the new instance. + */ + public Property makeNewProperty() { + return new SpaceProperty(); + } + + /** + * @see CompoundPropertyMaker#convertProperty + */ + public Property convertProperty(Property p, + PropertyList propertyList, + FObj fo) throws FOPException { + if (p instanceof SpaceProperty) { + return p; + } + return super.convertProperty(p, propertyList, fo); + } + } + + + + /** + * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean) + */ + public void setComponent(int cmpId, Property cmpnValue, + boolean bIsDefault) { + if (cmpId == CP_PRECEDENCE) { + setPrecedence(cmpnValue, bIsDefault); + } else if (cmpId == CP_CONDITIONALITY) { + setConditionality(cmpnValue, bIsDefault); + } else { + super.setComponent(cmpId, cmpnValue, bIsDefault); + } + } + + /** + * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) + */ + public Property getComponent(int cmpId) { + if (cmpId == CP_PRECEDENCE) { + return getPrecedence(); + } else if (cmpId == CP_CONDITIONALITY) { + return getConditionality(); + } else { + return super.getComponent(cmpId); + } + } + + /** + * + * @param precedence precedence Property to set + * @param bIsDefault (is not used anywhere) + */ + protected void setPrecedence(Property precedence, boolean bIsDefault) { + this.precedence = precedence; + } + + /** + * + * @param conditionality conditionality Property to set + * @param bIsDefault (is not used anywhere) + */ + protected void setConditionality(Property conditionality, + boolean bIsDefault) { + this.conditionality = conditionality; + } + + /** + * @return precedence Property + */ + public Property getPrecedence() { + return this.precedence; + } + + /** + * @return conditionality Property + */ + public Property getConditionality() { + return this.conditionality; + } + + public String toString() { + return "Space[" + + "min:" + getMinimum().getObject() + + ", max:" + getMaximum().getObject() + + ", opt:" + getOptimum().getObject() + + ", precedence:" + precedence.getObject() + + ", conditionality:" + conditionality.getObject() + "]"; + } + + /** + * @return the Space (datatype) object contained here + */ + public SpaceProperty getSpace() { + return this; + } + + /** + * Space extends LengthRange. + * @return the Space (datatype) object contained here + */ + public LengthRangeProperty getLengthRange() { + return this; + } + + /** + * @return the Space (datatype) object contained here + */ + public Object getObject() { + return this; + } + +} diff --git a/src/java/org/apache/fop/fo/properties/StringProperty.java b/src/java/org/apache/fop/fo/properties/StringProperty.java new file mode 100644 index 000000000..5ba630957 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/StringProperty.java @@ -0,0 +1,135 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; + +/** + * Exists primarily as a container for its Maker inner class, which is + * extended by many string-based FO property classes. + */ +public class StringProperty extends Property { + + /** + * Inner class for making instances of StringProperty + */ + public static class Maker extends PropertyMaker { + + /** + * @param propName name of property for which to create a Maker + */ + public Maker(int propId) { + super(propId); + } + + /** + * Make a new StringProperty object + * @param propertyList not used + * @param value String value of the new object + * @param fo not used + * @return the StringProperty object + */ + public Property make(PropertyList propertyList, String value, + FObj fo) { + // Work around the fact that most String properties are not + // specified as actual String literals (with "" or '') since + // the attribute values themselves are Strings! + // If the value starts with ' or ", make sure it also ends with + // this character + // Otherwise, just take the whole value as the String + int vlen = value.length() - 1; + if (vlen > 0) { + char q1 = value.charAt(0); + if (q1 == '"' || q1 == '\'') { + if (value.charAt(vlen) == q1) { + return new StringProperty(value.substring(1, vlen)); + } + System.err.println("Warning String-valued property starts with quote" + + " but doesn't end with quote: " + + value); + // fall through and use the entire value, including first quote + } + String str = checkValueKeywords(value); + if (str != null) { + value = str; + } + } + return new StringProperty(value); + } + + } // end String.Maker + + private String str; + + /** + * @param str String value to place in this object + */ + public StringProperty(String str) { + this.str = str; + // System.err.println("Set StringProperty: " + str); + } + + /** + * @return the Object equivalent of this property + */ + public Object getObject() { + return this.str; + } + + /** + * @return the String equivalent of this property + */ + public String getString() { + return this.str; + } + +} diff --git a/src/java/org/apache/fop/fo/properties/TableColLength.java b/src/java/org/apache/fop/fo/properties/TableColLength.java new file mode 100644 index 000000000..752fea6a0 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/TableColLength.java @@ -0,0 +1,121 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.fo.expr.NumericProperty; + +/** + * A table-column width specification, possibly including some + * number of proportional "column-units". The absolute size of a + * column-unit depends on the fixed and proportional sizes of all + * columns in the table, and on the overall size of the table. + * It can't be calculated until all columns have been specified and until + * the actual width of the table is known. Since this can be specified + * as a percent of its parent containing width, the calculation is done + * during layout. + * NOTE: this is only supposed to be allowed if table-layout=fixed. + */ +public class TableColLength extends LengthProperty { + + /** + * Number of table-column proportional units + */ + private double tcolUnits; + + /** + * Construct an object with tcolUnits of proportional measure. + * @param tcolUnits number of table-column proportional units + */ + public TableColLength(double tcolUnits) { + this.tcolUnits = tcolUnits; + } + + /** + * Override the method in Length + * @return the number of specified proportional table-column units. + */ + public double getTableUnits() { + return tcolUnits; + } + + /** + * Calculate the number of millipoints and set it. + * @param mpointsPerUnit density of millipoints per unit + */ + public void resolveTableUnit(double mpointsPerUnit) { + setComputedValue((int)(tcolUnits * mpointsPerUnit)); + } + + //If the table-unit can be resolved, set the computed value + /*protected void computeValue() { + if (tblUnitBase.canResolveUnit()) { + rslt += (int)(tcolUnits * (double)tblUnitBase.getUnitValue()); + setComputedValue(rslt); + } + }*/ + + /** + * Convert this to a String + * @return the string representation of this + */ + public String toString() { + return (Double.toString(tcolUnits) + " table-column-units"); + } + + /** + * Converts this to a new Numeric object + * @return the Numeric object + */ + public NumericProperty asNumeric() { + return new NumericProperty(this); + } +} + diff --git a/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java b/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java new file mode 100644 index 000000000..77db03940 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java @@ -0,0 +1,91 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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 . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fo.properties; + +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; + +public class ToBeImplementedProperty extends Property { + + public static class Maker extends PropertyMaker { + + public Maker(int propId) { + super(propId); + } + + public Property convertProperty(Property p, + PropertyList propertyList, FObj fo) { + if (p instanceof ToBeImplementedProperty) { + return p; + } + + ToBeImplementedProperty val = + new ToBeImplementedProperty(getPropId()); + return val; + } + } + + /** + * Constructor + * @param propName name of Property + */ + public ToBeImplementedProperty(int propId) { + + //XXX: (mjg@recalldesign.com) This is a bit of a kluge, perhaps an + //UnimplementedPropertyException or something similar should + //get thrown here instead. + +// Logger log = Hierarchy.getDefaultHierarchy().getLoggerFor("fop"); +// log.warn("property - \"" + propName +// + "\" is not implemented yet."); + } +} + diff --git a/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java b/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java index 5b153127a..abfacc217 100644 --- a/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/ListAttributesConverter.java @@ -52,9 +52,9 @@ package org.apache.fop.render.rtf; //FOP import org.apache.fop.apps.FOPException; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.LengthProperty; import org.apache.fop.fo.PropertyList; +import org.apache.fop.fo.properties.LengthProperty; +import org.apache.fop.fo.properties.Property; //RTF import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; diff --git a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java index 994aacfaa..9c2b85139 100644 --- a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java @@ -58,7 +58,7 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.fo.Constants; import org.apache.fop.fo.pagination.Region; import org.apache.fop.fo.pagination.SimplePageMaster; -import org.apache.fop.fo.Property; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.PropertyList; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfPage; diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java index 72250b650..68894c3c0 100644 --- a/src/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java @@ -59,10 +59,8 @@ import java.util.Iterator; import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.avalon.framework.logger.Logger; import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.EnumProperty; import org.apache.fop.fo.FOInputHandler; import org.apache.fop.fo.FObj; -import org.apache.fop.datatypes.FixedLength; import org.apache.fop.fo.flow.BasicLink; import org.apache.fop.fo.flow.Block; import org.apache.fop.fo.flow.ExternalGraphic; @@ -84,11 +82,13 @@ import org.apache.fop.fo.flow.TableRow; import org.apache.fop.fo.pagination.Flow; import org.apache.fop.fo.pagination.PageSequence; import org.apache.fop.fo.pagination.SimplePageMaster; +import org.apache.fop.fo.properties.EnumProperty; +import org.apache.fop.fo.properties.FixedLength; +import org.apache.fop.fo.properties.LengthProperty; +import org.apache.fop.fo.properties.Property; +import org.apache.fop.fo.properties.StringProperty; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FOText; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.StringProperty; import org.apache.fop.apps.Document; import org.apache.fop.render.rtf.rtflib.rtfdoc.ITableAttributes; import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfAfterContainer; diff --git a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java index e7aef684e..57f260c12 100644 --- a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java @@ -57,15 +57,15 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.BorderAttributesConverter; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.EnumProperty; import org.apache.fop.fo.expr.NCnameProperty; +import org.apache.fop.fo.properties.ColorTypeProperty; +import org.apache.fop.fo.properties.EnumProperty; +import org.apache.fop.fo.properties.LengthProperty; +import org.apache.fop.fo.properties.ListProperty; +import org.apache.fop.fo.properties.NumberProperty; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.ListProperty; import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.ColorTypeProperty; -import org.apache.fop.fo.NumberProperty; import org.apache.fop.datatypes.ColorType; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java index d7f7f0d5c..ea26c60d1 100644 --- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java @@ -54,12 +54,12 @@ package org.apache.fop.render.rtf; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.EnumProperty; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.LengthProperty; import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.SpaceProperty; -import org.apache.fop.fo.ColorTypeProperty; +import org.apache.fop.fo.properties.ColorTypeProperty; +import org.apache.fop.fo.properties.EnumProperty; +import org.apache.fop.fo.properties.LengthProperty; +import org.apache.fop.fo.properties.SpaceProperty; import org.apache.fop.datatypes.ColorType; //RTF diff --git a/src/java/org/apache/fop/traits/SpaceVal.java b/src/java/org/apache/fop/traits/SpaceVal.java index b15e8cb49..561721761 100644 --- a/src/java/org/apache/fop/traits/SpaceVal.java +++ b/src/java/org/apache/fop/traits/SpaceVal.java @@ -50,9 +50,9 @@ */ package org.apache.fop.traits; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.SpaceProperty; import org.apache.fop.fo.Constants; +import org.apache.fop.fo.properties.Property; +import org.apache.fop.fo.properties.SpaceProperty; /** * Store a single Space property value in simplified form, with all