From 380ae4dae1e2e01e26bbf09f155b40ba199afb84 Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Sun, 3 Feb 2008 14:11:40 +0000 Subject: [PATCH] Bugzilla 43705: Fixed a bug when the rgb-icc() function was used before the fo:declarations, or in documents without fo:declarations. Function now correctly (?) reverts to the sRGB fallback in those cases. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@617989 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/fo/expr/ICCColorFunction.java | 30 +++++++++++++++---- status.xml | 5 ++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/java/org/apache/fop/fo/expr/ICCColorFunction.java b/src/java/org/apache/fop/fo/expr/ICCColorFunction.java index ca66aac27..c254f1516 100644 --- a/src/java/org/apache/fop/fo/expr/ICCColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/ICCColorFunction.java @@ -19,6 +19,7 @@ package org.apache.fop.fo.expr; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.datatypes.PercentBase; import org.apache.fop.fo.pagination.ColorProfile; import org.apache.fop.fo.pagination.Declarations; import org.apache.fop.fo.properties.ColorProperty; @@ -38,6 +39,11 @@ class ICCColorFunction extends FunctionBase { return -4; } + /** {@inheritDoc} */ + public PercentBase getPercentBase() { + return new RGBColorFunction.RGBPercentBase(); + } + /** {@inheritDoc} */ public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { @@ -46,12 +52,24 @@ class ICCColorFunction extends FunctionBase { // Map color profile NCNAME to src from declarations/color-profile element String colorProfileName = args[3].getString(); Declarations decls = pInfo.getFO().getRoot().getDeclarations(); - ColorProfile cp = decls.getColorProfile(colorProfileName); - if (cp == null) { - PropertyException pe = new PropertyException("The " + colorProfileName - + " color profile was not declared"); - pe.setPropertyInfo(pInfo); - throw pe; + ColorProfile cp = null; + if (decls == null) { + //function used in a color-specification + //on a FO occurring: + //a) before the fo:declarations, + //b) or in a document without fo:declarations? + //=> return the sRGB fallback + Property[] rgbArgs = new Property[3]; + System.arraycopy(args, 0, rgbArgs, 0, 3); + return new RGBColorFunction().eval(rgbArgs, pInfo); + } else { + cp = decls.getColorProfile(colorProfileName); + if (cp == null) { + PropertyException pe = new PropertyException("The " + colorProfileName + + " color profile was not declared"); + pe.setPropertyInfo(pInfo); + throw pe; + } } String src = cp.getSrc(); diff --git a/status.xml b/status.xml index 4615f42d0..3cc0f5b46 100644 --- a/status.xml +++ b/status.xml @@ -28,6 +28,11 @@ + + Fixed a bug when the rgb-icc() function was used either before the fo:declarations, + or in documents without a fo:declarations node. In such cases, the sRGB fallback + is now used to avoid an ugly NullPointerException. + Added very basic parsing for the xml:lang shorthand. -- 2.39.5