1 17 18 19 20 package org.apache.fop.fo.expr; 21 import org.apache.fop.apps.FOUserAgent; 22 import org.apache.fop.fo.pagination.ColorProfile; 23 import org.apache.fop.fo.pagination.Declarations; 24 import org.apache.fop.fo.properties.ColorProperty; 25 import org.apache.fop.fo.properties.Property; 26 27 30 class ICCColorFunction extends FunctionBase { 31 32 37 public int nbArgs() { 38 return -4; 39 } 40 41 42 public Property eval(Property[] args, 43 PropertyInfo pInfo) throws PropertyException { 44 StringBuffer sb = new StringBuffer (); 45 46 String colorProfileName = args[3].getString(); 48 Declarations decls = pInfo.getFO().getRoot().getDeclarations(); 49 ColorProfile cp = decls.getColorProfile(colorProfileName); 50 if (cp == null) { 51 PropertyException pe = new PropertyException("The " + colorProfileName 52 + " color profile was not declared"); 53 pe.setPropertyInfo(pInfo); 54 throw pe; 55 } 56 String src = cp.getSrc(); 57 58 sb.append("fop-rgb-icc(" + args[0]); 61 for (int ix = 1; ix < args.length; ix++) { 62 if (ix == 3) { 63 sb.append("," + colorProfileName); 64 sb.append(",\"" + src + "\""); 65 } else { 66 sb.append("," + args[ix]); 67 } 68 } 69 sb.append(")"); 70 FOUserAgent ua = (pInfo == null 71 ? null 72 : (pInfo.getFO() == null ? null : pInfo.getFO().getUserAgent())); 73 return new ColorProperty(ua, sb.toString()); 74 } 75 76 77 } 78 | Popular Tags |