Browse Source

Make property function class names more consistent.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1328964 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_1rc1old
Glenn Adams 12 years ago
parent
commit
c15b4a103d

+ 1
- 1
src/java/org/apache/fop/fo/expr/BodyStartFunction.java View File



/** {@inheritDoc} */ /** {@inheritDoc} */
public int getRequiredArgsCount() { public int getRequiredArgsCount() {
return 1;
return 0;
} }


/** {@inheritDoc} */ /** {@inheritDoc} */

src/java/org/apache/fop/fo/expr/CMYKcolorFunction.java → src/java/org/apache/fop/fo/expr/CMYKColorFunction.java View File

/** /**
* Implements the cmyk() function. * Implements the cmyk() function.
*/ */
class CMYKcolorFunction extends FunctionBase {
class CMYKColorFunction extends FunctionBase {


/** {@inheritDoc} */ /** {@inheritDoc} */
public int getRequiredArgsCount() { public int getRequiredArgsCount() {

src/java/org/apache/fop/fo/expr/NearestSpecPropFunction.java → src/java/org/apache/fop/fo/expr/FromNearestSpecifiedValueFunction.java View File

* Class modelling the from-nearest-specified-value function. See Sec. 5.10.4 * Class modelling the from-nearest-specified-value function. See Sec. 5.10.4
* of the XSL-FO standard. * of the XSL-FO standard.
*/ */
public class NearestSpecPropFunction extends FunctionBase {
public class FromNearestSpecifiedValueFunction extends FunctionBase {


/** {@inheritDoc} */ /** {@inheritDoc} */
public int getRequiredArgsCount() { public int getRequiredArgsCount() {

+ 6
- 4
src/java/org/apache/fop/fo/expr/FunctionBase.java View File

package org.apache.fop.fo.expr; package org.apache.fop.fo.expr;


import org.apache.fop.datatypes.PercentBase; import org.apache.fop.datatypes.PercentBase;
import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.properties.StringProperty;


/** /**
* Abstract Base class for XSL-FO functions * Abstract Base class for XSL-FO functions
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
public Property getOptionalArgDefault(int index, PropertyInfo pi) new PropertyException {
public Property getOptionalArgDefault(int index, PropertyInfo pi) throws PropertyException {
if ( index >= getOptionalArgsCount() ) { if ( index >= getOptionalArgsCount() ) {
PropertyException e = new PropertyException ( new IndexOutOfBoundException ( "illegal optional argument index" ) );
PropertyException e = new PropertyException ( new IndexOutOfBoundsException ( "illegal optional argument index" ) );
e.setPropertyInfo ( pi ); e.setPropertyInfo ( pi );
throw e; throw e;
} else { } else {
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
public int hasVariableArgs() {
public boolean hasVariableArgs() {
return false; return false;
} }


* @return string property whose value is name of property being evaluated * @return string property whose value is name of property being evaluated
*/ */
protected final Property getPropertyName ( PropertyInfo pi ) { protected final Property getPropertyName ( PropertyInfo pi ) {
return StringProperty.getInstance ( pi.getPropertMaker().getName() );
return StringProperty.getInstance ( pi.getPropertyMaker().getName() );
} }
} }

+ 26
- 78
src/java/org/apache/fop/fo/expr/PropertyParser.java View File

FUNCTION_TABLE.put("system-color", new SystemColorFunction()); FUNCTION_TABLE.put("system-color", new SystemColorFunction());
FUNCTION_TABLE.put("from-table-column", new FromTableColumnFunction()); FUNCTION_TABLE.put("from-table-column", new FromTableColumnFunction());
FUNCTION_TABLE.put("inherited-property-value", new InheritedPropFunction()); FUNCTION_TABLE.put("inherited-property-value", new InheritedPropFunction());
FUNCTION_TABLE.put("from-nearest-specified-value", new NearestSpecPropFunction());
FUNCTION_TABLE.put("from-page-master-region", new FromPageMasterRegionFunction());
FUNCTION_TABLE.put("from-nearest-specified-value", new FromNearestSpecifiedValueFunction());
FUNCTION_TABLE.put("from-parent", new FromParentFunction()); FUNCTION_TABLE.put("from-parent", new FromParentFunction());
FUNCTION_TABLE.put("proportional-column-width", new PPColWidthFunction());
FUNCTION_TABLE.put("proportional-column-width", new ProportionalColumnWidthFunction());
FUNCTION_TABLE.put("label-end", new LabelEndFunction()); FUNCTION_TABLE.put("label-end", new LabelEndFunction());
FUNCTION_TABLE.put("body-start", new BodyStartFunction()); FUNCTION_TABLE.put("body-start", new BodyStartFunction());
FUNCTION_TABLE.put("rgb-icc", new ICCColorFunction());
FUNCTION_TABLE.put("rgb-named-color", new NamedColorFunction()); //since XSL-FO 2.0
FUNCTION_TABLE.put("rgb-icc", new RGBICCColorFunction());
FUNCTION_TABLE.put("rgb-named-color", new RGBNamedColorFunction()); //since XSL-FO 2.0
FUNCTION_TABLE.put("cie-lab-color", new CIELabColorFunction()); //since XSL-FO 2.0 FUNCTION_TABLE.put("cie-lab-color", new CIELabColorFunction()); //since XSL-FO 2.0
FUNCTION_TABLE.put("cmyk", new CMYKcolorFunction()); //non-standard!!!
FUNCTION_TABLE.put("cmyk", new CMYKColorFunction()); //non-standard!!!


/** /**
* * NOT YET IMPLEMENTED!!! * * NOT YET IMPLEMENTED!!!
next(); next();
// Push new function (for function context: getPercentBase()) // Push new function (for function context: getPercentBase())
propInfo.pushFunction(function); propInfo.pushFunction(function);
if (function.nbArgs() < 0) {
// Negative nbArgs --> function with variable number of arguments
prop = function.eval(parseVarArgs(function), propInfo);
} else {
prop = function.eval(parseArgs(function), propInfo);
}
prop = function.eval(parseArgs(function), propInfo);
propInfo.popFunction(); propInfo.popFunction();
return prop; return prop;


* Parse a comma separated list of function arguments. Each argument * Parse a comma separated list of function arguments. Each argument
* may itself be an expression. This method consumes the closing right * may itself be an expression. This method consumes the closing right
* parenthesis of the argument list. * parenthesis of the argument list.
* @param function The function object for which the arguments are
* collected.
* @return An array of Property objects representing the arguments
* found.
* @param function The function object for which the arguments are collected.
* @return An array of Property objects representing the arguments found.
* @throws PropertyException If the number of arguments found isn't equal * @throws PropertyException If the number of arguments found isn't equal
* to the number expected.
* to the number expected or if another argument parsing error occurs.
*/ */
Property[] parseArgs(Function function) throws PropertyException { Property[] parseArgs(Function function) throws PropertyException {
int nbArgs = function.nbArgs();
Property[] args = new Property[nbArgs];
Property prop;
int i = 0;
int numReq = function.getRequiredArgsCount(); // # required args
int numOpt = function.getOptionalArgsCount(); // # optional args
boolean hasVar = function.hasVariableArgs(); // has variable args
List<Property> args = new java.util.ArrayList<Property>(numReq + numOpt);
if (currentToken == TOK_RPAR) { if (currentToken == TOK_RPAR) {
// No args: func() // No args: func()
next(); next();
} else { } else {
while (true) { while (true) {
prop = parseAdditiveExpr();
if (i < nbArgs) {
args[i++] = prop;
Property p = parseAdditiveExpr();
int i = args.size();
if ( ( i < numReq ) || ( ( i - numReq ) < numOpt ) || hasVar ) {
args.add ( p );
} else {
throw new PropertyException ( "Unexpected function argument at index " + i );
} }
// ignore extra args // ignore extra args
if (currentToken != TOK_COMMA) { if (currentToken != TOK_COMMA) {
} }
expectRpar(); expectRpar();
} }
if (i == nbArgs - 1 && function.padArgsWithPropertyName()) {
args[i++] = StringProperty.getInstance(
propInfo.getPropertyMaker().getName());
}
if (nbArgs != i) {
throw new PropertyException("Expected " + nbArgs
+ ", but got " + i + " args for function");
}
return args;
}

/**
*
* 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.
*
* The method differs from parseArgs in that it accepts a variable
* number of arguments.
*
* @param function The function object for which the arguments are
* collected.
* @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.
*
* TODO Merge this with parseArgs?
*/
Property[] parseVarArgs(Function function) throws PropertyException {
// For variable argument functions the minimum number of arguments is returned as a
// negative integer from the nbArgs method
int nbArgs = -function.nbArgs();
List args = new LinkedList();
Property prop;
if (currentToken == TOK_RPAR) {
// No args: func()
next();
int numArgs = args.size();
if ( numArgs < numReq ) {
throw new PropertyException("Expected " + numReq + " required arguments, but only " + numArgs + " specified");
} else { } else {
while (true) {
prop = parseAdditiveExpr();
args.add(prop);
// ignore extra args
if (currentToken != TOK_COMMA) {
break;
for ( int i = 0; i < numOpt; i++ ) {
if ( args.size() < ( numReq + i + 1 ) ) {
args.add ( function.getOptionalArgDefault ( i, propInfo ) );
} }
next();
} }
expectRpar();
}
if (nbArgs > args.size()) {
throw new PropertyException("Expected at least " + nbArgs
+ ", but got " + args.size() + " args for function");
} }
Property[] propArray = new Property[args.size()];
args.toArray(propArray);
return propArray;
return (Property[]) args.toArray ( new Property [ args.size() ] );
} }



/** /**
* Evaluate an addition operation. If either of the arguments is null, * Evaluate an addition operation. If either of the arguments is null,
* this means that it wasn't convertible to a Numeric value. * this means that it wasn't convertible to a Numeric value.

src/java/org/apache/fop/fo/expr/PPColWidthFunction.java → src/java/org/apache/fop/fo/expr/ProportionalColumnWidthFunction.java View File

* Class modelling the proportional-column-width function. See Sec. 5.10.4 of * Class modelling the proportional-column-width function. See Sec. 5.10.4 of
* the XSL-FO standard. * the XSL-FO standard.
*/ */
public class PPColWidthFunction extends FunctionBase {
public class ProportionalColumnWidthFunction extends FunctionBase {


/** {@inheritDoc} */ /** {@inheritDoc} */
public int getRequiredArgsCount() { public int getRequiredArgsCount() {
@Override @Override
/** {@inheritDoc} */ /** {@inheritDoc} */
public PercentBase getPercentBase() { public PercentBase getPercentBase() {
return new PPColWidthPercentBase();
return new ProportionalColumnWidthPercentBase();
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
return new TableColLength(d.doubleValue(), pInfo.getFO()); return new TableColLength(d.doubleValue(), pInfo.getFO());
} }


private static class PPColWidthPercentBase implements PercentBase {
private static class ProportionalColumnWidthPercentBase implements PercentBase {


/** {@inheritDoc} */ /** {@inheritDoc} */
public int getBaseLength(PercentBaseContext context) throws PropertyException { public int getBaseLength(PercentBaseContext context) throws PropertyException {

src/java/org/apache/fop/fo/expr/ICCColorFunction.java → src/java/org/apache/fop/fo/expr/RGBICCColorFunction.java View File

/** /**
* Implements the rgb-icc() function. * Implements the rgb-icc() function.
*/ */
class ICCColorFunction extends FunctionBase {
class RGBICCColorFunction extends FunctionBase {


/** {@inheritDoc} */ /** {@inheritDoc} */
public int getRequiredArgsCount() { public int getRequiredArgsCount() {


@Override @Override
/** {@inheritDoc} */ /** {@inheritDoc} */
public int hasVariableArgs() {
public boolean hasVariableArgs() {
return true; return true;
} }



src/java/org/apache/fop/fo/expr/NamedColorFunction.java → src/java/org/apache/fop/fo/expr/RGBNamedColorFunction.java View File

* Implements the rgb-named-color() function. * Implements the rgb-named-color() function.
* @since XSL-FO 2.0 * @since XSL-FO 2.0
*/ */
class NamedColorFunction extends FunctionBase {
class RGBNamedColorFunction extends FunctionBase {


/** {@inheritDoc} */ /** {@inheritDoc} */
public int getRequiredArgsCount() { public int getRequiredArgsCount() {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public PercentBase getPercentBase() { public PercentBase getPercentBase() {
return new NamedPercentBase();
return new RGBNamedPercentBase();
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
return ColorProperty.getInstance(pInfo.getUserAgent(), sb.toString()); return ColorProperty.getInstance(pInfo.getUserAgent(), sb.toString());
} }


private static final class NamedPercentBase implements PercentBase {
private static final class RGBNamedPercentBase implements PercentBase {


/** {@inheritDoc} */ /** {@inheritDoc} */
public int getBaseLength(PercentBaseContext context) throws PropertyException { public int getBaseLength(PercentBaseContext context) throws PropertyException {

Loading…
Cancel
Save