diff options
author | Jeremias Maerki <jeremias@apache.org> | 2011-04-29 09:07:58 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2011-04-29 09:07:58 +0000 |
commit | 7e27b87ae7ee40489cec182df046cb1712d0c6d2 (patch) | |
tree | 9fafb11321278625672f16d7e026c820057ffb94 | |
parent | 3f71ba3d63ee20a2944d490786e27c07849296b1 (diff) | |
download | xmlgraphics-fop-7e27b87ae7ee40489cec182df046cb1712d0c6d2.tar.gz xmlgraphics-fop-7e27b87ae7ee40489cec182df046cb1712d0c6d2.zip |
Avert a few possible NPEs, ex. rgc-icc() and named-color() on fo:root.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1097736 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/fop/fo/expr/ICCColorFunction.java | 5 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/expr/NamedColorFunction.java | 5 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/properties/PropertyMaker.java | 5 |
3 files changed, 12 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/fo/expr/ICCColorFunction.java b/src/java/org/apache/fop/fo/expr/ICCColorFunction.java index 1235f4c4f..eaf932961 100644 --- a/src/java/org/apache/fop/fo/expr/ICCColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/ICCColorFunction.java @@ -41,6 +41,7 @@ class ICCColorFunction extends FunctionBase { } /** {@inheritDoc} */ + @Override public PercentBase getPercentBase() { return new ICCPercentBase(); } @@ -50,7 +51,9 @@ class ICCColorFunction extends FunctionBase { PropertyInfo pInfo) throws PropertyException { // Map color profile NCNAME to src from declarations/color-profile element String colorProfileName = args[3].getString(); - Declarations decls = pInfo.getFO().getRoot().getDeclarations(); + Declarations decls = (pInfo.getFO() != null + ? pInfo.getFO().getRoot().getDeclarations() + : null); ColorProfile cp = null; if (decls == null) { //function used in a color-specification diff --git a/src/java/org/apache/fop/fo/expr/NamedColorFunction.java b/src/java/org/apache/fop/fo/expr/NamedColorFunction.java index 53b9effdb..e4f8bc643 100644 --- a/src/java/org/apache/fop/fo/expr/NamedColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/NamedColorFunction.java @@ -40,6 +40,7 @@ class NamedColorFunction extends FunctionBase { } /** {@inheritDoc} */ + @Override public PercentBase getPercentBase() { return new NamedPercentBase(); } @@ -51,7 +52,9 @@ class NamedColorFunction extends FunctionBase { String colorProfileName = args[3].getString(); String colorName = args[4].getString(); - Declarations decls = pInfo.getFO().getRoot().getDeclarations(); + Declarations decls = (pInfo.getFO() != null + ? pInfo.getFO().getRoot().getDeclarations() + : null); ColorProfile cp = null; if (decls != null) { cp = decls.getColorProfile(colorProfileName); diff --git a/src/java/org/apache/fop/fo/properties/PropertyMaker.java b/src/java/org/apache/fop/fo/properties/PropertyMaker.java index 0f4632110..ba17b1850 100644 --- a/src/java/org/apache/fop/fo/properties/PropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/PropertyMaker.java @@ -445,7 +445,9 @@ public class PropertyMaker implements Cloneable { } return newProp; } catch (PropertyException propEx) { - propEx.setLocator(fo.getLocator()); + if (fo != null) { + propEx.setLocator(fo.getLocator()); + } propEx.setPropertyName(getName()); throw propEx; } @@ -653,6 +655,7 @@ public class PropertyMaker implements Cloneable { * subproperty makers of the generic compound makers. * {@inheritDoc} */ + @Override public Object clone() { try { return super.clone(); |