aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/fo/expr
diff options
context:
space:
mode:
authorTore Engvig <tore@apache.org>2001-07-30 20:29:35 +0000
committerTore Engvig <tore@apache.org>2001-07-30 20:29:35 +0000
commite0edd215721150e6c04ac49706622d6189cb0b42 (patch)
tree6b59b872d9c0e93f99316ea2f421209b71a97755 /src/org/apache/fop/fo/expr
parenteb57915dec9bcd907e495595efac60dbf3579ad8 (diff)
downloadxmlgraphics-fop-e0edd215721150e6c04ac49706622d6189cb0b42.tar.gz
xmlgraphics-fop-e0edd215721150e6c04ac49706622d6189cb0b42.zip
Formatted code according to code standards.
Changed license to use short license. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194380 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/fo/expr')
-rw-r--r--src/org/apache/fop/fo/expr/AbsFunction.java77
-rw-r--r--src/org/apache/fop/fo/expr/BodyStartFunction.java90
-rw-r--r--src/org/apache/fop/fo/expr/CeilingFunction.java75
-rw-r--r--src/org/apache/fop/fo/expr/FloorFunction.java75
-rw-r--r--src/org/apache/fop/fo/expr/FopPropValFunction.java78
-rw-r--r--src/org/apache/fop/fo/expr/FromParentFunction.java91
-rw-r--r--src/org/apache/fop/fo/expr/FromTableColumnFunction.java76
-rw-r--r--src/org/apache/fop/fo/expr/Function.java63
-rw-r--r--src/org/apache/fop/fo/expr/FunctionBase.java75
-rw-r--r--src/org/apache/fop/fo/expr/InheritedPropFunction.java76
-rw-r--r--src/org/apache/fop/fo/expr/LabelEndFunction.java112
-rw-r--r--src/org/apache/fop/fo/expr/MaxFunction.java80
-rw-r--r--src/org/apache/fop/fo/expr/MinFunction.java79
-rw-r--r--src/org/apache/fop/fo/expr/NCnameProperty.java89
-rw-r--r--src/org/apache/fop/fo/expr/NearestSpecPropFunction.java80
-rw-r--r--src/org/apache/fop/fo/expr/Numeric.java665
-rw-r--r--src/org/apache/fop/fo/expr/NumericProperty.java95
-rw-r--r--src/org/apache/fop/fo/expr/PPColWidthFunction.java84
-rw-r--r--src/org/apache/fop/fo/expr/PropertyException.java62
-rw-r--r--src/org/apache/fop/fo/expr/PropertyInfo.java166
-rw-r--r--src/org/apache/fop/fo/expr/PropertyParser.java858
-rw-r--r--src/org/apache/fop/fo/expr/PropertyTokenizer.java660
-rw-r--r--src/org/apache/fop/fo/expr/RGBColorFunction.java132
-rw-r--r--src/org/apache/fop/fo/expr/RoundFunction.java83
24 files changed, 1522 insertions, 2499 deletions
diff --git a/src/org/apache/fop/fo/expr/AbsFunction.java b/src/org/apache/fop/fo/expr/AbsFunction.java
index 578aaffca..7a40c9d39 100644
--- a/src/org/apache/fop/fo/expr/AbsFunction.java
+++ b/src/org/apache/fop/fo/expr/AbsFunction.java
@@ -1,69 +1,28 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
public class AbsFunction extends FunctionBase {
- public int nbArgs() { return 1; }
+ public int nbArgs() {
+ return 1;
+ }
+
+ public Property eval(Property[] args,
+ PropertyInfo propInfo) throws PropertyException {
+ Numeric num = args[0].getNumeric();
+ if (num == null)
+ throw new PropertyException("Non numeric operand to abs function");
+ // What if has relative composants (percent, table-col units)?
+ return new NumericProperty(num.abs());
+ }
- public Property eval(Property[] args, PropertyInfo propInfo)
- throws PropertyException
- {
- Numeric num = args[0].getNumeric();
- if (num == null)
- throw new PropertyException("Non numeric operand to abs function");
- // What if has relative composants (percent, table-col units)?
- return new NumericProperty(num.abs());
- }
}
diff --git a/src/org/apache/fop/fo/expr/BodyStartFunction.java b/src/org/apache/fop/fo/expr/BodyStartFunction.java
index 56a3a1fb4..41c47ee55 100644
--- a/src/org/apache/fop/fo/expr/BodyStartFunction.java
+++ b/src/org/apache/fop/fo/expr/BodyStartFunction.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
@@ -56,24 +13,27 @@ import org.apache.fop.fo.flow.ListItem;
public class BodyStartFunction extends FunctionBase {
- public int nbArgs() { return 0; }
+ public int nbArgs() {
+ return 0;
+ }
+
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ Numeric distance =
+ pInfo.getPropertyList().get("provisional-distance-between-starts").getNumeric();
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- Numeric distance
- = pInfo.getPropertyList().get("provisional-distance-between-starts").getNumeric();
+ FObj item = pInfo.getFO();
+ while (item != null &&!(item instanceof ListItem)) {
+ item = item.getParent();
+ }
+ if (item == null) {
+ throw new PropertyException("body-start() called from outside an fo:list-item");
+ }
- FObj item = pInfo.getFO();
- while(item != null && !(item instanceof ListItem)) {
- item = item.getParent();
- }
- if(item == null) {
- throw new PropertyException("body-start() called from outside an fo:list-item");
+ Numeric startIndent =
+ item.properties.get("start-indent").getNumeric();
+
+ return new NumericProperty(distance.add(startIndent));
}
- Numeric startIndent = item.properties.get("start-indent").getNumeric();
-
- return new NumericProperty(distance.add(startIndent));
- }
}
diff --git a/src/org/apache/fop/fo/expr/CeilingFunction.java b/src/org/apache/fop/fo/expr/CeilingFunction.java
index 5812b53a0..9f4200415 100644
--- a/src/org/apache/fop/fo/expr/CeilingFunction.java
+++ b/src/org/apache/fop/fo/expr/CeilingFunction.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
@@ -55,14 +12,16 @@ import org.apache.fop.fo.NumberProperty;
class CeilingFunction extends FunctionBase {
- public int nbArgs() { return 1; }
+ public int nbArgs() {
+ return 1;
+ }
+
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ Number dbl = args[0].getNumber();
+ if (dbl == null)
+ throw new PropertyException("Non number operand to ceiling function");
+ return new NumberProperty(Math.ceil(dbl.doubleValue()));
+ }
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- Number dbl = args[0].getNumber();
- if (dbl == null)
- throw new PropertyException("Non number operand to ceiling function");
- return new NumberProperty(Math.ceil(dbl.doubleValue()));
- }
}
diff --git a/src/org/apache/fop/fo/expr/FloorFunction.java b/src/org/apache/fop/fo/expr/FloorFunction.java
index f9055db72..868067bd7 100644
--- a/src/org/apache/fop/fo/expr/FloorFunction.java
+++ b/src/org/apache/fop/fo/expr/FloorFunction.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
@@ -56,14 +13,16 @@ import org.apache.fop.fo.NumberProperty;
class FloorFunction extends FunctionBase {
- public int nbArgs() { return 1; }
+ public int nbArgs() {
+ return 1;
+ }
+
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ Number dbl = args[0].getNumber();
+ if (dbl == null)
+ throw new PropertyException("Non number operand to floor function");
+ return new NumberProperty(Math.floor(dbl.doubleValue()));
+ }
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- Number dbl = args[0].getNumber();
- if (dbl == null)
- throw new PropertyException("Non number operand to floor function");
- return new NumberProperty(Math.floor(dbl.doubleValue()));
- }
}
diff --git a/src/org/apache/fop/fo/expr/FopPropValFunction.java b/src/org/apache/fop/fo/expr/FopPropValFunction.java
index 72fd8856d..b89719014 100644
--- a/src/org/apache/fop/fo/expr/FopPropValFunction.java
+++ b/src/org/apache/fop/fo/expr/FopPropValFunction.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
@@ -58,17 +15,18 @@ import org.apache.fop.fo.Property;
*/
public class FopPropValFunction extends FunctionBase {
- public int nbArgs() { return 1; }
+ public int nbArgs() {
+ return 1;
+ }
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- String propName = args[0].getString();
- if (propName == null) {
- throw new PropertyException("Incorrect parameter to _int-property-value function");
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ String propName = args[0].getString();
+ if (propName == null) {
+ throw new PropertyException("Incorrect parameter to _int-property-value function");
+ }
+ // System.err.println("Get property-value for " + propName);
+ return pInfo.getPropertyList().get(propName);
}
- // System.err.println("Get property-value for " + propName);
- return pInfo.getPropertyList().get( propName);
- }
-}
+}
diff --git a/src/org/apache/fop/fo/expr/FromParentFunction.java b/src/org/apache/fop/fo/expr/FromParentFunction.java
index 4c66b4ffa..26c90c981 100644
--- a/src/org/apache/fop/fo/expr/FromParentFunction.java
+++ b/src/org/apache/fop/fo/expr/FromParentFunction.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
@@ -55,23 +12,25 @@ import org.apache.fop.fo.Property;
public class FromParentFunction extends FunctionBase {
- public int nbArgs() { return 1; }
+ public int nbArgs() {
+ return 1;
+ }
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- String propName = args[0].getString();
- if (propName == null) {
- throw new PropertyException("Incorrect parameter to from-parent function");
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ String propName = args[0].getString();
+ if (propName == null) {
+ throw new PropertyException("Incorrect parameter to from-parent function");
+ }
+ // NOTE: special cases for shorthand property
+ // Should return COMPUTED VALUE
+ /*
+ * For now, this is the same as inherited-property-value(propName)
+ * (The only difference I can see is that this could work for
+ * non-inherited properties too. Perhaps the result is different for
+ * a property line line-height which "inherits specified"???
+ */
+ return pInfo.getPropertyList().getFromParent(propName);
}
- // NOTE: special cases for shorthand property
- // Should return COMPUTED VALUE
- /* For now, this is the same as inherited-property-value(propName)
- * (The only difference I can see is that this could work for
- * non-inherited properties too. Perhaps the result is different for
- * a property line line-height which "inherits specified"???
- */
- return pInfo.getPropertyList().getFromParent( propName);
- }
-}
+}
diff --git a/src/org/apache/fop/fo/expr/FromTableColumnFunction.java b/src/org/apache/fop/fo/expr/FromTableColumnFunction.java
index cd37b6a52..e164a2d8a 100644
--- a/src/org/apache/fop/fo/expr/FromTableColumnFunction.java
+++ b/src/org/apache/fop/fo/expr/FromTableColumnFunction.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
@@ -55,16 +12,17 @@ import org.apache.fop.fo.Property;
public class FromTableColumnFunction extends FunctionBase {
- public int nbArgs() { return 1; }
+ public int nbArgs() {
+ return 1;
+ }
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- String propName = args[0].getString();
- if (propName == null) {
- throw new PropertyException("Incorrect parameter to from-table-column function");
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ String propName = args[0].getString();
+ if (propName == null) {
+ throw new PropertyException("Incorrect parameter to from-table-column function");
+ }
+ throw new PropertyException("from-table-column unimplemented!");
}
- throw new PropertyException("from-table-column unimplemented!");
- }
-}
+}
diff --git a/src/org/apache/fop/fo/expr/Function.java b/src/org/apache/fop/fo/expr/Function.java
index d0aba74f9..b2d0c04ec 100644
--- a/src/org/apache/fop/fo/expr/Function.java
+++ b/src/org/apache/fop/fo/expr/Function.java
@@ -1,62 +1,19 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
import org.apache.fop.datatypes.PercentBase;
public interface Function {
- int nbArgs() ;
- PercentBase getPercentBase();
- Property eval(Property[] args, PropertyInfo propInfo)
- throws PropertyException;
+ int nbArgs();
+ PercentBase getPercentBase();
+ Property eval(Property[] args,
+ PropertyInfo propInfo) throws PropertyException;
}
diff --git a/src/org/apache/fop/fo/expr/FunctionBase.java b/src/org/apache/fop/fo/expr/FunctionBase.java
index e14bf3eea..2ebf76ef5 100644
--- a/src/org/apache/fop/fo/expr/FunctionBase.java
+++ b/src/org/apache/fop/fo/expr/FunctionBase.java
@@ -1,69 +1,28 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
import org.apache.fop.datatypes.PercentBase;
public abstract class FunctionBase implements Function {
- // abstract int nbArgs() ;
+ // abstract int nbArgs() ;
- /**
- * By default, functions have no percent-based arguments.
- */
- public PercentBase getPercentBase() { return null; }
+ /**
+ * By default, functions have no percent-based arguments.
+ */
+ public PercentBase getPercentBase() {
+ return null;
+ }
- /*
- abstract Property eval(Property[] args, PropertyInfo propInfo)
- throws PropertyException;
- */
+ /*
+ * abstract Property eval(Property[] args, PropertyInfo propInfo)
+ * throws PropertyException;
+ */
}
diff --git a/src/org/apache/fop/fo/expr/InheritedPropFunction.java b/src/org/apache/fop/fo/expr/InheritedPropFunction.java
index 8b708e5fb..f00eacb19 100644
--- a/src/org/apache/fop/fo/expr/InheritedPropFunction.java
+++ b/src/org/apache/fop/fo/expr/InheritedPropFunction.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
@@ -55,16 +12,17 @@ import org.apache.fop.fo.Property;
public class InheritedPropFunction extends FunctionBase {
- public int nbArgs() { return 1; }
+ public int nbArgs() {
+ return 1;
+ }
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- String propName = args[0].getString();
- if (propName == null) {
- throw new PropertyException("Incorrect parameter to inherited-property-value function");
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ String propName = args[0].getString();
+ if (propName == null) {
+ throw new PropertyException("Incorrect parameter to inherited-property-value function");
+ }
+ return pInfo.getPropertyList().getInherited(propName);
}
- return pInfo.getPropertyList().getInherited(propName);
- }
-}
+}
diff --git a/src/org/apache/fop/fo/expr/LabelEndFunction.java b/src/org/apache/fop/fo/expr/LabelEndFunction.java
index 6ab37cec7..46ec29160 100644
--- a/src/org/apache/fop/fo/expr/LabelEndFunction.java
+++ b/src/org/apache/fop/fo/expr/LabelEndFunction.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.datatypes.*;
@@ -58,39 +15,40 @@ import org.apache.fop.fo.flow.ListItem;
public class LabelEndFunction extends FunctionBase {
- public int nbArgs() { return 0; }
+ public int nbArgs() {
+ return 0;
+ }
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException {
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
- Length distance
- = pInfo.getPropertyList()
- .get("provisional-distance-between-starts").getLength();
- Length separation
- = pInfo.getPropertyList()
- .getNearestSpecified("provisional-label-separation").getLength();
+ Length distance =
+ pInfo.getPropertyList().get("provisional-distance-between-starts").getLength();
+ Length separation =
+ pInfo.getPropertyList().getNearestSpecified("provisional-label-separation").getLength();
- FObj item = pInfo.getFO();
- while(item != null && !(item instanceof ListItem)) {
- item = item.getParent();
- }
- if(item == null) {
- throw new PropertyException("label-end() called from outside an fo:list-item");
- }
- Length startIndent = item.properties.get("start-indent").getLength();
-
- LinearCombinationLength labelEnd = new LinearCombinationLength();
+ FObj item = pInfo.getFO();
+ while (item != null &&!(item instanceof ListItem)) {
+ item = item.getParent();
+ }
+ if (item == null) {
+ throw new PropertyException("label-end() called from outside an fo:list-item");
+ }
+ Length startIndent = item.properties.get("start-indent").getLength();
- // Should be CONTAINING_REFAREA but that doesn't work
- LengthBase base = new LengthBase(item, pInfo.getPropertyList(),
- LengthBase.CONTAINING_BOX);
- PercentLength refWidth = new PercentLength(1.0, base);
+ LinearCombinationLength labelEnd = new LinearCombinationLength();
- labelEnd.addTerm(1.0, refWidth);
- labelEnd.addTerm(-1.0, distance);
- labelEnd.addTerm(-1.0, startIndent);
- labelEnd.addTerm(1.0, separation);
+ // Should be CONTAINING_REFAREA but that doesn't work
+ LengthBase base = new LengthBase(item, pInfo.getPropertyList(),
+ LengthBase.CONTAINING_BOX);
+ PercentLength refWidth = new PercentLength(1.0, base);
- return new LengthProperty(labelEnd);
+ labelEnd.addTerm(1.0, refWidth);
+ labelEnd.addTerm(-1.0, distance);
+ labelEnd.addTerm(-1.0, startIndent);
+ labelEnd.addTerm(1.0, separation);
+
+ return new LengthProperty(labelEnd);
}
+
}
diff --git a/src/org/apache/fop/fo/expr/MaxFunction.java b/src/org/apache/fop/fo/expr/MaxFunction.java
index 2a986aee7..1a145a567 100644
--- a/src/org/apache/fop/fo/expr/MaxFunction.java
+++ b/src/org/apache/fop/fo/expr/MaxFunction.java
@@ -1,70 +1,28 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
public class MaxFunction extends FunctionBase {
- public int nbArgs() { return 2; }
+ public int nbArgs() {
+ return 2;
+ }
- // Handle "numerics" if no proportional/percent parts!
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- Numeric n1 = args[0].getNumeric();
- Numeric n2 = args[1].getNumeric();
- if (n1 == null || n2 == null)
- throw new PropertyException("Non numeric operands to max function");
- return new NumericProperty(n1.max(n2));
- }
+ // Handle "numerics" if no proportional/percent parts!
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ Numeric n1 = args[0].getNumeric();
+ Numeric n2 = args[1].getNumeric();
+ if (n1 == null || n2 == null)
+ throw new PropertyException("Non numeric operands to max function");
+ return new NumericProperty(n1.max(n2));
+ }
-}
+}
diff --git a/src/org/apache/fop/fo/expr/MinFunction.java b/src/org/apache/fop/fo/expr/MinFunction.java
index 05643b225..4691e7588 100644
--- a/src/org/apache/fop/fo/expr/MinFunction.java
+++ b/src/org/apache/fop/fo/expr/MinFunction.java
@@ -1,69 +1,28 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
public class MinFunction extends FunctionBase {
- public int nbArgs() { return 2; }
+ public int nbArgs() {
+ return 2;
+ }
- // Handle "numerics" if no proportional/percent parts!
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException {
- Numeric n1 = args[0].getNumeric();
- Numeric n2 = args[1].getNumeric();
- if (n1 == null || n2 == null)
- throw new PropertyException("Non numeric operands to min function");
- return new NumericProperty(n1.min(n2));
- }
+ // Handle "numerics" if no proportional/percent parts!
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ Numeric n1 = args[0].getNumeric();
+ Numeric n2 = args[1].getNumeric();
+ if (n1 == null || n2 == null)
+ throw new PropertyException("Non numeric operands to min function");
+ return new NumericProperty(n1.min(n2));
+ }
-}
+}
diff --git a/src/org/apache/fop/fo/expr/NCnameProperty.java b/src/org/apache/fop/fo/expr/NCnameProperty.java
index abfcbcf85..aa2b64325 100644
--- a/src/org/apache/fop/fo/expr/NCnameProperty.java
+++ b/src/org/apache/fop/fo/expr/NCnameProperty.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
@@ -55,26 +12,26 @@ import org.apache.fop.datatypes.ColorType;
public class NCnameProperty extends Property {
- private final String ncName;
+ private final String ncName;
- public NCnameProperty(String ncName) {
- this.ncName = ncName;
- }
+ public NCnameProperty(String ncName) {
+ this.ncName = ncName;
+ }
- public ColorType getColor() throws PropertyException {
- // If a system color, return the corresponding value
- throw new PropertyException("Not a Color");
- }
+ public ColorType getColor() throws PropertyException {
+ // If a system color, return the corresponding value
+ throw new PropertyException("Not a Color");
+ }
- /**
- * Return the name as a String (should be specified with quotes!)
- */
- public String getString() {
- return this.ncName;
- }
+ /**
+ * Return the name as a String (should be specified with quotes!)
+ */
+ public String getString() {
+ return this.ncName;
+ }
- public String getNCname() {
- return this.ncName;
- }
+ public String getNCname() {
+ return this.ncName;
+ }
}
diff --git a/src/org/apache/fop/fo/expr/NearestSpecPropFunction.java b/src/org/apache/fop/fo/expr/NearestSpecPropFunction.java
index 0c62b346f..d4be00503 100644
--- a/src/org/apache/fop/fo/expr/NearestSpecPropFunction.java
+++ b/src/org/apache/fop/fo/expr/NearestSpecPropFunction.java
@@ -1,71 +1,29 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
public class NearestSpecPropFunction extends FunctionBase {
- public int nbArgs() { return 1; }
+ public int nbArgs() {
+ return 1;
+ }
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- String propName = args[0].getString();
- if (propName == null) {
- throw new PropertyException("Incorrect parameter to from-nearest-specified-value function");
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ String propName = args[0].getString();
+ if (propName == null) {
+ throw new PropertyException("Incorrect parameter to from-nearest-specified-value function");
+ }
+ // NOTE: special cases for shorthand property
+ // Should return COMPUTED VALUE
+ return pInfo.getPropertyList().getNearestSpecified(propName);
}
- // NOTE: special cases for shorthand property
- // Should return COMPUTED VALUE
- return pInfo.getPropertyList().getNearestSpecified(propName);
- }
-}
+}
diff --git a/src/org/apache/fop/fo/expr/Numeric.java b/src/org/apache/fop/fo/expr/Numeric.java
index f13ccbc76..845327bff 100644
--- a/src/org/apache/fop/fo/expr/Numeric.java
+++ b/src/org/apache/fop/fo/expr/Numeric.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
@@ -71,336 +28,342 @@ import org.apache.fop.datatypes.PercentBase;
* It supports basic arithmetic operations involving Numerics.
*/
public class Numeric {
- // Bit fields
- public static final int ABS_LENGTH = 1; // abs units (or number)
- public static final int PC_LENGTH=2; // Percentage
- public static final int TCOL_LENGTH=4; // Table units
-
- private int valType ;
- private double absValue ;
- private double pcValue ;
- private PercentBase pcBase=null; // base value for PC_LENGTH component
- private double tcolValue;
- private int dim;
-
-
- /**
- * Construct a Numeric object by specifying one or more components,
- * including absolute length, percent length, table units.
- * @param valType A combination of bits representing the value types.
- * @param absValue The value of a Number or resolved Length value if
- * the ABS_LENGTH flag is set.
- * @param pcValue The decimal percent value if the PC_LENGTH flag is set
- * @param tcolValue The decimal table unit value if the TCOL_LENGTH flag
- * is set.
- * @param dim The dimension of the value. 0 for a Number, 1 for a Length
- * (any type), >1, <0 if Lengths have been multiplied or divided.
- * @pcBase The PercentBase object used to calculate an actual value for
- * a PC_LENGTH.
- */
- protected Numeric(int valType, double absValue,
- double pcValue, double tcolValue, int dim,
- PercentBase pcBase) {
- this.valType = valType;
- this.absValue = absValue;
- this.pcValue = pcValue;
- this.tcolValue = tcolValue;
- this.dim = dim;
- this.pcBase = pcBase;
- }
-
- /**
- * Construct a Numeric object of dimension 0 from a double.
- * @param valType A combination of bits representing the value types.
- * @param absValue The value of a Number or resolved Length value.
- */
- /***
- protected Numeric(int valType, double absValue) {
- this.valType = valType;
- this.absValue = absValue;
- }
- ***/
+ // Bit fields
+ public static final int ABS_LENGTH = 1; // abs units (or number)
+ public static final int PC_LENGTH = 2; // Percentage
+ public static final int TCOL_LENGTH = 4; // Table units
- /**
- * Construct a Numeric object from a Number.
- * @param num The number.
- */
- public Numeric(Number num) {
- this(ABS_LENGTH, num.doubleValue(), 0.0, 0.0, 0, null);
- }
+ private int valType;
+ private double absValue;
+ private double pcValue;
+ private PercentBase pcBase = null; // base value for PC_LENGTH component
+ private double tcolValue;
+ private int dim;
- /**
- * Construct a Numeric object from a Length.
- * @param l The Length.
- */
- public Numeric(Length l) {
- this(ABS_LENGTH, (double)l.mvalue(), 0.0, 0.0, 1, null);
- }
- /**
- * Construct a Numeric object from a PercentLength.
- * @param pclen The PercentLength.
- */
- public Numeric(PercentLength pclen) {
- this(PC_LENGTH, 0.0, pclen.value(), 0.0, 1, pclen.getBaseLength());
- }
+ /**
+ * Construct a Numeric object by specifying one or more components,
+ * including absolute length, percent length, table units.
+ * @param valType A combination of bits representing the value types.
+ * @param absValue The value of a Number or resolved Length value if
+ * the ABS_LENGTH flag is set.
+ * @param pcValue The decimal percent value if the PC_LENGTH flag is set
+ * @param tcolValue The decimal table unit value if the TCOL_LENGTH flag
+ * is set.
+ * @param dim The dimension of the value. 0 for a Number, 1 for a Length
+ * (any type), >1, <0 if Lengths have been multiplied or divided.
+ * @pcBase The PercentBase object used to calculate an actual value for
+ * a PC_LENGTH.
+ */
+ protected Numeric(int valType, double absValue, double pcValue,
+ double tcolValue, int dim, PercentBase pcBase) {
+ this.valType = valType;
+ this.absValue = absValue;
+ this.pcValue = pcValue;
+ this.tcolValue = tcolValue;
+ this.dim = dim;
+ this.pcBase = pcBase;
+ }
- /**
- * Construct a Numeric object from a TableColLength.
- * @param tclen The TableColLength.
- */
- public Numeric(TableColLength tclen) {
- this(TCOL_LENGTH, 0.0, 0.0, tclen.getTableUnits(), 1, null);
- }
+ /**
+ * Construct a Numeric object of dimension 0 from a double.
+ * @param valType A combination of bits representing the value types.
+ * @param absValue The value of a Number or resolved Length value.
+ */
+ /**
+ * *
+ * protected Numeric(int valType, double absValue) {
+ * this.valType = valType;
+ * this.absValue = absValue;
+ * }
+ */
- /**
- * Return the current value as a Length if possible. This constructs
- * a new Length or Length subclass based on the current value type
- * of the Numeric.
- * If the stored value has a unit dimension other than 1, null
- * is returned.
- */
- public Length asLength() {
- if (dim == 1) {
- if (valType == ABS_LENGTH) {
- return new Length((int)absValue);
- }
- PercentLength pclen = null;
- if ((valType & PC_LENGTH)!=0) {
- pclen = new PercentLength(pcValue, pcBase);
- if (valType == PC_LENGTH)
- return pclen;
- }
- if ((valType & TCOL_LENGTH) != 0) {
- return new TableColLength((int)absValue, pclen, tcolValue);
- }
- return new MixedLength((int)absValue, pclen);
- }
- else {
- // or throw exception???
- // can't make Length if dimension != 1
- return null;
+ /**
+ * Construct a Numeric object from a Number.
+ * @param num The number.
+ */
+ public Numeric(Number num) {
+ this(ABS_LENGTH, num.doubleValue(), 0.0, 0.0, 0, null);
}
- }
- /**
- * Return the current value as a Number if possible.
- * Calls asDouble().
- */
- public Number asNumber() {
- return asDouble();
- }
- public Double asDouble() {
- if (dim == 0 && valType==ABS_LENGTH) {
- return new Double(absValue);
- }
- else {
- // or throw exception???
- // can't make Number if dimension != 0
- return null;
+ /**
+ * Construct a Numeric object from a Length.
+ * @param l The Length.
+ */
+ public Numeric(Length l) {
+ this(ABS_LENGTH, (double)l.mvalue(), 0.0, 0.0, 1, null);
}
- }
- /**
- * Return the current value as a Integer if possible.
- * If the unit dimension is 0 and the value type is ABSOLUTE, an Integer
- * is returned. Otherwise null is returned. Note: the current value is
- * truncated if necessary to make an integer value.
- */
- /**
- public Integer asInteger() {
- if (dim == 0 && valType==ABS_LENGTH) {
- return new Integer((int)absValue);
+ /**
+ * Construct a Numeric object from a PercentLength.
+ * @param pclen The PercentLength.
+ */
+ public Numeric(PercentLength pclen) {
+ this(PC_LENGTH, 0.0, pclen.value(), 0.0, 1, pclen.getBaseLength());
}
- else {
- // or throw exception???
- // can't make Number if dimension != 0
- return null;
- }
- }
- **/
- /**
- * Return a boolean value indiciating whether the currently stored
- * value consists of different "types" of values (absolute, percent,
- * and/or table-unit.)
- */
- private boolean isMixedType() {
- int ntype = 0;
- for (int t = valType; t!=0; t=t>>1) {
- if ((t & 1) != 0) ++ntype;
+ /**
+ * Construct a Numeric object from a TableColLength.
+ * @param tclen The TableColLength.
+ */
+ public Numeric(TableColLength tclen) {
+ this(TCOL_LENGTH, 0.0, 0.0, tclen.getTableUnits(), 1, null);
}
- return ntype>1;
- }
- /**
- * Subtract the operand from the current value and return a new Numeric
- * representing the result.
- * @param op The value to subtract.
- * @return A Numeric representing the result.
- * @throws PropertyException If the dimension of the operand is different
- * from the dimension of this Numeric.
- */
- public Numeric subtract(Numeric op) throws PropertyException {
- // Check of same dimension
- // Add together absolute and table units
- // What about percentages??? Treat as colUnits if they can't be
- // in same property!
- if (dim == op.dim) {
- PercentBase npcBase = ((valType & PC_LENGTH)!=0)? pcBase : op.pcBase;
- // Subtract each type of value
- return new Numeric(valType|op.valType, absValue-op.absValue,
- pcValue-op.pcValue,
- tcolValue-op.tcolValue,dim, npcBase);
- }
- else {
- throw new PropertyException("Can't add Numerics of different dimensions");
- }
- }
- /**
- * Add the operand from the current value and return a new Numeric
- * representing the result.
- * @param op The value to add.
- * @return A Numeric representing the result.
- * @throws PropertyException If the dimension of the operand is different
- * from the dimension of this Numeric.
- */
- public Numeric add(Numeric op) throws PropertyException {
- // Check of same dimension
- // Add together absolute and table units
- // What about percentages??? Treat as colUnits if they can't be
- // in same property!
- if (dim == op.dim) {
- PercentBase npcBase = ((valType & PC_LENGTH)!=0)? pcBase : op.pcBase;
- // Add each type of value
- return new Numeric(valType | op.valType, absValue+op.absValue,
- pcValue+op.pcValue,
- tcolValue+op.tcolValue, dim, npcBase);
- }
- else {
- throw new PropertyException("Can't add Numerics of different dimensions");
- }
- }
- /**
- * Multiply the the current value by the operand and return a new Numeric
- * representing the result.
- * @param op The multiplier.
- * @return A Numeric representing the result.
- * @throws PropertyException If both Numerics have "mixed" type.
- */
- public Numeric multiply(Numeric op) throws PropertyException {
- // Multiply together absolute units and add dimensions (exponents)
- // What about percentages??? Treat as colUnits if they can't be
- // in same property!
- if (dim == 0) {
- // This is a dimensionless quantity, ie. a "Number"
- return new Numeric(op.valType, absValue*op.absValue,
- absValue*op.pcValue,
- absValue*op.tcolValue, op.dim,
- op.pcBase);
+ /**
+ * Return the current value as a Length if possible. This constructs
+ * a new Length or Length subclass based on the current value type
+ * of the Numeric.
+ * If the stored value has a unit dimension other than 1, null
+ * is returned.
+ */
+ public Length asLength() {
+ if (dim == 1) {
+ if (valType == ABS_LENGTH) {
+ return new Length((int)absValue);
+ }
+ PercentLength pclen = null;
+ if ((valType & PC_LENGTH) != 0) {
+ pclen = new PercentLength(pcValue, pcBase);
+ if (valType == PC_LENGTH)
+ return pclen;
+ }
+ if ((valType & TCOL_LENGTH) != 0) {
+ return new TableColLength((int)absValue, pclen, tcolValue);
+ }
+ return new MixedLength((int)absValue, pclen);
+ } else {
+ // or throw exception???
+ // can't make Length if dimension != 1
+ return null;
+ }
}
- else if (op.dim == 0) {
- double opval = op.absValue;
- return new Numeric(valType, opval*absValue,
- opval*pcValue, opval*tcolValue, dim, pcBase);
+
+ /**
+ * Return the current value as a Number if possible.
+ * Calls asDouble().
+ */
+ public Number asNumber() {
+ return asDouble();
}
- else if (valType == op.valType && !isMixedType()) {
- // Check same relbase and pcbase ???
- PercentBase npcBase = ((valType & PC_LENGTH)!=0)? pcBase : op.pcBase;
- return new Numeric(valType, absValue * op.absValue,
- pcValue*op.pcValue,
- tcolValue*op.tcolValue,dim+op.dim,
- npcBase);
+
+ public Double asDouble() {
+ if (dim == 0 && valType == ABS_LENGTH) {
+ return new Double(absValue);
+ } else {
+ // or throw exception???
+ // can't make Number if dimension != 0
+ return null;
+ }
}
- else {
- throw new PropertyException("Can't multiply mixed Numerics");
+
+ /**
+ * Return the current value as a Integer if possible.
+ * If the unit dimension is 0 and the value type is ABSOLUTE, an Integer
+ * is returned. Otherwise null is returned. Note: the current value is
+ * truncated if necessary to make an integer value.
+ */
+
+ /**
+ * public Integer asInteger() {
+ * if (dim == 0 && valType==ABS_LENGTH) {
+ * return new Integer((int)absValue);
+ * }
+ * else {
+ * // or throw exception???
+ * // can't make Number if dimension != 0
+ * return null;
+ * }
+ * }
+ */
+
+ /**
+ * Return a boolean value indiciating whether the currently stored
+ * value consists of different "types" of values (absolute, percent,
+ * and/or table-unit.)
+ */
+ private boolean isMixedType() {
+ int ntype = 0;
+ for (int t = valType; t != 0; t = t >> 1) {
+ if ((t & 1) != 0)
+ ++ntype;
+ }
+ return ntype > 1;
}
- }
- /**
- * Divide the the current value by the operand and return a new Numeric
- * representing the result.
- * @param op The divisor.
- * @return A Numeric representing the result.
- * @throws PropertyException If both Numerics have "mixed" type.
- */
- public Numeric divide(Numeric op) throws PropertyException {
- // Multiply together absolute units and add dimensions (exponents)
- // What about percentages??? Treat as colUnits if they can't be
- // in same property!
- if (dim == 0) {
- // This is a dimensionless quantity, ie. a "Number"
- return new Numeric(op.valType, absValue/op.absValue,
- absValue/op.pcValue,
- absValue/op.tcolValue, -op.dim, op.pcBase);
+ /**
+ * Subtract the operand from the current value and return a new Numeric
+ * representing the result.
+ * @param op The value to subtract.
+ * @return A Numeric representing the result.
+ * @throws PropertyException If the dimension of the operand is different
+ * from the dimension of this Numeric.
+ */
+ public Numeric subtract(Numeric op) throws PropertyException {
+ // Check of same dimension
+ // Add together absolute and table units
+ // What about percentages??? Treat as colUnits if they can't be
+ // in same property!
+ if (dim == op.dim) {
+ PercentBase npcBase = ((valType & PC_LENGTH) != 0) ? pcBase
+ : op.pcBase;
+ // Subtract each type of value
+ return new Numeric(valType | op.valType, absValue - op.absValue,
+ pcValue - op.pcValue,
+ tcolValue - op.tcolValue, dim, npcBase);
+ } else {
+ throw new PropertyException("Can't add Numerics of different dimensions");
+ }
}
- else if (op.dim == 0) {
- double opval = op.absValue;
- return new Numeric(valType, absValue/opval,
- pcValue/opval, tcolValue/opval, dim, pcBase);
+
+ /**
+ * Add the operand from the current value and return a new Numeric
+ * representing the result.
+ * @param op The value to add.
+ * @return A Numeric representing the result.
+ * @throws PropertyException If the dimension of the operand is different
+ * from the dimension of this Numeric.
+ */
+ public Numeric add(Numeric op) throws PropertyException {
+ // Check of same dimension
+ // Add together absolute and table units
+ // What about percentages??? Treat as colUnits if they can't be
+ // in same property!
+ if (dim == op.dim) {
+ PercentBase npcBase = ((valType & PC_LENGTH) != 0) ? pcBase
+ : op.pcBase;
+ // Add each type of value
+ return new Numeric(valType | op.valType, absValue + op.absValue,
+ pcValue + op.pcValue,
+ tcolValue + op.tcolValue, dim, npcBase);
+ } else {
+ throw new PropertyException("Can't add Numerics of different dimensions");
+ }
}
- else if (valType == op.valType && !isMixedType()) {
- PercentBase npcBase = ((valType & PC_LENGTH)!=0)? pcBase : op.pcBase;
- return new Numeric(valType,
- (valType==ABS_LENGTH? absValue/op.absValue:0.0),
- (valType==PC_LENGTH? pcValue/op.pcValue:0.0),
- (valType==TCOL_LENGTH? tcolValue/op.tcolValue:0.0),
- dim-op.dim, npcBase);
+
+ /**
+ * Multiply the the current value by the operand and return a new Numeric
+ * representing the result.
+ * @param op The multiplier.
+ * @return A Numeric representing the result.
+ * @throws PropertyException If both Numerics have "mixed" type.
+ */
+ public Numeric multiply(Numeric op) throws PropertyException {
+ // Multiply together absolute units and add dimensions (exponents)
+ // What about percentages??? Treat as colUnits if they can't be
+ // in same property!
+ if (dim == 0) {
+ // This is a dimensionless quantity, ie. a "Number"
+ return new Numeric(op.valType, absValue * op.absValue,
+ absValue * op.pcValue,
+ absValue * op.tcolValue, op.dim, op.pcBase);
+ } else if (op.dim == 0) {
+ double opval = op.absValue;
+ return new Numeric(valType, opval * absValue, opval * pcValue,
+ opval * tcolValue, dim, pcBase);
+ } else if (valType == op.valType &&!isMixedType()) {
+ // Check same relbase and pcbase ???
+ PercentBase npcBase = ((valType & PC_LENGTH) != 0) ? pcBase
+ : op.pcBase;
+ return new Numeric(valType, absValue * op.absValue,
+ pcValue * op.pcValue,
+ tcolValue * op.tcolValue, dim + op.dim,
+ npcBase);
+ } else {
+ throw new PropertyException("Can't multiply mixed Numerics");
+ }
}
- else {
- throw new PropertyException("Can't divide mixed Numerics.");
+
+ /**
+ * Divide the the current value by the operand and return a new Numeric
+ * representing the result.
+ * @param op The divisor.
+ * @return A Numeric representing the result.
+ * @throws PropertyException If both Numerics have "mixed" type.
+ */
+ public Numeric divide(Numeric op) throws PropertyException {
+ // Multiply together absolute units and add dimensions (exponents)
+ // What about percentages??? Treat as colUnits if they can't be
+ // in same property!
+ if (dim == 0) {
+ // This is a dimensionless quantity, ie. a "Number"
+ return new Numeric(op.valType, absValue / op.absValue,
+ absValue / op.pcValue,
+ absValue / op.tcolValue, -op.dim, op.pcBase);
+ } else if (op.dim == 0) {
+ double opval = op.absValue;
+ return new Numeric(valType, absValue / opval, pcValue / opval,
+ tcolValue / opval, dim, pcBase);
+ } else if (valType == op.valType &&!isMixedType()) {
+ PercentBase npcBase = ((valType & PC_LENGTH) != 0) ? pcBase
+ : op.pcBase;
+ return new Numeric(valType,
+ (valType == ABS_LENGTH ? absValue / op.absValue : 0.0),
+ (valType == PC_LENGTH ? pcValue / op.pcValue : 0.0),
+ (valType == TCOL_LENGTH ? tcolValue / op.tcolValue : 0.0),
+ dim - op.dim, npcBase);
+ } else {
+ throw new PropertyException("Can't divide mixed Numerics.");
+ }
}
- }
- /**
- * Return the absolute value of this Numeric.
- * @return A new Numeric object representing the absolute value.
- */
- public Numeric abs() {
- return new Numeric(valType, Math.abs(absValue),
- Math.abs(pcValue), Math.abs(tcolValue), dim, pcBase);
- }
+ /**
+ * Return the absolute value of this Numeric.
+ * @return A new Numeric object representing the absolute value.
+ */
+ public Numeric abs() {
+ return new Numeric(valType, Math.abs(absValue), Math.abs(pcValue),
+ Math.abs(tcolValue), dim, pcBase);
+ }
- /**
- * Return a Numeric which is the maximum of the current value and the
- * operand.
- * @throws PropertyException If the dimensions or value types of the
- * object and the operand are different.
- */
- public Numeric max(Numeric op) throws PropertyException {
- double rslt = 0.0;
- // Only compare if have same dimension and value type!
- if (dim == op.dim && valType == op.valType && !isMixedType()) {
- if (valType==ABS_LENGTH) rslt = absValue - op.absValue;
- else if (valType==PC_LENGTH) rslt = pcValue - op.pcValue;
- else if (valType==TCOL_LENGTH) rslt = tcolValue - op.tcolValue;
- if (rslt > 0.0)
- return this;
- else return op;
+ /**
+ * Return a Numeric which is the maximum of the current value and the
+ * operand.
+ * @throws PropertyException If the dimensions or value types of the
+ * object and the operand are different.
+ */
+ public Numeric max(Numeric op) throws PropertyException {
+ double rslt = 0.0;
+ // Only compare if have same dimension and value type!
+ if (dim == op.dim && valType == op.valType &&!isMixedType()) {
+ if (valType == ABS_LENGTH)
+ rslt = absValue - op.absValue;
+ else if (valType == PC_LENGTH)
+ rslt = pcValue - op.pcValue;
+ else if (valType == TCOL_LENGTH)
+ rslt = tcolValue - op.tcolValue;
+ if (rslt > 0.0)
+ return this;
+ else
+ return op;
+ }
+ throw new PropertyException("Arguments to max() must have same dimension and value type.");
}
- throw new PropertyException("Arguments to max() must have same dimension and value type.");
- }
- /**
- * Return a Numeric which is the minimum of the current value and the
- * operand.
- * @throws PropertyException If the dimensions or value types of the
- * object and the operand are different.
- */
- public Numeric min(Numeric op) throws PropertyException {
- double rslt = 0.0;
- // Only compare if have same dimension and value type!
- if (dim == op.dim && valType == op.valType && !isMixedType()) {
- if (valType==ABS_LENGTH) rslt = absValue - op.absValue;
- else if (valType==PC_LENGTH) rslt = pcValue - op.pcValue;
- else if (valType==TCOL_LENGTH) rslt = tcolValue - op.tcolValue;
- if (rslt > 0.0)
- return op;
- else return this;
+ /**
+ * Return a Numeric which is the minimum of the current value and the
+ * operand.
+ * @throws PropertyException If the dimensions or value types of the
+ * object and the operand are different.
+ */
+ public Numeric min(Numeric op) throws PropertyException {
+ double rslt = 0.0;
+ // Only compare if have same dimension and value type!
+ if (dim == op.dim && valType == op.valType &&!isMixedType()) {
+ if (valType == ABS_LENGTH)
+ rslt = absValue - op.absValue;
+ else if (valType == PC_LENGTH)
+ rslt = pcValue - op.pcValue;
+ else if (valType == TCOL_LENGTH)
+ rslt = tcolValue - op.tcolValue;
+ if (rslt > 0.0)
+ return op;
+ else
+ return this;
+ }
+ throw new PropertyException("Arguments to min() must have same dimension and value type.");
}
- throw new PropertyException("Arguments to min() must have same dimension and value type.");
- }
}
diff --git a/src/org/apache/fop/fo/expr/NumericProperty.java b/src/org/apache/fop/fo/expr/NumericProperty.java
index 49d08920d..524ec0c20 100644
--- a/src/org/apache/fop/fo/expr/NumericProperty.java
+++ b/src/org/apache/fop/fo/expr/NumericProperty.java
@@ -1,52 +1,8 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
package org.apache.fop.fo.expr;
@@ -55,30 +11,31 @@ import org.apache.fop.datatypes.Length;
import org.apache.fop.datatypes.ColorType;
class NumericProperty extends Property {
- private Numeric numeric ;
+ private Numeric numeric;
+
+ NumericProperty(Numeric value) {
+ this.numeric = value;
+ }
- NumericProperty(Numeric value) {
- this.numeric = value;
- }
+ public Numeric getNumeric() {
+ return this.numeric;
+ }
- public Numeric getNumeric() {
- return this.numeric;
- }
+ public Number getNumber() {
+ return numeric.asNumber();
+ }
- public Number getNumber() {
- return numeric.asNumber();
- }
+ public Length getLength() {
+ return numeric.asLength();
+ }
- public Length getLength() {
- return numeric.asLength();
- }
+ public ColorType getColorType() {
+ // try converting to numeric number and then to color
+ return null;
+ }
- public ColorType getColorType() {
- // try converting to numeric number and then to color
- return null;
- }
+ public Object getObject() {
+ return this.numeric;
+ }
- public Object getObject() {
- return this.numeric;
- }
}
diff --git a/src/org/apache/fop/fo/expr/PPColWidthFunction.java b/src/org/apache/fop/fo/expr/PPColWidthFunction.java
index 1e2501d42..c3bd3eada 100644
--- a/src/org/apache/fop/fo/expr/PPColWidthFunction.java
+++ b/src/org/apache/fop/fo/expr/PPColWidthFunction.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
@@ -57,20 +14,21 @@ import org.apache.fop.datatypes.TableColLength;
public class PPColWidthFunction extends FunctionBase {
- public int nbArgs() { return 1; }
-
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- Number d = args[0].getNumber();
- if (d == null) {
- throw new PropertyException("Non number operand to proportional-column-width function");
+ public int nbArgs() {
+ return 1;
}
- if (!pInfo.getPropertyList().getElement().equals("table-column")) {
- throw new PropertyException("proportional-column-width function may only be used on table-column FO");
+
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ Number d = args[0].getNumber();
+ if (d == null) {
+ throw new PropertyException("Non number operand to proportional-column-width function");
+ }
+ if (!pInfo.getPropertyList().getElement().equals("table-column")) {
+ throw new PropertyException("proportional-column-width function may only be used on table-column FO");
+ }
+ // Check if table-layout is "fixed"...
+ return new LengthProperty(new TableColLength(d.doubleValue()));
}
- // Check if table-layout is "fixed"...
- return new LengthProperty(new TableColLength(d.doubleValue()));
- }
-}
+}
diff --git a/src/org/apache/fop/fo/expr/PropertyException.java b/src/org/apache/fop/fo/expr/PropertyException.java
index 2e0f17b50..d73c37734 100644
--- a/src/org/apache/fop/fo/expr/PropertyException.java
+++ b/src/org/apache/fop/fo/expr/PropertyException.java
@@ -1,57 +1,15 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
public class PropertyException extends Exception {
- public PropertyException(String detail) {
- super(detail);
- }
+ public PropertyException(String detail) {
+ super(detail);
+ }
+
}
diff --git a/src/org/apache/fop/fo/expr/PropertyInfo.java b/src/org/apache/fop/fo/expr/PropertyInfo.java
index 5416ebfbe..747ec17af 100644
--- a/src/org/apache/fop/fo/expr/PropertyInfo.java
+++ b/src/org/apache/fop/fo/expr/PropertyInfo.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import java.util.Stack;
@@ -65,68 +22,73 @@ import org.apache.fop.datatypes.PercentBase;
* built, and the FObj parent of the FObj for which the property is being set.
*/
public class PropertyInfo {
- private Property.Maker maker;
- private PropertyList plist;
- private FObj fo;
- private Stack stkFunction; // Stack of functions being evaluated
+ private Property.Maker maker;
+ private PropertyList plist;
+ private FObj fo;
+ private Stack stkFunction; // Stack of functions being evaluated
- public PropertyInfo(Property.Maker maker, PropertyList plist, FObj fo) {
- this.maker = maker;
- this.plist = plist;
- this.fo = fo;
- }
+ public PropertyInfo(Property.Maker maker, PropertyList plist, FObj fo) {
+ this.maker = maker;
+ this.plist = plist;
+ this.fo = fo;
+ }
- /**
- * Return whether this property inherits specified values.
- * Propagates to the Maker.
- * @return true if the property inherits specified values, false if it
- * inherits computed values.
- */
- public boolean inheritsSpecified() {
- return maker.inheritsSpecified();
- }
+ /**
+ * Return whether this property inherits specified values.
+ * Propagates to the Maker.
+ * @return true if the property inherits specified values, false if it
+ * inherits computed values.
+ */
+ public boolean inheritsSpecified() {
+ return maker.inheritsSpecified();
+ }
- /**
- * Return the PercentBase object used to calculate the absolute value from
- * a percent specification.
- * Propagates to the Maker.
- * @return The PercentBase object or null if percentLengthOK()=false.
- */
- public PercentBase getPercentBase() {
- PercentBase pcbase = getFunctionPercentBase();
- return (pcbase != null)? pcbase : maker.getPercentBase(fo, plist);
- }
+ /**
+ * Return the PercentBase object used to calculate the absolute value from
+ * a percent specification.
+ * Propagates to the Maker.
+ * @return The PercentBase object or null if percentLengthOK()=false.
+ */
+ public PercentBase getPercentBase() {
+ PercentBase pcbase = getFunctionPercentBase();
+ return (pcbase != null) ? pcbase : maker.getPercentBase(fo, plist);
+ }
- /**
- * Return the current font-size value as base units (milli-points).
- */
- public int currentFontSize() {
- return plist.get("font-size").getLength().mvalue();
- }
+ /**
+ * Return the current font-size value as base units (milli-points).
+ */
+ public int currentFontSize() {
+ return plist.get("font-size").getLength().mvalue();
+ }
- public FObj getFO() { return fo; }
+ public FObj getFO() {
+ return fo;
+ }
- public PropertyList getPropertyList() { return plist; }
+ public PropertyList getPropertyList() {
+ return plist;
+ }
- public void pushFunction(Function func) {
- if (stkFunction == null) {
- stkFunction = new Stack();
+ public void pushFunction(Function func) {
+ if (stkFunction == null) {
+ stkFunction = new Stack();
+ }
+ stkFunction.push(func);
}
- stkFunction.push(func);
- }
- public void popFunction() {
- if (stkFunction != null)
- stkFunction.pop();
- }
+ public void popFunction() {
+ if (stkFunction != null)
+ stkFunction.pop();
+ }
- private PercentBase getFunctionPercentBase() {
- if (stkFunction != null) {
- Function f = (Function)stkFunction.peek();
- if (f != null) {
- return f.getPercentBase();
- }
+ private PercentBase getFunctionPercentBase() {
+ if (stkFunction != null) {
+ Function f = (Function)stkFunction.peek();
+ if (f != null) {
+ return f.getPercentBase();
+ }
+ }
+ return null;
}
- return null;
- }
+
}
diff --git a/src/org/apache/fop/fo/expr/PropertyParser.java b/src/org/apache/fop/fo/expr/PropertyParser.java
index 9195a1ada..2d5a89c61 100644
--- a/src/org/apache/fop/fo/expr/PropertyParser.java
+++ b/src/org/apache/fop/fo/expr/PropertyParser.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
import org.apache.fop.fo.Property;
@@ -66,415 +23,420 @@ import java.util.Hashtable;
* XT, an XSLT processor.
*/
public class PropertyParser extends PropertyTokenizer {
- private PropertyInfo propInfo; // Maker and propertyList related info
-
- static private final String RELUNIT = "em";
- static private final Numeric negOne = new Numeric(new Double(-1.0));
- static final private Hashtable functionTable = new Hashtable();
-
- static {
- // Initialize the Hashtable of XSL-defined functions
- functionTable.put("ceiling", new CeilingFunction());
- functionTable.put("floor", new FloorFunction());
- functionTable.put("round", new RoundFunction());
- functionTable.put("min", new MinFunction());
- functionTable.put("max", new MaxFunction());
- functionTable.put("abs", new AbsFunction());
- functionTable.put("rgb", new RGBColorFunction());
- functionTable.put("from-table-column", new FromTableColumnFunction());
- functionTable.put("inherited-property-value", new InheritedPropFunction());
- functionTable.put("from-parent", new FromParentFunction());
- functionTable.put("from-nearest-specified-value", new NearestSpecPropFunction());
- functionTable.put("proportional-column-width", new PPColWidthFunction());
- functionTable.put("label-end", new LabelEndFunction());
- functionTable.put("body-start", new BodyStartFunction());
- // NOTE: used from code generated for corresponding properties
- functionTable.put("_fop-property-value", new FopPropValFunction());
-
- /*** NOT YET IMPLEMENTED!!!
- functionTable.put("icc-color", new ICCcolorFunction());
- functionTable.put("system-color", new SystemColorFunction());
-
- functionTable.put("system-font", new SystemFontFunction());
-
- functionTable.put("merge-property-values", new MergePropsFunction());
- ***/
- }
-
-
- /**
- * Public entrypoint to the Property expression parser.
- * @param expr The specified value (attribute on the xml element).
- * @param propInfo A PropertyInfo object representing the context in
- * which the property expression is to be evaluated.
- * @return A Property object holding the parsed result.
- * @throws PropertyException If the "expr" cannot be parsed as a Property.
- */
- public static Property parse(String expr, PropertyInfo propInfo)
- throws PropertyException {
- return new PropertyParser(expr, propInfo).parseProperty();
- }
-
-
- /**
- * Private constructor. Called by the static parse() method.
- * @param propExpr The specified value (attribute on the xml element).
- * @param propInfo A PropertyInfo object representing the context in
- * which the property expression is to be evaluated.
- */
- private PropertyParser(String propExpr, PropertyInfo pInfo) {
- super(propExpr);
- this.propInfo = pInfo;
- }
-
- /**
- * Parse the property expression described in the instance variables.
- * Note: If the property expression String is empty, a StringProperty
- * object holding an empty String is returned.
- * @return A Property object holding the parsed result.
- * @throws PropertyException If the "expr" cannot be parsed as a Property.
- */
- private Property parseProperty() throws PropertyException {
- next();
- if (currentToken == TOK_EOF) {
- // if prop value is empty string, force to StringProperty
- return new StringProperty("");
+ private PropertyInfo propInfo; // Maker and propertyList related info
+
+ static private final String RELUNIT = "em";
+ static private final Numeric negOne = new Numeric(new Double(-1.0));
+ static final private Hashtable functionTable = new Hashtable();
+
+ static {
+ // Initialize the Hashtable of XSL-defined functions
+ functionTable.put("ceiling", new CeilingFunction());
+ functionTable.put("floor", new FloorFunction());
+ functionTable.put("round", new RoundFunction());
+ functionTable.put("min", new MinFunction());
+ functionTable.put("max", new MaxFunction());
+ functionTable.put("abs", new AbsFunction());
+ functionTable.put("rgb", new RGBColorFunction());
+ functionTable.put("from-table-column", new FromTableColumnFunction());
+ functionTable.put("inherited-property-value",
+ new InheritedPropFunction());
+ functionTable.put("from-parent", new FromParentFunction());
+ functionTable.put("from-nearest-specified-value",
+ new NearestSpecPropFunction());
+ functionTable.put("proportional-column-width",
+ new PPColWidthFunction());
+ functionTable.put("label-end", new LabelEndFunction());
+ functionTable.put("body-start", new BodyStartFunction());
+ // NOTE: used from code generated for corresponding properties
+ functionTable.put("_fop-property-value", new FopPropValFunction());
+
+ /**
+ * * NOT YET IMPLEMENTED!!!
+ * functionTable.put("icc-color", new ICCcolorFunction());
+ * functionTable.put("system-color", new SystemColorFunction());
+ * functionTable.put("system-font", new SystemFontFunction());
+ *
+ * functionTable.put("merge-property-values", new MergePropsFunction());
+ */
}
- ListProperty propList = null;
- while (true) {
- Property prop = parseAdditiveExpr();
- if (currentToken == TOK_EOF) {
- if (propList != null) {
- propList.addProperty(prop);
- return propList;
- }
- else return prop;
- }
- else {
- if (propList == null) {
- propList = new ListProperty(prop);
+
+
+ /**
+ * Public entrypoint to the Property expression parser.
+ * @param expr The specified value (attribute on the xml element).
+ * @param propInfo A PropertyInfo object representing the context in
+ * which the property expression is to be evaluated.
+ * @return A Property object holding the parsed result.
+ * @throws PropertyException If the "expr" cannot be parsed as a Property.
+ */
+ public static Property parse(String expr, PropertyInfo propInfo)
+ throws PropertyException {
+ return new PropertyParser(expr, propInfo).parseProperty();
+ }
+
+
+ /**
+ * Private constructor. Called by the static parse() method.
+ * @param propExpr The specified value (attribute on the xml element).
+ * @param propInfo A PropertyInfo object representing the context in
+ * which the property expression is to be evaluated.
+ */
+ private PropertyParser(String propExpr, PropertyInfo pInfo) {
+ super(propExpr);
+ this.propInfo = pInfo;
+ }
+
+ /**
+ * Parse the property expression described in the instance variables.
+ * Note: If the property expression String is empty, a StringProperty
+ * object holding an empty String is returned.
+ * @return A Property object holding the parsed result.
+ * @throws PropertyException If the "expr" cannot be parsed as a Property.
+ */
+ private Property parseProperty() throws PropertyException {
+ next();
+ if (currentToken == TOK_EOF) {
+ // if prop value is empty string, force to StringProperty
+ return new StringProperty("");
}
- else {
- propList.addProperty(prop);
+ ListProperty propList = null;
+ while (true) {
+ Property prop = parseAdditiveExpr();
+ if (currentToken == TOK_EOF) {
+ if (propList != null) {
+ propList.addProperty(prop);
+ return propList;
+ } else
+ return prop;
+ } else {
+ if (propList == null) {
+ propList = new ListProperty(prop);
+ } else {
+ propList.addProperty(prop);
+ }
+ }
+ // throw new PropertyException("unexpected token");
}
- }
- //throw new PropertyException("unexpected token");
+ // return prop;
}
- //return prop;
- }
-
- /**
- * Try to parse an addition or subtraction expression and return the
- * resulting Property.
- */
- private Property parseAdditiveExpr() throws PropertyException {
- // Evaluate and put result on the operand stack
- Property prop = parseMultiplicativeExpr();
- loop:
- for (;;) {
- switch (currentToken) {
- case TOK_PLUS:
- next();
- prop = evalAddition(prop.getNumeric(),
- parseMultiplicativeExpr().getNumeric() );
- break;
- case TOK_MINUS:
- next();
- prop = evalSubtraction(prop.getNumeric(),
- parseMultiplicativeExpr().getNumeric() );
- break;
- default:
- break loop;
- }
+
+ /**
+ * Try to parse an addition or subtraction expression and return the
+ * resulting Property.
+ */
+ private Property parseAdditiveExpr() throws PropertyException {
+ // Evaluate and put result on the operand stack
+ Property prop = parseMultiplicativeExpr();
+ loop:
+ for (; ; ) {
+ switch (currentToken) {
+ case TOK_PLUS:
+ next();
+ prop = evalAddition(prop.getNumeric(),
+ parseMultiplicativeExpr().getNumeric());
+ break;
+ case TOK_MINUS:
+ next();
+ prop =
+ evalSubtraction(prop.getNumeric(),
+ parseMultiplicativeExpr().getNumeric());
+ break;
+ default:
+ break loop;
+ }
+ }
+ return prop;
}
- return prop;
- }
-
- /**
- * Try to parse a multiply, divide or modulo expression and return
- * the resulting Property.
- */
- private Property parseMultiplicativeExpr() throws PropertyException {
- Property prop = parseUnaryExpr();
- loop:
- for (;;) {
- switch (currentToken) {
- case TOK_DIV:
- next();
- prop = evalDivide(prop.getNumeric(), parseUnaryExpr().getNumeric() );
- break;
- case TOK_MOD:
- next();
- prop = evalModulo(prop.getNumber(), parseUnaryExpr().getNumber() );
- break;
- case TOK_MULTIPLY:
- next();
- prop = evalMultiply(prop.getNumeric(), parseUnaryExpr().getNumeric());
- break;
- default:
- break loop;
- }
+
+ /**
+ * Try to parse a multiply, divide or modulo expression and return
+ * the resulting Property.
+ */
+ private Property parseMultiplicativeExpr() throws PropertyException {
+ Property prop = parseUnaryExpr();
+ loop:
+ for (; ; ) {
+ switch (currentToken) {
+ case TOK_DIV:
+ next();
+ prop = evalDivide(prop.getNumeric(),
+ parseUnaryExpr().getNumeric());
+ break;
+ case TOK_MOD:
+ next();
+ prop = evalModulo(prop.getNumber(),
+ parseUnaryExpr().getNumber());
+ break;
+ case TOK_MULTIPLY:
+ next();
+ prop = evalMultiply(prop.getNumeric(),
+ parseUnaryExpr().getNumeric());
+ break;
+ default:
+ break loop;
+ }
+ }
+ return prop;
}
- return prop;
- }
-
- /**
- * Try to parse a unary minus expression and return the
- * resulting Property.
- */
- private Property parseUnaryExpr() throws PropertyException {
- if (currentToken == TOK_MINUS) {
- next();
- return evalNegate(parseUnaryExpr().getNumeric());
+
+ /**
+ * Try to parse a unary minus expression and return the
+ * resulting Property.
+ */
+ private Property parseUnaryExpr() throws PropertyException {
+ if (currentToken == TOK_MINUS) {
+ next();
+ return evalNegate(parseUnaryExpr().getNumeric());
+ }
+ return parsePrimaryExpr();
}
- return parsePrimaryExpr();
- }
-
-
- /**
- * Checks that the current token is a right parenthesis
- * and throws an exception if this isn't the case.
- */
- private final void expectRpar() throws PropertyException {
- if (currentToken != TOK_RPAR)
- throw new PropertyException("expected )");
- next();
- }
-
- /**
- * Try to parse a primary expression and return the
- * resulting Property.
- * A primary expression is either a parenthesized expression or an
- * expression representing a primitive Property datatype, such as a
- * string literal, an NCname, a number or a unit expression, or a
- * function call expression.
- */
- private Property parsePrimaryExpr() throws PropertyException {
- Property prop;
- switch (currentToken) {
- case TOK_LPAR:
- next();
- prop = parseAdditiveExpr();
- expectRpar();
- return prop;
-
- case TOK_LITERAL:
- prop = new StringProperty(currentTokenValue);
- break;
-
- case TOK_NCNAME:
- // Interpret this in context of the property or do it later?
- prop = new NCnameProperty(currentTokenValue);
- break;
-
- case TOK_FLOAT:
- prop = new NumberProperty(new Double(currentTokenValue));
- break;
-
- case TOK_INTEGER:
- prop = new NumberProperty(new Integer(currentTokenValue));
- break;
-
- case TOK_PERCENT:
- /* Get the length base value object from the Maker. If null, then
- * this property can't have % values. Treat it as a real number.
- */
- double pcval = new Double(currentTokenValue.substring(0,
- currentTokenValue.length()-1)).
- doubleValue()/100.0;
- // LengthBase lbase = this.propInfo.getPercentLengthBase();
- PercentBase pcBase = this.propInfo.getPercentBase();
- if (pcBase != null) {
- if (pcBase.getDimension() == 0) {
- prop = new NumberProperty(pcval * pcBase.getBaseValue());
- }
- else if (pcBase.getDimension() == 1) {
- prop = new LengthProperty(new PercentLength(pcval, pcBase));
- }
- else {
- throw new PropertyException("Illegal percent dimension value");
- }
- }
- else {
- // WARNING? Interpret as a decimal fraction, eg. 50% = .5
- prop = new NumberProperty(pcval);
- }
- break;
-
- case TOK_NUMERIC:
- // A number plus a valid unit name.
- int numLen = currentTokenValue.length()-currentUnitLength;
- String unitPart = currentTokenValue.substring(numLen);
- Double numPart = new Double(currentTokenValue.substring(0,numLen));
- Length length= null;
- if (unitPart.equals(RELUNIT)) {
- length = new Length(numPart.doubleValue(),
- propInfo.currentFontSize());
- }
- else
- length = new Length(numPart.doubleValue(), unitPart);
- if (length == null) {
- throw new PropertyException("unrecognized unit name: "+ currentTokenValue);
- }
- else prop = new LengthProperty(length);
- break;
-
- case TOK_COLORSPEC:
- prop = new ColorTypeProperty(new ColorType(currentTokenValue));
- break;
-
- case TOK_FUNCTION_LPAR:
- {
- Function function = (Function)functionTable.get(currentTokenValue);
- if (function == null) {
- throw new PropertyException("no such function: " + currentTokenValue);
- }
- next();
- // Push new function (for function context: getPercentBase())
- propInfo.pushFunction(function);
- prop = function.eval(parseArgs(function.nbArgs()), propInfo);
- propInfo.popFunction();
- return prop;
- }
- default:
- throw new PropertyException("syntax error");
+
+
+ /**
+ * Checks that the current token is a right parenthesis
+ * and throws an exception if this isn't the case.
+ */
+ private final void expectRpar() throws PropertyException {
+ if (currentToken != TOK_RPAR)
+ throw new PropertyException("expected )");
+ next();
}
- next();
- return prop;
- }
-
- /**
- * Parse a comma separated list of function arguments. Each argument
- * may itself be an expression. This method consumes the closing right
- * parenthesis of the argument list.
- * @param nbArgs The number of arguments expected by the function.
- * @return An array of Property objects representing the arguments
- * found.
- * @throws PropertyException If the number of arguments found isn't equal
- * to the number expected.
- */
- Property[] parseArgs(int nbArgs) throws PropertyException {
- Property[] args = new Property[nbArgs];
- Property prop;
- int i=0;
- if (currentToken == TOK_RPAR) {
- // No args: func()
- next();
+
+ /**
+ * Try to parse a primary expression and return the
+ * resulting Property.
+ * A primary expression is either a parenthesized expression or an
+ * expression representing a primitive Property datatype, such as a
+ * string literal, an NCname, a number or a unit expression, or a
+ * function call expression.
+ */
+ private Property parsePrimaryExpr() throws PropertyException {
+ Property prop;
+ switch (currentToken) {
+ case TOK_LPAR:
+ next();
+ prop = parseAdditiveExpr();
+ expectRpar();
+ return prop;
+
+ case TOK_LITERAL:
+ prop = new StringProperty(currentTokenValue);
+ break;
+
+ case TOK_NCNAME:
+ // Interpret this in context of the property or do it later?
+ prop = new NCnameProperty(currentTokenValue);
+ break;
+
+ case TOK_FLOAT:
+ prop = new NumberProperty(new Double(currentTokenValue));
+ break;
+
+ case TOK_INTEGER:
+ prop = new NumberProperty(new Integer(currentTokenValue));
+ break;
+
+ case TOK_PERCENT:
+ /*
+ * Get the length base value object from the Maker. If null, then
+ * this property can't have % values. Treat it as a real number.
+ */
+ double pcval =
+ new Double(currentTokenValue.substring(0, currentTokenValue.length() - 1)).doubleValue()
+ / 100.0;
+ // LengthBase lbase = this.propInfo.getPercentLengthBase();
+ PercentBase pcBase = this.propInfo.getPercentBase();
+ if (pcBase != null) {
+ if (pcBase.getDimension() == 0) {
+ prop = new NumberProperty(pcval * pcBase.getBaseValue());
+ } else if (pcBase.getDimension() == 1) {
+ prop = new LengthProperty(new PercentLength(pcval,
+ pcBase));
+ } else {
+ throw new PropertyException("Illegal percent dimension value");
+ }
+ } else {
+ // WARNING? Interpret as a decimal fraction, eg. 50% = .5
+ prop = new NumberProperty(pcval);
+ }
+ break;
+
+ case TOK_NUMERIC:
+ // A number plus a valid unit name.
+ int numLen = currentTokenValue.length() - currentUnitLength;
+ String unitPart = currentTokenValue.substring(numLen);
+ Double numPart = new Double(currentTokenValue.substring(0,
+ numLen));
+ Length length = null;
+ if (unitPart.equals(RELUNIT)) {
+ length = new Length(numPart.doubleValue(),
+ propInfo.currentFontSize());
+ } else
+ length = new Length(numPart.doubleValue(), unitPart);
+ if (length == null) {
+ throw new PropertyException("unrecognized unit name: "
+ + currentTokenValue);
+ } else
+ prop = new LengthProperty(length);
+ break;
+
+ case TOK_COLORSPEC:
+ prop = new ColorTypeProperty(new ColorType(currentTokenValue));
+ break;
+
+ case TOK_FUNCTION_LPAR: {
+ Function function =
+ (Function)functionTable.get(currentTokenValue);
+ if (function == null) {
+ throw new PropertyException("no such function: "
+ + currentTokenValue);
+ }
+ next();
+ // Push new function (for function context: getPercentBase())
+ propInfo.pushFunction(function);
+ prop = function.eval(parseArgs(function.nbArgs()), propInfo);
+ propInfo.popFunction();
+ return prop;
+ }
+ default:
+ throw new PropertyException("syntax error");
+ }
+ next();
+ return prop;
+ }
+
+ /**
+ * Parse a comma separated list of function arguments. Each argument
+ * may itself be an expression. This method consumes the closing right
+ * parenthesis of the argument list.
+ * @param nbArgs The number of arguments expected by the function.
+ * @return An array of Property objects representing the arguments
+ * found.
+ * @throws PropertyException If the number of arguments found isn't equal
+ * to the number expected.
+ */
+ Property[] parseArgs(int nbArgs) throws PropertyException {
+ Property[] args = new Property[nbArgs];
+ Property prop;
+ int i = 0;
+ if (currentToken == TOK_RPAR) {
+ // No args: func()
+ next();
+ } else {
+ while (true) {
+
+ prop = parseAdditiveExpr();
+ if (i < nbArgs) {
+ args[i++] = prop;
+ }
+ // ignore extra args
+ if (currentToken != TOK_COMMA)
+ break;
+ next();
+ }
+ expectRpar();
+ }
+ if (nbArgs != i) {
+ throw new PropertyException("Wrong number of args for function");
+ }
+ return args;
}
- else {
- while(true) {
-
- prop = parseAdditiveExpr();
- if (i < nbArgs) {
- args[i++] = prop;
- }
- // ignore extra args
- if (currentToken != TOK_COMMA)
- break;
- next();
- }
- expectRpar();
+
+
+ /**
+ * Evaluate an addition operation. If either of the arguments is null,
+ * this means that it wasn't convertible to a Numeric value.
+ * @param op1 A Numeric object (Number or Length-type object)
+ * @param op2 A Numeric object (Number or Length-type object)
+ * @return A new NumericProperty object holding an object which represents
+ * the sum of the two operands.
+ * @throws PropertyException If either operand is null.
+ */
+ private Property evalAddition(Numeric op1,
+ Numeric op2) throws PropertyException {
+ if (op1 == null || op2 == null)
+ throw new PropertyException("Non numeric operand in addition");
+ return new NumericProperty(op1.add(op2));
+ }
+
+ /**
+ * Evaluate a subtraction operation. If either of the arguments is null,
+ * this means that it wasn't convertible to a Numeric value.
+ * @param op1 A Numeric object (Number or Length-type object)
+ * @param op2 A Numeric object (Number or Length-type object)
+ * @return A new NumericProperty object holding an object which represents
+ * the difference of the two operands.
+ * @throws PropertyException If either operand is null.
+ */
+ private Property evalSubtraction(Numeric op1,
+ Numeric op2) throws PropertyException {
+ if (op1 == null || op2 == null)
+ throw new PropertyException("Non numeric operand in subtraction");
+ return new NumericProperty(op1.subtract(op2));
}
- if (nbArgs != i) {
- throw new PropertyException("Wrong number of args for function");
+
+ /**
+ * Evaluate a unary minus operation. If the argument is null,
+ * this means that it wasn't convertible to a Numeric value.
+ * @param op A Numeric object (Number or Length-type object)
+ * @return A new NumericProperty object holding an object which represents
+ * the negative of the operand (multiplication by *1).
+ * @throws PropertyException If the operand is null.
+ */
+ private Property evalNegate(Numeric op) throws PropertyException {
+ if (op == null)
+ throw new PropertyException("Non numeric operand to unary minus");
+ return new NumericProperty(op.multiply(negOne));
+ }
+
+ /**
+ * Evaluate a multiplication operation. If either of the arguments is null,
+ * this means that it wasn't convertible to a Numeric value.
+ * @param op1 A Numeric object (Number or Length-type object)
+ * @param op2 A Numeric object (Number or Length-type object)
+ * @return A new NumericProperty object holding an object which represents
+ * the product of the two operands.
+ * @throws PropertyException If either operand is null.
+ */
+ private Property evalMultiply(Numeric op1,
+ Numeric op2) throws PropertyException {
+ if (op1 == null || op2 == null)
+ throw new PropertyException("Non numeric operand in multiplication");
+ return new NumericProperty(op1.multiply(op2));
+ }
+
+
+ /**
+ * Evaluate a division operation. If either of the arguments is null,
+ * this means that it wasn't convertible to a Numeric value.
+ * @param op1 A Numeric object (Number or Length-type object)
+ * @param op2 A Numeric object (Number or Length-type object)
+ * @return A new NumericProperty object holding an object which represents
+ * op1 divided by op2.
+ * @throws PropertyException If either operand is null.
+ */
+ private Property evalDivide(Numeric op1,
+ Numeric op2) throws PropertyException {
+ if (op1 == null || op2 == null)
+ throw new PropertyException("Non numeric operand in division");
+ return new NumericProperty(op1.divide(op2));
+ }
+
+ /**
+ * Evaluate a modulo operation. If either of the arguments is null,
+ * this means that it wasn't convertible to a Number value.
+ * @param op1 A Number object
+ * @param op2 A Number object
+ * @return A new NumberProperty object holding an object which represents
+ * op1 mod op2.
+ * @throws PropertyException If either operand is null.
+ */
+ private Property evalModulo(Number op1,
+ Number op2) throws PropertyException {
+ if (op1 == null || op2 == null)
+ throw new PropertyException("Non number operand to modulo");
+ return new NumberProperty(op1.doubleValue() % op2.doubleValue());
}
- return args;
- }
-
-
- /**
- * Evaluate an addition operation. If either of the arguments is null,
- * this means that it wasn't convertible to a Numeric value.
- * @param op1 A Numeric object (Number or Length-type object)
- * @param op2 A Numeric object (Number or Length-type object)
- * @return A new NumericProperty object holding an object which represents
- * the sum of the two operands.
- * @throws PropertyException If either operand is null.
- */
- private Property evalAddition(Numeric op1, Numeric op2)
- throws PropertyException {
- if (op1 == null || op2 == null)
- throw new PropertyException("Non numeric operand in addition");
- return new NumericProperty(op1.add(op2));
- }
-
- /**
- * Evaluate a subtraction operation. If either of the arguments is null,
- * this means that it wasn't convertible to a Numeric value.
- * @param op1 A Numeric object (Number or Length-type object)
- * @param op2 A Numeric object (Number or Length-type object)
- * @return A new NumericProperty object holding an object which represents
- * the difference of the two operands.
- * @throws PropertyException If either operand is null.
- */
- private Property evalSubtraction(Numeric op1, Numeric op2)
- throws PropertyException {
- if (op1 == null || op2 == null)
- throw new PropertyException("Non numeric operand in subtraction");
- return new NumericProperty(op1.subtract(op2));
- }
-
- /**
- * Evaluate a unary minus operation. If the argument is null,
- * this means that it wasn't convertible to a Numeric value.
- * @param op A Numeric object (Number or Length-type object)
- * @return A new NumericProperty object holding an object which represents
- * the negative of the operand (multiplication by *1).
- * @throws PropertyException If the operand is null.
- */
- private Property evalNegate(Numeric op) throws PropertyException {
- if (op == null)
- throw new PropertyException("Non numeric operand to unary minus");
- return new NumericProperty(op.multiply(negOne));
- }
-
- /**
- * Evaluate a multiplication operation. If either of the arguments is null,
- * this means that it wasn't convertible to a Numeric value.
- * @param op1 A Numeric object (Number or Length-type object)
- * @param op2 A Numeric object (Number or Length-type object)
- * @return A new NumericProperty object holding an object which represents
- * the product of the two operands.
- * @throws PropertyException If either operand is null.
- */
- private Property evalMultiply(Numeric op1, Numeric op2)
- throws PropertyException {
- if (op1 == null || op2 == null)
- throw new PropertyException("Non numeric operand in multiplication");
- return new NumericProperty(op1.multiply(op2));
- }
-
-
- /**
- * Evaluate a division operation. If either of the arguments is null,
- * this means that it wasn't convertible to a Numeric value.
- * @param op1 A Numeric object (Number or Length-type object)
- * @param op2 A Numeric object (Number or Length-type object)
- * @return A new NumericProperty object holding an object which represents
- * op1 divided by op2.
- * @throws PropertyException If either operand is null.
- */
- private Property evalDivide(Numeric op1, Numeric op2)
- throws PropertyException {
- if (op1 == null || op2 == null)
- throw new PropertyException("Non numeric operand in division");
- return new NumericProperty(op1.divide(op2));
- }
-
- /**
- * Evaluate a modulo operation. If either of the arguments is null,
- * this means that it wasn't convertible to a Number value.
- * @param op1 A Number object
- * @param op2 A Number object
- * @return A new NumberProperty object holding an object which represents
- * op1 mod op2.
- * @throws PropertyException If either operand is null.
- */
- private Property evalModulo(Number op1, Number op2)
- throws PropertyException {
- if (op1 == null || op2 == null)
- throw new PropertyException("Non number operand to modulo");
- return new NumberProperty(op1.doubleValue()%op2.doubleValue());
- }
}
diff --git a/src/org/apache/fop/fo/expr/PropertyTokenizer.java b/src/org/apache/fop/fo/expr/PropertyTokenizer.java
index fc3094403..025c68695 100644
--- a/src/org/apache/fop/fo/expr/PropertyTokenizer.java
+++ b/src/org/apache/fop/fo/expr/PropertyTokenizer.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
@@ -59,326 +16,329 @@ package org.apache.fop.fo.expr;
*/
class PropertyTokenizer {
- static final int TOK_EOF = 0;
- static final int TOK_NCNAME = TOK_EOF + 1;
- static final int TOK_MULTIPLY = TOK_NCNAME + 1;
- static final int TOK_LPAR = TOK_MULTIPLY + 1;
- static final int TOK_RPAR = TOK_LPAR + 1;
- static final int TOK_LITERAL = TOK_RPAR + 1;
- static final int TOK_NUMBER = TOK_LITERAL + 1;
- static final int TOK_FUNCTION_LPAR = TOK_NUMBER + 1;
- static final int TOK_PLUS = TOK_FUNCTION_LPAR + 1;
- static final int TOK_MINUS = TOK_PLUS + 1;
- static final int TOK_MOD = TOK_MINUS + 1;
- static final int TOK_DIV = TOK_MOD + 1;
- static final int TOK_NUMERIC = TOK_DIV + 1;
- static final int TOK_COMMA = TOK_NUMERIC + 1;
- static final int TOK_PERCENT = TOK_COMMA + 1;
- static final int TOK_COLORSPEC = TOK_PERCENT + 1;
- static final int TOK_FLOAT = TOK_COLORSPEC + 1;
- static final int TOK_INTEGER = TOK_FLOAT + 1;
+ static final int TOK_EOF = 0;
+ static final int TOK_NCNAME = TOK_EOF + 1;
+ static final int TOK_MULTIPLY = TOK_NCNAME + 1;
+ static final int TOK_LPAR = TOK_MULTIPLY + 1;
+ static final int TOK_RPAR = TOK_LPAR + 1;
+ static final int TOK_LITERAL = TOK_RPAR + 1;
+ static final int TOK_NUMBER = TOK_LITERAL + 1;
+ static final int TOK_FUNCTION_LPAR = TOK_NUMBER + 1;
+ static final int TOK_PLUS = TOK_FUNCTION_LPAR + 1;
+ static final int TOK_MINUS = TOK_PLUS + 1;
+ static final int TOK_MOD = TOK_MINUS + 1;
+ static final int TOK_DIV = TOK_MOD + 1;
+ static final int TOK_NUMERIC = TOK_DIV + 1;
+ static final int TOK_COMMA = TOK_NUMERIC + 1;
+ static final int TOK_PERCENT = TOK_COMMA + 1;
+ static final int TOK_COLORSPEC = TOK_PERCENT + 1;
+ static final int TOK_FLOAT = TOK_COLORSPEC + 1;
+ static final int TOK_INTEGER = TOK_FLOAT + 1;
+
+ int currentToken = TOK_EOF;
+ String currentTokenValue = null;
+ protected int currentUnitLength = 0;
- int currentToken = TOK_EOF;
- String currentTokenValue = null;
- protected int currentUnitLength = 0;
+ private int currentTokenStartIndex = 0;
+ private /* final */ String expr;
+ private int exprIndex = 0;
+ private int exprLength;
+ private boolean recognizeOperator = false;
- private int currentTokenStartIndex = 0;
- private /*final*/ String expr;
- private int exprIndex = 0;
- private int exprLength;
- private boolean recognizeOperator = false;
-
- /**
- * Construct a new PropertyTokenizer object to tokenize the passed
- * String.
- * @param s The Property expressio to tokenize.
- */
- PropertyTokenizer(String s) {
- this.expr = s;
- this.exprLength = s.length();
- }
+ /**
+ * Construct a new PropertyTokenizer object to tokenize the passed
+ * String.
+ * @param s The Property expressio to tokenize.
+ */
+ PropertyTokenizer(String s) {
+ this.expr = s;
+ this.exprLength = s.length();
+ }
+
+ /**
+ * Return the next token in the expression string.
+ * This sets the following package visible variables:
+ * currentToken An enumerated value identifying the recognized token
+ * currentTokenValue A String containing the token contents
+ * currentUnitLength If currentToken = TOK_NUMERIC, the number of
+ * characters in the unit name.
+ * @throws PropertyException If un unrecognized token is encountered.
+ */
+ void next() throws PropertyException {
+ currentTokenValue = null;
+ currentTokenStartIndex = exprIndex;
+ boolean currentMaybeOperator = recognizeOperator;
+ boolean bSawDecimal;
+ recognizeOperator = true;
+ for (; ; ) {
+ if (exprIndex >= exprLength) {
+ currentToken = TOK_EOF;
+ return;
+ }
+ char c = expr.charAt(exprIndex++);
+ switch (c) {
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\n':
+ currentTokenStartIndex = exprIndex;
+ break;
+ case ',':
+ recognizeOperator = false;
+ currentToken = TOK_COMMA;
+ return;
+ case '+':
+ recognizeOperator = false;
+ currentToken = TOK_PLUS;
+ return;
+ case '-':
+ recognizeOperator = false;
+ currentToken = TOK_MINUS;
+ return;
+ case '(':
+ currentToken = TOK_LPAR;
+ recognizeOperator = false;
+ return;
+ case ')':
+ currentToken = TOK_RPAR;
+ return;
+ case '"':
+ case '\'':
+ exprIndex = expr.indexOf(c, exprIndex);
+ if (exprIndex < 0) {
+ exprIndex = currentTokenStartIndex + 1;
+ throw new PropertyException("missing quote");
+ }
+ currentTokenValue = expr.substring(currentTokenStartIndex
+ + 1, exprIndex++);
+ currentToken = TOK_LITERAL;
+ return;
+ case '*':
+ /*
+ * if (currentMaybeOperator) {
+ * recognizeOperator = false;
+ */
+ currentToken = TOK_MULTIPLY;
+ /*
+ * }
+ * else
+ * throw new PropertyException("illegal operator *");
+ */
+ return;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ scanDigits();
+ if (exprIndex < exprLength && expr.charAt(exprIndex) == '.') {
+ exprIndex++;
+ bSawDecimal = true;
+ if (exprIndex < exprLength
+ && isDigit(expr.charAt(exprIndex))) {
+ exprIndex++;
+ scanDigits();
+ }
+ } else
+ bSawDecimal = false;
+ if (exprIndex < exprLength && expr.charAt(exprIndex) == '%') {
+ exprIndex++;
+ currentToken = TOK_PERCENT;
+ } else {
+ // Check for possible unit name following number
+ currentUnitLength = exprIndex;
+ scanName();
+ currentUnitLength = exprIndex - currentUnitLength;
+ currentToken = (currentUnitLength > 0) ? TOK_NUMERIC
+ : (bSawDecimal ? TOK_FLOAT : TOK_INTEGER);
+ }
+ currentTokenValue = expr.substring(currentTokenStartIndex,
+ exprIndex);
+ return;
- /**
- * Return the next token in the expression string.
- * This sets the following package visible variables:
- * currentToken An enumerated value identifying the recognized token
- * currentTokenValue A String containing the token contents
- * currentUnitLength If currentToken = TOK_NUMERIC, the number of
- * characters in the unit name.
- * @throws PropertyException If un unrecognized token is encountered.
- */
- void next() throws PropertyException {
- currentTokenValue = null;
- currentTokenStartIndex = exprIndex;
- boolean currentMaybeOperator = recognizeOperator;
- boolean bSawDecimal ;
- recognizeOperator = true;
- for (;;) {
- if (exprIndex >= exprLength) {
- currentToken = TOK_EOF;
- return;
- }
- char c = expr.charAt(exprIndex++);
- switch (c) {
- case ' ':
- case '\t':
- case '\r':
- case '\n':
- currentTokenStartIndex = exprIndex;
- break;
- case ',':
- recognizeOperator = false;
- currentToken = TOK_COMMA;
- return;
- case '+':
- recognizeOperator = false;
- currentToken = TOK_PLUS;
- return;
- case '-':
- recognizeOperator = false;
- currentToken = TOK_MINUS;
- return;
- case '(':
- currentToken = TOK_LPAR;
- recognizeOperator = false;
- return;
- case ')':
- currentToken = TOK_RPAR;
- return;
- case '"':
- case '\'':
- exprIndex = expr.indexOf(c, exprIndex);
- if (exprIndex < 0) {
- exprIndex = currentTokenStartIndex + 1;
- throw new PropertyException("missing quote");
- }
- currentTokenValue = expr.substring(currentTokenStartIndex + 1,
- exprIndex++);
- currentToken = TOK_LITERAL;
- return;
- case '*':
- /*if (currentMaybeOperator) {
- recognizeOperator = false;*/
- currentToken = TOK_MULTIPLY;
- /*}
- else
- throw new PropertyException("illegal operator *");*/
- return;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- scanDigits();
- if (exprIndex < exprLength
- && expr.charAt(exprIndex) == '.') {
- exprIndex++;
- bSawDecimal=true;
- if (exprIndex < exprLength
- && isDigit(expr.charAt(exprIndex))) {
- exprIndex++;
- scanDigits();
- }
- }
- else bSawDecimal=false;
- if (exprIndex < exprLength && expr.charAt(exprIndex) == '%') {
- exprIndex++;
- currentToken = TOK_PERCENT ;
- }
- else {
- // Check for possible unit name following number
- currentUnitLength = exprIndex;
- scanName();
- currentUnitLength = exprIndex-currentUnitLength;
- currentToken = (currentUnitLength>0)? TOK_NUMERIC :
- (bSawDecimal? TOK_FLOAT : TOK_INTEGER) ;
- }
- currentTokenValue = expr.substring(currentTokenStartIndex,
- exprIndex);
- return;
+ case '.':
+ if (exprIndex < exprLength
+ && isDigit(expr.charAt(exprIndex))) {
+ ++exprIndex;
+ scanDigits();
+ if (exprIndex < exprLength
+ && expr.charAt(exprIndex) == '%') {
+ exprIndex++;
+ currentToken = TOK_PERCENT;
+ } else {
+ // Check for possible unit name following number
+ currentUnitLength = exprIndex;
+ scanName();
+ currentUnitLength = exprIndex - currentUnitLength;
+ currentToken = (currentUnitLength > 0) ? TOK_NUMERIC
+ : TOK_FLOAT;
+ }
+ currentTokenValue = expr.substring(currentTokenStartIndex,
+ exprIndex);
+ return;
+ }
+ throw new PropertyException("illegal character '.'");
- case '.':
- if (exprIndex < exprLength && isDigit(expr.charAt(exprIndex))) {
- ++exprIndex;
- scanDigits();
- if (exprIndex < exprLength && expr.charAt(exprIndex) == '%') {
- exprIndex++;
- currentToken = TOK_PERCENT ;
- }
- else {
- // Check for possible unit name following number
- currentUnitLength = exprIndex;
- scanName();
- currentUnitLength = exprIndex-currentUnitLength;
- currentToken = (currentUnitLength>0)? TOK_NUMERIC : TOK_FLOAT;
- }
- currentTokenValue = expr.substring(currentTokenStartIndex,
- exprIndex);
- return;
- }
- throw new PropertyException("illegal character '.'");
+ case '#': // Start of color value
+ if (exprIndex < exprLength
+ && isHexDigit(expr.charAt(exprIndex))) {
+ ++exprIndex;
+ scanHexDigits();
+ currentToken = TOK_COLORSPEC;
+ currentTokenValue = expr.substring(currentTokenStartIndex,
+ exprIndex);
+ // Probably should have some multiple of 3 for length!
+ return;
+ } else
+ throw new PropertyException("illegal character '#'");
- case '#': // Start of color value
- if (exprIndex < exprLength && isHexDigit(expr.charAt(exprIndex))) {
- ++exprIndex;
- scanHexDigits();
- currentToken = TOK_COLORSPEC;
- currentTokenValue = expr.substring(currentTokenStartIndex,
- exprIndex);
- // Probably should have some multiple of 3 for length!
- return;
- }
- else throw new PropertyException("illegal character '#'");
-
- default:
- --exprIndex;
- scanName();
- if (exprIndex == currentTokenStartIndex)
- throw new PropertyException("illegal character");
- currentTokenValue = expr.substring(currentTokenStartIndex,
- exprIndex);
- // if (currentMaybeOperator) {
- if (currentTokenValue.equals("mod")) {
- currentToken = TOK_MOD;
- return;
- }
- else if (currentTokenValue.equals("div")) {
- currentToken = TOK_DIV;
- return;
- }
- /*else
- throw new PropertyException("unrecognized operator name");
- recognizeOperator = false;
- return;
- }*/
- if (followingParen()) {
- currentToken = TOK_FUNCTION_LPAR;
- recognizeOperator = false;
- }
- else {
- currentToken = TOK_NCNAME;
- recognizeOperator = false;
- }
- return;
- }
+ default:
+ --exprIndex;
+ scanName();
+ if (exprIndex == currentTokenStartIndex)
+ throw new PropertyException("illegal character");
+ currentTokenValue = expr.substring(currentTokenStartIndex,
+ exprIndex);
+ // if (currentMaybeOperator) {
+ if (currentTokenValue.equals("mod")) {
+ currentToken = TOK_MOD;
+ return;
+ } else if (currentTokenValue.equals("div")) {
+ currentToken = TOK_DIV;
+ return;
+ }
+ /*
+ * else
+ * throw new PropertyException("unrecognized operator name");
+ * recognizeOperator = false;
+ * return;
+ * }
+ */
+ if (followingParen()) {
+ currentToken = TOK_FUNCTION_LPAR;
+ recognizeOperator = false;
+ } else {
+ currentToken = TOK_NCNAME;
+ recognizeOperator = false;
+ }
+ return;
+ }
+ }
}
- }
- /**
- * Attempt to recognize a valid NAME token in the input expression.
- */
- private void scanName() {
- if (exprIndex < exprLength
- && isNameStartChar(expr.charAt(exprIndex)))
- while (++exprIndex < exprLength
- && isNameChar(expr.charAt(exprIndex)))
- ;
- }
+ /**
+ * Attempt to recognize a valid NAME token in the input expression.
+ */
+ private void scanName() {
+ if (exprIndex < exprLength && isNameStartChar(expr.charAt(exprIndex)))
+ while (++exprIndex < exprLength
+ && isNameChar(expr.charAt(exprIndex)));
+ }
- /**
- * Attempt to recognize a valid sequence of decimal digits in the
- * input expression.
- */
- private void scanDigits() {
- while (exprIndex < exprLength && isDigit(expr.charAt(exprIndex)))
- exprIndex++;
- }
+ /**
+ * Attempt to recognize a valid sequence of decimal digits in the
+ * input expression.
+ */
+ private void scanDigits() {
+ while (exprIndex < exprLength && isDigit(expr.charAt(exprIndex)))
+ exprIndex++;
+ }
- /**
- * Attempt to recognize a valid sequence of hexadecimal digits in the
- * input expression.
- */
- private void scanHexDigits() {
- while (exprIndex < exprLength && isHexDigit(expr.charAt(exprIndex)))
- exprIndex++;
- }
+ /**
+ * Attempt to recognize a valid sequence of hexadecimal digits in the
+ * input expression.
+ */
+ private void scanHexDigits() {
+ while (exprIndex < exprLength && isHexDigit(expr.charAt(exprIndex)))
+ exprIndex++;
+ }
- /**
- * Return a boolean value indicating whether the following non-whitespace
- * character is an opening parenthesis.
- */
- private boolean followingParen() {
- for (int i = exprIndex; i < exprLength; i++) {
- switch (expr.charAt(i)) {
- case '(':
- exprIndex = i + 1;
- return true;
- case ' ':
- case '\r':
- case '\n':
- case '\t':
- break;
- default:
- return false;
- }
+ /**
+ * Return a boolean value indicating whether the following non-whitespace
+ * character is an opening parenthesis.
+ */
+ private boolean followingParen() {
+ for (int i = exprIndex; i < exprLength; i++) {
+ switch (expr.charAt(i)) {
+ case '(':
+ exprIndex = i + 1;
+ return true;
+ case ' ':
+ case '\r':
+ case '\n':
+ case '\t':
+ break;
+ default:
+ return false;
+ }
+ }
+ return false;
}
- return false;
- }
- static private final String nameStartChars =
- "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- static private final String nameChars = ".-0123456789";
- static private final String digits = "0123456789";
- static private final String hexchars = digits + "abcdefABCDEF";
+ static private final String nameStartChars =
+ "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ static private final String nameChars = ".-0123456789";
+ static private final String digits = "0123456789";
+ static private final String hexchars = digits + "abcdefABCDEF";
- /**
- * Return a boolean value indicating whether the argument is a
- * decimal digit (0-9).
- * @param c The character to check
- */
- private static final boolean isDigit(char c) {
- return digits.indexOf(c) >= 0;
- }
+ /**
+ * Return a boolean value indicating whether the argument is a
+ * decimal digit (0-9).
+ * @param c The character to check
+ */
+ private static final boolean isDigit(char c) {
+ return digits.indexOf(c) >= 0;
+ }
- /**
- * Return a boolean value indicating whether the argument is a
- * hexadecimal digit (0-9, A-F, a-f).
- * @param c The character to check
- */
- private static final boolean isHexDigit(char c) {
- return hexchars.indexOf(c) >=0;
- }
+ /**
+ * Return a boolean value indicating whether the argument is a
+ * hexadecimal digit (0-9, A-F, a-f).
+ * @param c The character to check
+ */
+ private static final boolean isHexDigit(char c) {
+ return hexchars.indexOf(c) >= 0;
+ }
- /**
- * Return a boolean value indicating whether the argument is whitespace
- * as defined by XSL (space, newline, CR, tab).
- * @param c The character to check
- */
- private static final boolean isSpace(char c) {
- switch(c) {
- case ' ':
- case '\r':
- case '\n':
- case '\t':
- return true;
+ /**
+ * Return a boolean value indicating whether the argument is whitespace
+ * as defined by XSL (space, newline, CR, tab).
+ * @param c The character to check
+ */
+ private static final boolean isSpace(char c) {
+ switch (c) {
+ case ' ':
+ case '\r':
+ case '\n':
+ case '\t':
+ return true;
+ }
+ return false;
}
- return false;
- }
- /**
- * Return a boolean value indicating whether the argument is a valid name
- * start character, ie. can start a NAME as defined by XSL.
- * @param c The character to check
- */
- private static final boolean isNameStartChar(char c) {
- return nameStartChars.indexOf(c) >= 0 || c >= 0x80;
- }
+ /**
+ * Return a boolean value indicating whether the argument is a valid name
+ * start character, ie. can start a NAME as defined by XSL.
+ * @param c The character to check
+ */
+ private static final boolean isNameStartChar(char c) {
+ return nameStartChars.indexOf(c) >= 0 || c >= 0x80;
+ }
- /**
- * Return a boolean value indicating whether the argument is a valid name
- * character, ie. can occur in a NAME as defined by XSL.
- * @param c The character to check
- */
- private static final boolean isNameChar(char c) {
- return nameStartChars.indexOf(c) >= 0 ||
- nameChars.indexOf(c) >= 0 || c >= 0x80;
- }
+ /**
+ * Return a boolean value indicating whether the argument is a valid name
+ * character, ie. can occur in a NAME as defined by XSL.
+ * @param c The character to check
+ */
+ private static final boolean isNameChar(char c) {
+ return nameStartChars.indexOf(c) >= 0 || nameChars.indexOf(c) >= 0
+ || c >= 0x80;
+ }
}
diff --git a/src/org/apache/fop/fo/expr/RGBColorFunction.java b/src/org/apache/fop/fo/expr/RGBColorFunction.java
index 16f619494..6627fb36d 100644
--- a/src/org/apache/fop/fo/expr/RGBColorFunction.java
+++ b/src/org/apache/fop/fo/expr/RGBColorFunction.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
@@ -57,42 +14,53 @@ import org.apache.fop.datatypes.ColorType;
import org.apache.fop.datatypes.PercentBase;
class RGBColorFunction extends FunctionBase {
- public int nbArgs() { return 3; }
+ public int nbArgs() {
+ return 3;
+ }
+
+ /**
+ * Return an object which implements the PercentBase interface.
+ * Percents in arguments to this function are interpreted relative
+ * to 255.
+ */
+ public PercentBase getPercentBase() {
+ return new RGBPercentBase();
+ }
- /**
- * Return an object which implements the PercentBase interface.
- * Percents in arguments to this function are interpreted relative
- * to 255.
- */
- public PercentBase getPercentBase() { return new RGBPercentBase(); }
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ // Using CSS rules, numbers are either supposed to be 0-255
+ // or percentage values. If percentages value, they've already
+ // been converted to reals.
+ float[] cfvals = new float[3]; // RGB
+ for (int i = 0; i < 3; i++) {
+ Number cval = args[i].getNumber();
+ if (cval == null) {
+ throw new PropertyException("Argument to rgb() must be a Number");
+ }
+ float colorVal = cval.floatValue() / 255f;
+ if (colorVal < 0.0 || colorVal > 255.0) {
+ throw new PropertyException("Arguments to rgb() must normalize to the range 0 to 1");
+ }
+ cfvals[i] = colorVal;
+ }
+ return new ColorTypeProperty(new ColorType(cfvals[0], cfvals[1],
+ cfvals[2]));
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- // Using CSS rules, numbers are either supposed to be 0-255
- // or percentage values. If percentages value, they've already
- // been converted to reals.
- float[] cfvals = new float[3]; // RGB
- for (int i=0; i<3; i++) {
- Number cval = args[i].getNumber();
- if (cval == null) {
- throw new PropertyException("Argument to rgb() must be a Number");
- }
- float colorVal = cval.floatValue()/255f;
- if (colorVal < 0.0 || colorVal > 255.0) {
- throw new PropertyException("Arguments to rgb() must normalize to the range 0 to 1");
- }
- cfvals[i] = colorVal;
}
- return new ColorTypeProperty( new ColorType(cfvals[0],
- cfvals[1],
- cfvals[2]));
- }
+ static class RGBPercentBase implements PercentBase {
+ public int getDimension() {
+ return 0;
+ }
+
+ public double getBaseValue() {
+ return 255f;
+ }
- static class RGBPercentBase implements PercentBase {
- public int getDimension() { return 0; }
- public double getBaseValue() { return 255f ; }
- public int getBaseLength() { return 0; }
- }
+ public int getBaseLength() {
+ return 0;
+ }
+
+ }
}
diff --git a/src/org/apache/fop/fo/expr/RoundFunction.java b/src/org/apache/fop/fo/expr/RoundFunction.java
index 43cf2e3b1..81d51b113 100644
--- a/src/org/apache/fop/fo/expr/RoundFunction.java
+++ b/src/org/apache/fop/fo/expr/RoundFunction.java
@@ -1,53 +1,10 @@
-/*-- $Id$ --
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "FOP" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- apache@apache.org.
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- James Tauber <jtauber@jtauber.com>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
*/
+
package org.apache.fop.fo.expr;
@@ -55,18 +12,20 @@ import org.apache.fop.fo.Property;
import org.apache.fop.fo.NumberProperty;
class RoundFunction extends FunctionBase {
- public int nbArgs() { return 1; }
+ public int nbArgs() {
+ return 1;
+ }
+
+ public Property eval(Property[] args,
+ PropertyInfo pInfo) throws PropertyException {
+ Number dbl = args[0].getNumber();
+ if (dbl == null)
+ throw new PropertyException("Non number operand to round function");
+ double n = dbl.doubleValue();
+ double r = Math.floor(n + 0.5);
+ if (r == 0.0 && n < 0.0)
+ r = -r; // round(-0.2) returns -0 not 0
+ return new NumberProperty(r);
+ }
- public Property eval(Property[] args, PropertyInfo pInfo)
- throws PropertyException
- {
- Number dbl = args[0].getNumber();
- if (dbl == null)
- throw new PropertyException("Non number operand to round function");
- double n = dbl.doubleValue();
- double r = Math.floor(n + 0.5);
- if (r == 0.0 && n < 0.0)
- r = -r; // round(-0.2) returns -0 not 0
- return new NumberProperty(r);
- }
}