/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return 1;
}
+ /**
+ * @return true (allow padding of arglist with property name)
+ */
+ public boolean padArgsWithPropertyName() {
+ return true;
+ }
+
/**
* @param args array of arguments, which should either be empty, or the
* first of which should contain an NCName corresponding to property name
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return 1;
}
+ /**
+ * @return true (allow padding of arglist with property name)
+ */
+ public boolean padArgsWithPropertyName() {
+ return true;
+ }
+
/**
*
* @param args array of arguments, which should either be empty, or the
*/
public Property eval(Property[] args,
PropertyInfo pInfo) throws PropertyException {
+ /* uncomment when implementing
String propName = args[0].getString();
if (propName == null) {
- //TODO Determine on which property this method was called.
+ throw new PropertyException("Incorrect parameter to from-table-column function");
}
+ */
throw new PropertyException("The from-table-column() function is not implemented, yet!");
}
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
Property eval(Property[] args,
PropertyInfo propInfo) throws PropertyException;
-}
+ /**
+ * @return if it is allowed to fill up the property list with
+ * the property name if only one arg is missing.
+ */
+ boolean padArgsWithPropertyName();
+}
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return null;
}
+ /**
+ * @return false (by default don't pad arglist with property-name)
+ */
+ public boolean padArgsWithPropertyName() {
+ return false;
+ }
}
-
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return 1;
}
+ /**
+ * @return true (allow padding of arglist with property name)
+ */
+ public boolean padArgsWithPropertyName() {
+ return true;
+ }
+
/**
*
* @param args arguments to be evaluated
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return 1;
}
+ /**
+ * @return true (allow padding of arglist with property name)
+ */
+ public boolean padArgsWithPropertyName() {
+ return true;
+ }
+
/**
*
* @param args array of arguments for the function
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
next();
// Push new function (for function context: getPercentBase())
propInfo.pushFunction(function);
- prop = function.eval(parseArgs(function.nbArgs()), propInfo);
+ prop = function.eval(parseArgs(function), propInfo);
propInfo.popFunction();
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.
+ * @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.
*/
- Property[] parseArgs(int nbArgs) throws PropertyException {
+ Property[] parseArgs(Function function) throws PropertyException {
+ int nbArgs = function.nbArgs();
Property[] args = new Property[nbArgs];
Property prop;
int i = 0;
}
expectRpar();
}
+ if (i == nbArgs - 1 && function.padArgsWithPropertyName()) {
+ args[i++] = new StringProperty(propInfo.getPropertyMaker().getName());
+ }
if (nbArgs != i) {
- throw new PropertyException("Wrong number of args for function");
+ throw new PropertyException("Expected " + nbArgs
+ + ", but got " + i + " args for function");
}
return args;
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- $Id$ -->
+<!-- This test verifies the addition of the property name for which the
+ function is called to the parameter list of the function if the
+ last parameter is omitted. (Only for currently implemented functions).
+-->
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:test="http://xmlgraphics.apache.org/fop/test">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="normal">
+ <fo:flow flow-name="xsl-region-body">
+ <!-- system-font (not implemented) -->
+ <!-- inherited-property-value -->
+ <fo:block font-size="13pt">
+ Top Level Block: font-size="13pt" background-color="#00ff00"
+ <fo:block font-size="inherited-property-value() + 3pt">
+ <test:assert property="font-size" expected="16000mpt"/>
+ Nested Block: font-size="inherited-property-value() + 3pt"
+ (calculate with an inherited value)
+ </fo:block>
+ </fo:block>
+ <!-- from-parent -->
+ <fo:block font-size="24pt" background-color="#ff0000">
+ Top Level Block: font-size="24pt" background-color="#ff0000"
+ <fo:block font-size="from-parent() + 2pt"
+ background-color="from-parent()">
+ <test:assert property="font-size" expected="26000mpt"/>
+ <test:assert property="background-color" expected="#ff0000"/>
+ Nested Block:
+ font-size="from-parent() + 2pt"(inherited value and calculate)
+ background-color="from-parent()" (calculate with an inherited value)
+ </fo:block>
+ </fo:block>
+ <!-- from-nearest-specified-value -->
+ <fo:block background-color="#0000ff">
+ Top Level Block: font-size="24pt" background-color="#0000ff"
+ <fo:block>
+ <test:assert property="background-color" expected="#000000"/>
+ Nested Block: background-color=default
+ <fo:block background-color="from-nearest-specified-value()">
+ <test:assert property="background-color" expected="#0000ff"/>
+ Nested Block: background-color="from-nearest-specified-value()"
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ <!-- from-table-column (not implemented) -->
+ <!-- merge-property-value (not implemented) -->
+ </fo:flow>
+ </fo:page-sequence>
+</fo:root>
+