cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java
pbwest 2002/11/21 18:07:04 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java Log: Correcting RCS problems. Revision ChangesPath No revision No revision 1.5.2.19 +2 -2 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.18 retrieving revision 1.5.2.19 diff -u -r1.5.2.18 -r1.5.2.19 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java
pbwest 2002/11/17 02:00:23 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java Log: Removed debug println. Revision ChangesPath No revision No revision 1.5.2.18 +2 -3 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.17 retrieving revision 1.5.2.18 diff -u -r1.5.2.17 -r1.5.2.18 --- PropertyParser.java 11 Nov 2002 16:47:01 - 1.5.2.17 +++ PropertyParser.java 17 Nov 2002 10:00:23 - 1.5.2.18 @@ -712,7 +712,6 @@ // Color functions if (function.equals("rgb")) { // Currently arguments must all be integers. -System.out.println("rgb: " + getExpr()); PropertyValue[] args = parseArgs(3); switch (args[0].getType()) { case PropertyValue.INTEGER: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java
pbwest 2002/11/11 08:47:01 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java Log: Extend handling of numeric args to functions to include IntegerType arguments. Add funcNumericErrorStr(). Modified makeEms arg list. Revision ChangesPath No revision No revision 1.5.2.17 +100 -16 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.16 retrieving revision 1.5.2.17 diff -u -r1.5.2.16 -r1.5.2.17 --- PropertyParser.java 21 Oct 2002 16:07:31 - 1.5.2.16 +++ PropertyParser.java 11 Nov 2002 16:47:01 - 1.5.2.17 @@ -240,6 +240,16 @@ + getExpr(); } + +/** + * Generate an function numeric argument error string. + * @return function numeric argument error message. + */ +private String funcNumericErrorStr() { +return "Function requires Numeric or integer argument: " ++ getExpr(); +} + /** * Try to parse an addition or subtraction expression and return the * resulting PropertyValue. @@ -558,7 +568,7 @@ Double.parseDouble(currentTokenValue)); break; case RELATIVE_LENGTH: -prop = Ems.makeEms(property, +prop = Ems.makeEms(node, property, Double.parseDouble(currentTokenValue)); break; @@ -607,45 +617,119 @@ // Numeric functions if (function.equals("floor")) { PropertyValue[] args = parseArgs(1); -prop = new Numeric -(property, ((Numeric)args[0]).floor()); +switch (args[0].getType()) { +case PropertyValue.INTEGER: +args[0] = +new Numeric +(property, ((IntegerType)args[0]).getInt()); +case PropertyValue.NUMERIC: +prop = new Numeric +(property, ((Numeric)args[0]).floor()); +break; +default: +throw new PropertyException(funcNumericErrorStr()); +} break; } if (function.equals("ceiling")) { PropertyValue[] args = parseArgs(1); -prop = new Numeric -(property, ((Numeric)args[0]).ceiling()); +switch (args[0].getType()) { +case PropertyValue.INTEGER: +args[0] = +new Numeric +(property, ((IntegerType)args[0]).getInt()); +case PropertyValue.NUMERIC: +prop = new Numeric +(property, ((Numeric)args[0]).ceiling()); +break; +default: +throw new PropertyException(funcNumericErrorStr()); +} break; } if (function.equals("round")) { PropertyValue[] args = parseArgs(1); -prop = new Numeric -(property, ((Numeric)args[0]).round()); +switch (args[0].getType()) { +case PropertyValue.INTEGER: +args[0] = +new Numeric +(property, ((IntegerType)args[0]).getInt()); +case PropertyValue.NUMERIC: +prop = new Numeric +(property, ((Numeric)args[0]).round()); +break; +default: +throw new PropertyException(funcNumericErrorStr()); +} break; } if (function.equals("min")) { PropertyValue[] args = parseArgs(2); -prop = ((Numeric)args[0]).min((Numeric)args[1]); +switch (args[0].getType()) { +case PropertyValue.INTEGER: +args[0] = +new Numeric +(property, ((IntegerType)args[0]).getInt()); +case PropertyValue.NUMERIC: +prop = ((Numeric)args[0]).min
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java
pbwest 2002/10/21 09:07:32 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java Log: Use PropertyConsts.pconsts singleton. Revision ChangesPath No revision No revision 1.5.2.16 +8 -10 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.15 retrieving revision 1.5.2.16 diff -u -r1.5.2.15 -r1.5.2.16 --- PropertyParser.java 19 Oct 2002 03:42:19 - 1.5.2.15 +++ PropertyParser.java 21 Oct 2002 16:07:31 - 1.5.2.16 @@ -59,8 +59,6 @@ private FOTree foTree; /** The FONode which has initiated this parser */ private FONode node; -public final PropertyConsts propertyConsts = -PropertyConsts.getPropertyConsts(); public PropertyParser(FOTree foTree) { super(); @@ -698,12 +696,12 @@ ((StringType)args[0]).getString()); // If it's a compound, return an InheritedValue object -if (propertyConsts.isCompound(propindex)) { +if (PropertyConsts.pconsts.isCompound(propindex)) { prop = new InheritedValue(property, propindex); break; } // Is it an inherited property? -if (propertyConsts.inheritance(propindex) +if (PropertyConsts.pconsts.inheritance(propindex) == Property.NO) throw new PropertyException ("inherited-property-value: " @@ -732,8 +730,8 @@ PropertyValue[] args = parseArgs(0, 1); if (args.length == 0) { -if (! (propertyConsts.isShorthand(property) - || propertyConsts.isCompound(property))) { +if (! (PropertyConsts.pconsts.isShorthand(property) + || PropertyConsts.pconsts.isCompound(property))) { // develop the function value and return it as // a property. switch (funcType) { @@ -756,8 +754,8 @@ String propname = ncname.getNCName(); int nameindex = PropNames.getPropertyIndex(propname); -if (propertyConsts.isShorthand(nameindex) -|| propertyConsts.isCompound(nameindex)) { +if (PropertyConsts.pconsts.isShorthand(nameindex) +|| PropertyConsts.pconsts.isCompound(nameindex)) { // the argument is a shorthand/compound property - // it must be the same as the property being // assigned to. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java
pbwest 2002/10/18 20:42:19 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java Log: PropertyConsts now instantiated. PropertyConsts data is accessed through a singleton object. getPropertyIndex() moved to PropNames. Properties split into properties.Property and properties.. Revision ChangesPath No revision No revision 1.5.2.15 +14 -12xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.14 retrieving revision 1.5.2.15 diff -u -r1.5.2.14 -r1.5.2.15 --- PropertyParser.java 10 Oct 2002 03:27:01 - 1.5.2.14 +++ PropertyParser.java 19 Oct 2002 03:42:19 - 1.5.2.15 @@ -8,7 +8,7 @@ package org.apache.fop.fo.expr; import org.apache.fop.fo.PropertyConsts; -import org.apache.fop.fo.Properties; +import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.PropNames; import org.apache.fop.fo.FOTree; import org.apache.fop.fo.FONode; @@ -59,6 +59,8 @@ private FOTree foTree; /** The FONode which has initiated this parser */ private FONode node; +public final PropertyConsts propertyConsts = +PropertyConsts.getPropertyConsts(); public PropertyParser(FOTree foTree) { super(); @@ -692,17 +694,17 @@ int propindex = property; PropertyValue[] args = parseArgs(0, 1); if (args.length != 0) -propindex = PropertyConsts.getPropertyIndex( +propindex = PropNames.getPropertyIndex( ((StringType)args[0]).getString()); // If it's a compound, return an InheritedValue object -if (PropertyConsts.isCompound(propindex)) { +if (propertyConsts.isCompound(propindex)) { prop = new InheritedValue(property, propindex); break; } // Is it an inherited property? -if (PropertyConsts.inheritance(propindex) -== Properties.NO) +if (propertyConsts.inheritance(propindex) +== Property.NO) throw new PropertyException ("inherited-property-value: " + PropNames.getPropertyName(propindex) @@ -730,8 +732,8 @@ PropertyValue[] args = parseArgs(0, 1); if (args.length == 0) { -if (! (PropertyConsts.isShorthand(property) - || PropertyConsts.isCompound(property))) { +if (! (propertyConsts.isShorthand(property) + || propertyConsts.isCompound(property))) { // develop the function value and return it as // a property. switch (funcType) { @@ -753,9 +755,9 @@ NCName ncname = (NCName)args[0]; String propname = ncname.getNCName(); int nameindex = -PropertyConsts.getPropertyIndex(propname); -if (PropertyConsts.isShorthand(nameindex) -|| PropertyConsts.isCompound(nameindex)) { +PropNames.getPropertyIndex(propname); +if (propertyConsts.isShorthand(nameindex) +|| propertyConsts.isCompound(nameindex)) { // the argument is a shorthand/compound property - // it must be the same as the property being // assigned to. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java
pbwest 2002/10/09 20:27:01 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java Log: Allow IntegerType PropertyValues as arguments to parseAdditiveExpr() and parseUnaryExpr(). Restructure parseMultiplicativeExpr() to include arithmetic exceptions. Revision ChangesPath No revision No revision 1.5.2.14 +156 -62 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.13 retrieving revision 1.5.2.14 diff -u -r1.5.2.13 -r1.5.2.14 --- PropertyParser.java 9 Oct 2002 06:02:51 - 1.5.2.13 +++ PropertyParser.java 10 Oct 2002 03:27:01 - 1.5.2.14 @@ -232,26 +232,99 @@ } /** + * Generate an arithmetic error string. + * @return arithmetic error message. + */ +private String arithErrorStr() { +return "Arithmetic operator not followed by Numeric or integer: " ++ getExpr(); +} + +/** * Try to parse an addition or subtraction expression and return the * resulting PropertyValue. */ private PropertyValue parseAdditiveExpr() throws PropertyException { // Evaluate and put result on the operand stack -System.out.println("parseAdd"); +//System.out.println("parseAdd"); PropertyValue prop = parseMultiplicativeExpr(); -loop: +PropertyValue pv; +outer: for (; ; ) { -switch (currentToken) { -case PLUS: -next(); -((Numeric)prop).add((Numeric)parseMultiplicativeExpr()); -break; -case MINUS: -next(); -((Numeric)prop).subtract((Numeric)parseMultiplicativeExpr()); -break; +inner: +switch (prop.getType()) { +case PropertyValue.NUMERIC: { +switch (currentToken) { +case PLUS: +next(); +pv = parseMultiplicativeExpr(); +switch (pv.getType()) { +case PropertyValue.NUMERIC: +((Numeric)prop).add((Numeric)pv); +break inner; +case PropertyValue.INTEGER: +((Numeric)prop).add((double) +(((IntegerType)pv).getInt())); +break inner; +default: +throw new PropertyException(arithErrorStr()); +} +case MINUS: +next(); +pv = parseMultiplicativeExpr(); +switch (pv.getType()) { +case PropertyValue.NUMERIC: +((Numeric)prop).subtract((Numeric)pv); +break inner; +case PropertyValue.INTEGER: +((Numeric)prop).subtract((double) + (((IntegerType)pv).getInt())); +break inner; +default: +throw new PropertyException(arithErrorStr()); +} +default: +break outer; +} +} +case PropertyValue.INTEGER: { +int intVal = ((IntegerType)prop).getInt(); +switch (currentToken) { +case PLUS: +next(); +pv = parseMultiplicativeExpr(); +switch (pv.getType()) { +case PropertyValue.NUMERIC: +prop = ((Numeric)pv).add((double)intVal); +break inner; +case PropertyValue.INTEGER: +((IntegerType)prop).setInt(intVal + +((IntegerType)pv).getInt()); +break inner; +default: +throw new PropertyException(arithErrorStr()); +} +case MINUS: +next(); +pv = parseMultiplicativeExpr(); +switch (pv.getType()) { +case PropertyValue.NUMERIC: +((Numeric)pv).add((double)(-intVal)); +prop = ((Numeric)pv).negate(); +break inner; +case PropertyValue.INTEGER: +((Integ
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java PropertyTokenizer.java
pbwest 2002/10/08 23:02:51 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java PropertyTokenizer.java Log: Bug fixes and debugging output. Revision ChangesPath No revision No revision 1.5.2.13 +133 -44 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.12 retrieving revision 1.5.2.13 diff -u -r1.5.2.12 -r1.5.2.13 --- PropertyParser.java 2 Oct 2002 07:23:18 - 1.5.2.12 +++ PropertyParser.java 9 Oct 2002 06:02:51 - 1.5.2.13 @@ -237,6 +237,7 @@ */ private PropertyValue parseAdditiveExpr() throws PropertyException { // Evaluate and put result on the operand stack +System.out.println("parseAdd"); PropertyValue prop = parseMultiplicativeExpr(); loop: for (; ; ) { @@ -261,24 +262,109 @@ * the resulting PropertyValue. */ private PropertyValue parseMultiplicativeExpr() throws PropertyException { +System.out.println("parseMult"); PropertyValue prop = parseUnaryExpr(); -loop: +PropertyValue pv; +outer: +// Outer loop exists to handle a sequence of multiplicative operations +// e.g. 5 * 4 / 2 +// break outer; will terminate the multiplicative expression parsing +// break inner; will look for another trailing multiplicative +// operator. for (; ; ) { -switch (currentToken) { -case DIV: -next(); -((Numeric)prop).divide((Numeric)parseUnaryExpr()); -break; -case MOD: -next(); -((Numeric)prop).mod((Numeric)parseUnaryExpr()); -break; -case MULTIPLY: -next(); -((Numeric)prop).multiply((Numeric)parseUnaryExpr()); -break; +inner: +switch (prop.getType()) { +case PropertyValue.NUMERIC: +switch (currentToken) { +case DIV: +next(); +System.out.println("Dividing.."); +pv = parseUnaryExpr(); +if (pv.getType() == PropertyValue.INTEGER) { +((Numeric)prop).divide +((double)(((IntegerType)pv).getInt())); +break inner; +} // else must be Numeric +((Numeric)prop).divide((Numeric)pv); +break inner; +case MOD: +next(); +pv = parseUnaryExpr(); +if (pv.getType() == PropertyValue.INTEGER) { +((Numeric)prop).mod +((double)(((IntegerType)pv).getInt())); +break inner; +} // else must be Numeric +((Numeric)prop).mod((Numeric)parseUnaryExpr()); +break inner; +case MULTIPLY: +next(); +System.out.println("Multiplying.."); +pv = parseUnaryExpr(); +System.out.println("...by " + pv); +if (pv.getType() == PropertyValue.INTEGER) { +((Numeric)prop).multiply +((double)(((IntegerType)pv).getInt())); +break inner; +} // else must be Numeric +((Numeric)prop).multiply((Numeric)pv); +break inner; +default: +break outer; +} +// N.B. The above case cannot fall through to here +case PropertyValue.INTEGER: +// This code treats all multiplicative operations as implicit +// operations on doubles. It might be reasonable to allow +// an integer multiply. +switch (currentToken) { +case DIV: +next(); +System.out.println("Dividing.."); +pv = parseUnaryExpr(); +if (pv.getType() == PropertyValue.INTEGER) { +prop = new Numeric(property, +(double)(((IntegerType)prop).getInt()) / + ((IntegerType)pv).getInt()); +break inner
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java
pbwest 2002/10/02 00:23:18 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java Log: Add explicit reset()s. Add InheritedValue handling. Access tokenizer expr value via method call. Revision ChangesPath No revision No revision 1.5.2.12 +32 -17xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.11 retrieving revision 1.5.2.12 diff -u -r1.5.2.11 -r1.5.2.12 --- PropertyParser.java 24 Sep 2002 05:26:42 - 1.5.2.11 +++ PropertyParser.java 2 Oct 2002 07:23:18 - 1.5.2.12 @@ -127,11 +127,13 @@ public PropertyValue parse(FONode node, int property, String expr) throws PropertyException { +//System.out.println("-Entering parse:" +// + PropNames.getPropertyName(property) + " " + expr); synchronized (this) { // make sure this parser is available -if (expr != null) // the parser is currently active +if (getExpr() != null) // the parser is currently active throw new PropertyException -("PropertyParser is currently active."); +("PropertyParser is currently active: " + getExpr()); initialize(property, expr); this.node = node; } @@ -149,8 +151,10 @@ // end of the expression - add to list and go if (propList.size() != 0) { propList.add(prop); +reset(); return propList; } else { // list is empty +reset(); return prop; } } @@ -164,8 +168,10 @@ propList.add(prop); } else { // whitespace separates list elements; make a sublist propList.add(parseSublist(prop)); -if (currentToken == EOF) +if (currentToken == EOF) { +reset(); return propList; +} } } } @@ -489,29 +495,38 @@ } // Property value functions +if (currentTokenValue.equals("label-end")) { +PropertyValue[] args = parseArgs(0); +throw new FunctionNotImplementedException("label-end"); +//break; +} +if (currentTokenValue.equals("body-start")) { +PropertyValue[] args = parseArgs(0); +throw new FunctionNotImplementedException("body-start"); +//break; +} if (currentTokenValue.equals("inherited-property-value")) { int propindex = property; PropertyValue[] args = parseArgs(0, 1); if (args.length != 0) propindex = PropertyConsts.getPropertyIndex( ((StringType)args[0]).getString()); -if (PropertyConsts.inheritance(propindex) == Properties.NO) + +// If it's a compound, return an InheritedValue object +if (PropertyConsts.isCompound(propindex)) { +prop = new InheritedValue(property, propindex); +break; +} +// Is it an inherited property? +if (PropertyConsts.inheritance(propindex) +== Properties.NO) throw new PropertyException ("inherited-property-value: " + PropNames.getPropertyName(propindex) + " is not inherited."); -prop = new InheritedValue(property, propindex); +// Not a compound, and inherited - try to resolve it +prop = node.fromParent(property, propindex); break; -} -if (currentTokenValue.equals("label-end")) { -PropertyValue[] args = parseArgs(0); -throw new FunctionNotImplementedException("label-end"); -//break; -} -if (currentTokenValue.equals("body-start")) { -PropertyValue[] args = parseArgs(0); -throw new FunctionNotImplementedException("body-start"); -
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java
pbwest 2002/09/23 22:26:42 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java Log: Invoke parser with FONode arg. Call fromParent() and fromNearestSpecified() methods in FONode. Revision ChangesPath No revision No revision 1.5.2.11 +200 -155 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.10 retrieving revision 1.5.2.11 diff -u -r1.5.2.10 -r1.5.2.11 --- PropertyParser.java 18 Sep 2002 15:35:03 - 1.5.2.10 +++ PropertyParser.java 24 Sep 2002 05:26:42 - 1.5.2.11 @@ -11,6 +11,7 @@ import org.apache.fop.fo.Properties; import org.apache.fop.fo.PropNames; import org.apache.fop.fo.FOTree; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.expr.SystemFontFunction; import org.apache.fop.datatypes.PropertyValue; @@ -56,6 +57,8 @@ /** The FO tree which has initiated this parser */ private FOTree foTree; +/** The FONode which has initiated this parser */ +private FONode node; public PropertyParser(FOTree foTree) { super(); @@ -112,14 +115,16 @@ * * Note: If the property expression String is empty, a StringProperty * object holding an empty String is returned. - * @param property an int containing the property index. + * @param node - the FONode for which the property expression + * is being resolved. + * @param property - an int containing the property index. * which the property expression is to be evaluated. - * @param expr The specified value (attribute on the xml element). - * @return A PropertyValue holding the parsed result. - * @throws PropertyException If the "expr" cannot be parsed as a + * @param expr - the specified value (attribute on the xml element). + * @return a PropertyValue holding the parsed result. + * @throws PropertyException if the "expr" cannot be parsed as a * PropertyValue. */ -public PropertyValue parse(int property, String expr) +public PropertyValue parse(FONode node, int property, String expr) throws PropertyException { synchronized (this) { @@ -128,6 +133,7 @@ throw new PropertyException ("PropertyParser is currently active."); initialize(property, expr); +this.node = node; } next(); @@ -167,8 +173,8 @@ /** * Parse a property values sublist - a list of whitespace separated * PropertyValues. - * - * Property value expressions for various properties may contaiin lists + * + * Property value expressions for various properties may contain lists * of values, which may be separated by whitespace or by commas. See, * e.g., 7.6.17 "voice-family" and 7.8.2 "font-family". The shorthands * may also contain lists of elements, generally (or exclusively) @@ -404,164 +410,203 @@ // processing, so, like LPAR processing, next() is not called // and the return from this method must be premature prop = null; -// Numeric functions -if (currentTokenValue.equals("floor")) { -PropertyValue[] args = parseArgs(1); -prop = new Numeric -(property, ((Numeric)args[0]).floor()); -} -else if (currentTokenValue.equals("ceiling")) { -PropertyValue[] args = parseArgs(1); -prop = new Numeric -(property, ((Numeric)args[0]).ceiling()); -} -else if (currentTokenValue.equals("round")) { -PropertyValue[] args = parseArgs(1); -prop = new Numeric -(property, ((Numeric)args[0]).round()); -} -else if (currentTokenValue.equals("min")) { -PropertyValue[] args = parseArgs(2); -prop = new Numeric +int funcType = PropertyValue.NO_TYPE; +do { +// Numeric functions +if (currentTokenValue.equals("floor")) { +PropertyValue[] args = parseArgs(1); +prop = new Numeric +(property, ((Numeric)args[0]).floor()); +break; +} +if (currentTokenValue.equals("ceiling")) { +PropertyValue[] args = parseArgs(1); +prop = new Numeric +
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java SystemFontFunction.java
pbwest 2002/09/18 08:35:03 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java SystemFontFunction.java Log: Changes to import names. Revision ChangesPath No revision No revision 1.5.2.10 +8 -8 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.9 retrieving revision 1.5.2.10 diff -u -r1.5.2.9 -r1.5.2.10 --- PropertyParser.java 16 Sep 2002 05:23:50 - 1.5.2.9 +++ PropertyParser.java 18 Sep 2002 15:35:03 - 1.5.2.10 @@ -13,8 +13,8 @@ import org.apache.fop.fo.FOTree; import org.apache.fop.fo.expr.SystemFontFunction; -import org.apache.fop.fo.expr.PropertyValue; -import org.apache.fop.fo.expr.PropertyValueList; +import org.apache.fop.datatypes.PropertyValue; +import org.apache.fop.datatypes.PropertyValueList; import org.apache.fop.datatypes.Numeric; import org.apache.fop.datatypes.Literal; import org.apache.fop.datatypes.NCName; @@ -26,8 +26,6 @@ import org.apache.fop.datatypes.Frequency; import org.apache.fop.datatypes.Angle; import org.apache.fop.datatypes.Bool; -import org.apache.fop.datatypes.Inherit; -import org.apache.fop.datatypes.InheritedValue; import org.apache.fop.datatypes.Auto; import org.apache.fop.datatypes.None; import org.apache.fop.datatypes.Slash; @@ -35,8 +33,10 @@ import org.apache.fop.datatypes.StringType; import org.apache.fop.datatypes.MimeType; import org.apache.fop.datatypes.UriType; -import org.apache.fop.datatypes.FromParent; -import org.apache.fop.datatypes.FromNearestSpecified; +import org.apache.fop.datatypes.indirect.Inherit; +import org.apache.fop.datatypes.indirect.InheritedValue; +import org.apache.fop.datatypes.indirect.FromParent; +import org.apache.fop.datatypes.indirect.FromNearestSpecified; import java.util.HashMap; 1.1.2.4 +5 -3 xml-fop/src/org/apache/fop/fo/expr/Attic/SystemFontFunction.java Index: SystemFontFunction.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/Attic/SystemFontFunction.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- SystemFontFunction.java 28 Jun 2002 03:32:29 - 1.1.2.3 +++ SystemFontFunction.java 18 Sep 2002 15:35:03 - 1.1.2.4 @@ -13,6 +13,8 @@ import org.apache.fop.fo.expr.PropertyException; import org.apache.fop.fo.expr.FunctionNotImplementedException; import org.apache.fop.datastructs.ROIntArray; +import org.apache.fop.datatypes.PropertyValue; +import org.apache.fop.datatypes.PropertyValueList; /** * Implement the system font function. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java PropertyTokenizer.java
pbwest 2002/07/03 17:59:40 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java PropertyTokenizer.java Log: Added ident keywords Revision ChangesPath No revision No revision 1.5.2.6 +4 -1 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.5 retrieving revision 1.5.2.6 diff -u -r1.5.2.5 -r1.5.2.6 --- PropertyParser.java 26 Jun 2002 15:55:37 - 1.5.2.5 +++ PropertyParser.java 4 Jul 2002 00:59:40 - 1.5.2.6 @@ -49,6 +49,9 @@ */ public class PropertyParser extends PropertyTokenizer { +private static final String tag = "$Name$"; +private static final String revision = "$Revision$"; + /** * This is an attempt to ensure that the restriction on the application of * from-parent() and from-nearest-specified-value() functions to shorthand 1.4.4.3 +4 -1 xml-fop/src/org/apache/fop/fo/expr/PropertyTokenizer.java Index: PropertyTokenizer.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyTokenizer.java,v retrieving revision 1.4.4.2 retrieving revision 1.4.4.3 diff -u -r1.4.4.2 -r1.4.4.3 --- PropertyTokenizer.java23 Jun 2002 15:02:18 - 1.4.4.2 +++ PropertyTokenizer.java4 Jul 2002 00:59:40 - 1.4.4.3 @@ -19,6 +19,9 @@ */ class PropertyTokenizer { +private static final String tag = "$Name$"; +private static final String revision = "$Revision$"; + /* * Maintain the numbering of this list in (X)Emacs by issuing * a shell command on the region with replacement (M-1 M-|). Use - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java
pbwest 2002/06/26 08:55:38 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java Log: Fix typo in systemFontCharacteristic code Revision ChangesPath No revision No revision 1.5.2.5 +2 -2 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.4 retrieving revision 1.5.2.5 diff -u -r1.5.2.4 -r1.5.2.5 --- PropertyParser.java 26 Jun 2002 15:19:27 - 1.5.2.4 +++ PropertyParser.java 26 Jun 2002 15:55:37 - 1.5.2.5 @@ -480,7 +480,7 @@ prop = SystemFontFunction.systemFontCharacteristic (property, ((StringType)args[0]).getString(), - ((StringType)args[0]).getString()); + ((StringType)args[1]).getString()); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java
pbwest 2002/06/26 08:19:27 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java Log: Support code for system-font function Revision ChangesPath No revision No revision 1.5.2.4 +13 -3 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.3 retrieving revision 1.5.2.4 diff -u -r1.5.2.3 -r1.5.2.4 --- PropertyParser.java 24 Jun 2002 22:31:58 - 1.5.2.3 +++ PropertyParser.java 26 Jun 2002 15:19:27 - 1.5.2.4 @@ -10,6 +10,7 @@ import org.apache.fop.fo.PropertyConsts; import org.apache.fop.fo.Properties; import org.apache.fop.fo.PropNames; +import org.apache.fop.fo.expr.SystemFontFunction; import org.apache.fop.fo.expr.PropertyValue; import org.apache.fop.fo.expr.PropertyValueList; @@ -470,8 +471,17 @@ // Font function else if (currentTokenValue.equals("system-font")) { PropertyValue[] args = parseArgs(1, 2); -throw new PropertyException -("system-font function is not supported."); +if (args.length == 1) { +prop = SystemFontFunction.systemFontCharacteristic +(property, + ((StringType)args[0]).getString()); +} else { +// 2 args +prop = SystemFontFunction.systemFontCharacteristic +(property, + ((StringType)args[0]).getString(), + ((StringType)args[0]).getString()); +} } // Property value functions - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java
pbwest 2002/06/24 15:31:58 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java Log: Use FunctionNotImplementedException Revision ChangesPath No revision No revision 1.5.2.3 +18 -24xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.2 retrieving revision 1.5.2.3 diff -u -r1.5.2.2 -r1.5.2.3 --- PropertyParser.java 23 Jun 2002 15:02:18 - 1.5.2.2 +++ PropertyParser.java 24 Jun 2002 22:31:58 - 1.5.2.3 @@ -34,7 +34,6 @@ import org.apache.fop.datatypes.UriType; import org.apache.fop.datatypes.FromParent; import org.apache.fop.datatypes.FromNearestSpecified; -//import org.apache.fop.datatypes.*; import java.util.HashMap; @@ -397,8 +396,9 @@ break; case INHERIT: -throw new PropertyException("INHERIT not supported"); -//break; +prop = new Inherit(property); +//throw new PropertyException("INHERIT not supported"); +break; case URI: prop = new UriType(property, currentTokenValue); @@ -459,8 +459,7 @@ } else if (currentTokenValue.equals("rgb-icc")) { PropertyValue[] args = parseArgs(6); -throw new PropertyException -("rgb-icc function is not supported."); +throw new FunctionNotImplementedException("rgb-icc"); } else if (currentTokenValue.equals("system-color")) { PropertyValue[] args = parseArgs(1); @@ -491,13 +490,11 @@ } else if (currentTokenValue.equals("label-end")) { PropertyValue[] args = parseArgs(0); -throw new PropertyException -("label-end function is not supported."); +throw new FunctionNotImplementedException("label-end"); } else if (currentTokenValue.equals("body-start")) { PropertyValue[] args = parseArgs(0); -throw new PropertyException -("body-start function is not supported."); +throw new FunctionNotImplementedException("body-start"); } // N.B. see comments on classes FromNearestSpecified and // FromParent for explanation of this section @@ -515,9 +512,8 @@ if (! PropertyConsts.isShorthand(property)) { // develop the function value and return it as // a property. -throw new PropertyException -(currentTokenValue + - " function is not supported."); +throw new FunctionNotImplementedException + (currentTokenValue); } // else a shorthand - do nothing; prop has been set // to the appropriate pseudo-propertyValue @@ -546,28 +542,26 @@ // pseudo-propertyValue } else { // An NCName but not a shorthand -// Perform normal from-parent processing -throw new PropertyException -(currentTokenValue + - " function is not supported."); +// Perform normal from-? processing +throw new FunctionNotImplementedException + (currentTokenValue); } } } else if (currentTokenValue.equals("from-table-column")) { PropertyValue[] args = parseArgs(0, 1); -throw new PropertyException -("from-table-column function is not supported."); +throw new FunctionNotImplementedException + ("from-table-column"); } else if (currentTokenValue.equals("proportional-column-width")) { PropertyValue[] args = parseArgs(1); -throw new PropertyException -("proportional-column-width " - + "function is not supported."); +throw new FunctionNotImplementedException + ("proportional-column-widt
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java PropertyTokenizer.java
pbwest 2002/06/23 08:02:18 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java PropertyTokenizer.java Log: Added SLASH processing Revision ChangesPath No revision No revision 1.5.2.2 +53 -3 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5.2.1 retrieving revision 1.5.2.2 diff -u -r1.5.2.1 -r1.5.2.2 --- PropertyParser.java 7 May 2002 05:37:16 - 1.5.2.1 +++ PropertyParser.java 23 Jun 2002 15:02:18 - 1.5.2.2 @@ -27,6 +27,7 @@ import org.apache.fop.datatypes.Inherit; import org.apache.fop.datatypes.Auto; import org.apache.fop.datatypes.None; +import org.apache.fop.datatypes.Slash; import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.StringType; import org.apache.fop.datatypes.MimeType; @@ -69,8 +70,53 @@ /** * Parse the property expression described in the instance variables. - * - * Note: If the property expression String is empty, a StringProperty + * + * The PropertyValue returned by this function has the + * following characteristics: + * If the expression resolves to a single element that object is returned + * directly in an object which implements . + * + * If the expression cannot be resolved into a single object, the set + * to which it resolves is returned in a PropertyValueList object + * (which itself implements PropertyValue). + * + * The PropertyValueList contains objects whose corresponding + * elements in the original expression were separated by commas. + * + * Objects whose corresponding elements in the original expression + * were separated by spaces are composed into a sublist contained in + * another PropertyValueList. If all of the elements in the + * expression were separated by spaces, the returned + * PropertyValueList will contain one element, a + * PropertyValueList containing objects representing each of + * the space-separated elements in the original expression. + * + * E.g., if a font-family property is assigned the string + * Palatino, New Century Schoolbook, serif, the returned value + * will look like this: + * + * PropertyValueList(NCName('Palatino') + * PropertyValueList(NCName('New') + * NCName('Century') + * NCName('Schoolbook') ) + * NCName('serif') ) + * + * If the property had been assigned the string + * Palatino, "New Century Schoolbook", serif, the returned value + * would look like this: + * + * PropertyValueList(NCName('Palatino') + * NCName('New Century Schoolbook') + * NCName('serif') ) + * + * If a background-position property is assigned the string + * top center, the returned value will look like this: + * + * PropertyValueList(PropertyValueList(NCName('top') + * NCName('center') ) ) + * + * + * Note: If the property expression String is empty, a StringProperty * object holding an empty String is returned. * @param property an int containing the property index. * which the property expression is to be evaluated. @@ -360,6 +406,10 @@ case MIMETYPE: prop = new MimeType(property, currentTokenValue); +break; + +case SLASH: +prop = new Slash(property); break; case FUNCTION_LPAR: { 1.4.4.2 +9 -4 xml-fop/src/org/apache/fop/fo/expr/PropertyTokenizer.java Index: PropertyTokenizer.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyTokenizer.java,v retrieving revision 1.4.4.1 retrieving revision 1.4.4.2 diff -u -r1.4.4.1 -r1.4.4.2 --- PropertyTokenizer.java7 May 2002 05:37:16 - 1.4.4.1 +++ PropertyTokenizer.java23 Jun 2002 15:02:18 - 1.4.4.2 @@ -56,11 +56,12 @@ ,BOOL = 24 ,URI = 25 ,MIMETYPE = 26 + ,SLASH = 27 // NO_UNIT is a transient token for internal use only. It is // never set as the end result of parsing a token. -,NO_UNIT = 27 -//,NSPREFIX = 28 -//,WHITESPACE = 29 +,NO_UNIT = 28 +//,NSPREFIX = 29 +
cvs commit: xml-fop/src/org/apache/fop/fo/expr PropertyParser.java PropertyTokenizer.java
pbwest 02/05/06 22:37:16 Modified:src/org/apache/fop/fo/expr Tag: FOP_0-20-0_Alt-Design PropertyParser.java PropertyTokenizer.java Log: Initial version of experimental property expression parsing. Revision ChangesPath No revision No revision 1.5.2.1 +435 -287 xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java Index: PropertyParser.java === RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/expr/PropertyParser.java,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -r1.5 -r1.5.2.1 --- PropertyParser.java 30 Jul 2001 20:29:21 - 1.5 +++ PropertyParser.java 7 May 2002 05:37:16 - 1.5.2.1 @@ -1,5 +1,5 @@ /* - * $Id: PropertyParser.java,v 1.5 2001/07/30 20:29:21 tore Exp $ + * $Id: PropertyParser.java,v 1.5.2.1 2002/05/07 05:37:16 pbwest Exp $ * 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. @@ -7,140 +7,195 @@ package org.apache.fop.fo.expr; -import org.apache.fop.fo.Property; -import org.apache.fop.fo.ListProperty; -import org.apache.fop.fo.LengthProperty; -import org.apache.fop.fo.NumberProperty; -import org.apache.fop.fo.StringProperty; -import org.apache.fop.fo.ColorTypeProperty; -import org.apache.fop.datatypes.*; +import org.apache.fop.fo.PropertyConsts; +import org.apache.fop.fo.Properties; +import org.apache.fop.fo.PropNames; + +import org.apache.fop.fo.expr.PropertyValue; +import org.apache.fop.fo.expr.PropertyValueList; +import org.apache.fop.datatypes.Numeric; +import org.apache.fop.datatypes.Literal; +import org.apache.fop.datatypes.NCName; +import org.apache.fop.datatypes.Percentage; +import org.apache.fop.datatypes.Ems; +import org.apache.fop.datatypes.IntegerType; +import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.Time; +import org.apache.fop.datatypes.Frequency; +import org.apache.fop.datatypes.Angle; +import org.apache.fop.datatypes.Bool; +import org.apache.fop.datatypes.Inherit; +import org.apache.fop.datatypes.Auto; +import org.apache.fop.datatypes.None; +import org.apache.fop.datatypes.ColorType; +import org.apache.fop.datatypes.StringType; +import org.apache.fop.datatypes.MimeType; +import org.apache.fop.datatypes.UriType; +import org.apache.fop.datatypes.FromParent; +import org.apache.fop.datatypes.FromNearestSpecified; +//import org.apache.fop.datatypes.*; -import java.util.Hashtable; +import java.util.HashMap; /** * Class to parse XSL FO property expression. - * This class is heavily based on the epxression parser in James Clark's + * This class is heavily based on the expression parser in James Clark's * XT, an XSLT processor. + * + * PropertyParser objects are re-usable. The constructor simply creates the + * object. To parse an expression, the public method Parse is + * called. */ 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 SystemC