Package org.apache.fop.fo.expr

Examples of org.apache.fop.fo.expr.PropertyException


                if (prop instanceof EnumProperty) {
                    //skip
                } else if (prop instanceof NCnameProperty) {
                    Property prop_enum = checkEnumValues(((NCnameProperty)prop).getString());
                    if (prop_enum == null) {
                        throw new PropertyException("Illegal enum value: " + prop.getString());
                    }
                    l.set(i, prop_enum);
                } else {
                    throw new PropertyException("Invalid content for text-decoration "
                            + "property: " + prop);
                }
            }
            return lst;
        }
View Full Code Here


       
        //TODO do we need context for getBPPaddingAndBorder() and getIPPaddingAndBorder()?
        if (getUserAgent().validateStrictly()
                && (getCommonBorderPaddingBackground().getBPPaddingAndBorder(false, null) != 0
                || getCommonBorderPaddingBackground().getIPPaddingAndBorder(false, null) != 0)) {
            throw new PropertyException("Border and padding for region \""
                    + regionName + "\" must be '0' (See 6.4.13 in XSL 1.0).");
        }
    }
View Full Code Here

                Property ipd = (Property)lst.get(0);
                Property bpd = (Property)lst.get(1);
                return new LengthPairProperty(ipd, bpd);
            }
        }
        throw new PropertyException("list with 1 or 2 length values expected");
    }
View Full Code Here

                        if (spaceIndex == -1
                                || (quoteIndex != -1 && spaceIndex > quoteIndex)) {
                            /* no spaces or first space appears after the first
                             * single/double quote, so malformed value string
                             */
                            throw new PropertyException("Invalid property value: "
                                    + "font=\"" + value + "\"");                       
                        }
                        PropertyMaker m = null;
                        int fromIndex = spaceIndex + 1;
                        int toIndex = specVal.length();
                        /* at least one space that appears before the first
                         * single/double quote, so extract the individual properties
                         */
                        boolean fontFamilyParsed = false;
                        int commaIndex = value.indexOf(',');
                        while (!fontFamilyParsed) {
                            /* value contains a (list of) possibly quoted
                             * font-family name(s)
                             */
                            if (commaIndex == -1) {
                                /* no list, just a single name
                                 * (or first name in the list)
                                 */
                                if (quoteIndex != -1) {
                                    /* a single name, quoted
                                     */
                                    fromIndex = quoteIndex;
                                }
                                m = FObj.getPropertyMakerFor(PROP_IDS[1]);
                                prop = m.make(propertyList, specVal.substring(fromIndex), fo);
                                newProp.addProperty(prop, 1);
                                fontFamilyParsed = true;                           
                            } else {
                                if (quoteIndex != -1 && quoteIndex < commaIndex) {
                                    /* a quoted font-family name as first name
                                     * in the comma-separated list
                                     * fromIndex = index of the first quote
                                     */
                                    fromIndex = quoteIndex;
                                    quoteIndex = -1;
                                } else {
                                    fromIndex = value.lastIndexOf(' ', commaIndex) + 1;
                                }
                                commaIndex = -1;
                            }
                        }
                        toIndex = fromIndex - 1;
                        fromIndex = value.lastIndexOf(' ', toIndex - 1) + 1;
                        value = specVal.substring(fromIndex, toIndex);
                        int slashIndex = value.indexOf('/');
                        String fontSize = value.substring(0,
                                (slashIndex == -1) ? value.length() : slashIndex);
                        m = FObj.getPropertyMakerFor(PROP_IDS[0]);
                        prop = m.make(propertyList, fontSize, fo);
                        /* need to make sure subsequent call to LineHeightPropertyMaker.make()
                         * doesn't generate the default font-size property...
                         */
                        propertyList.putExplicit(PROP_IDS[0], prop);
                        newProp.addProperty(prop, 0);
                        if (slashIndex != -1) {
                            /* line-height */
                            String lineHeight = value.substring(slashIndex + 1);
                            m = FObj.getPropertyMakerFor(PROP_IDS[2]);
                            prop = m.make(propertyList, lineHeight, fo);
                            newProp.addProperty(prop, 2);
                        }
                        if (fromIndex != 0) {
                            toIndex = fromIndex - 1;
                            value = specVal.substring(0, toIndex);
                            fromIndex = 0;
                            spaceIndex = value.indexOf(' ');
                            do {
                                toIndex = (spaceIndex == -1) ? value.length() : spaceIndex;
                                String val = value.substring(fromIndex, toIndex);
                                for (int i = 6; --i >= 3;) {
                                    if (newProp.list.get(i) == null) {
                                        /* not set */
                                        m = FObj.getPropertyMakerFor(PROP_IDS[i]);
                                        val = m.checkValueKeywords(val);
                                        prop = m.checkEnumValues(val);
                                        if (prop != null) {
                                            newProp.addProperty(prop, i);
                                        }
                                    }
                                }
                                fromIndex = toIndex + 1;
                                spaceIndex = value.indexOf(' ', fromIndex);
                            } while (toIndex != value.length());
                        }
                    } else {
                        //TODO: implement enum values
                        log.warn("Enum values other than \"inherit\""
                                + " not yet supported for the font shorthand.");
                        return null;
                    }
                }
                if (newProp.list.get(0) == null || newProp.list.get(1) == null) {
                    throw new PropertyException("Invalid property value: "
                            + "font-size and font-family are required for the font shorthand"
                            + "\nfont=\"" + value + "\"");
                }
                return newProp;
           } catch (PropertyException pe) {
View Full Code Here

                    if (loc != null && loc.getLineNumber() != -1) {
                        errorMessage.append(" (line #")
                            .append(loc.getLineNumber()).append(", column #")
                            .append(loc.getColumnNumber()).append(")");
                    }
                    throw new PropertyException(errorMessage.toString());
                }
            }

            return p;
        }
View Full Code Here

            } else {
                throw new NumberFormatException();
            }
            parsedColor = new Color(red, green, blue, alpha);
        } catch (Exception e) {
            throw new PropertyException("Unknown color format: " + value
                    + ". Must be #RGB. #RGBA, #RRGGBB, or #RRGGBBAA");
        }
        return parsedColor;
    }
View Full Code Here

        if (poss != -1 && pose != -1) {
            String[] args = value.substring(poss + 1, pose).split(",");
           
            try {
                if (args.length < 5) {
                    throw new PropertyException("Too few arguments for rgb-icc() function");
                }
                /* Get and verify ICC profile name */
                String iccProfileName = args[3].trim();
                if (iccProfileName == null || "".equals(iccProfileName)) {
                    throw new PropertyException("ICC profile name missing");
                }
                /* Get and verify ICC profile source */
                String iccProfileSrc = args[4].trim();
                if (iccProfileSrc == null || "".equals(iccProfileSrc)) {
                    throw new PropertyException("ICC profile source missing");
                }
                if (iccProfileSrc.startsWith("\"") || iccProfileSrc.startsWith("'")) {
                    iccProfileSrc = iccProfileSrc.substring(1);
                }
                if (iccProfileSrc.endsWith("\"") || iccProfileSrc.endsWith("'")) {
                    iccProfileSrc = iccProfileSrc.substring(0, iccProfileSrc.length() - 1);
                }
                /* ICC profile arguments */
                float[] iccComponents = new float[args.length - 5];
                for (int ix = 4; ++ix < args.length;) {
                    iccComponents[ix - 5] = Float.parseFloat(args[ix].trim());
                }
                /* Ask FOP factory to get ColorSpace for the specified ICC profile source */
                ColorSpace colorSpace = (foUserAgent != null
                        ? foUserAgent.getFactory().getColorSpace(
                                foUserAgent.getBaseURL(), iccProfileSrc) : null);
               
                float red = 0, green = 0, blue = 0;
                red = Float.parseFloat(args[0].trim());
                green = Float.parseFloat(args[1].trim());
                blue = Float.parseFloat(args[2].trim());
                /* Verify rgb replacement arguments */
                if ((red < 0 || red > 1)
                        || (green < 0 || green > 1)
                        || (blue < 0 || blue > 1)) {
                    throw new PropertyException("Color values out of range. "
                            + "Fallback RGB arguments to fop-rgb-icc() must be [0..1]");
                }

                if (colorSpace != null) {
                    // ColorSpace available - create ColorExt (keeps track of replacement rgb
                    // values for possible later colorTOsRGBString call
                    parsedColor = ColorExt.createFromFoRgbIcc(red, green, blue,
                            iccProfileName, iccProfileSrc, colorSpace, iccComponents);
                } else {
                    // ICC profile could not be loaded - use rgb replacement values */
                    log.warn("Color profile '" + iccProfileSrc
                            + "' not found. Using rgb replacement values.");
                    parsedColor = new Color(Math.round(red * 255),
                            Math.round(green * 255), Math.round(blue * 255));
                }
            } catch (PropertyException pe) {
                //simply re-throw
                throw pe;
            } catch (Exception e) {
                //wrap in a PropertyException
                throw new PropertyException(e);
            }
        } else {
            throw new PropertyException("Unknown color format: " + value
                    + ". Must be fop-rgb-icc(r,g,b,NCNAME,src,....)");
        }
        return parsedColor;
    }
View Full Code Here

        if (poss != -1 && pose != -1) {
            value = value.substring(poss + 1, pose);
            String[] args = value.split(",");
            try {
                if (args.length != 4) {
                    throw new PropertyException(
                            "Invalid number of arguments: cmyk(" + value + ")");
                }
                float cyan = 0.0f, magenta = 0.0f, yellow = 0.0f, black = 0.0f;
                String str = args[0].trim();
                if (str.endsWith("%")) {
                  cyan  = Float.parseFloat(str.substring(0,
                            str.length() - 1)) / 100.0f;
                } else {
                  cyan  = Float.parseFloat(str);
                }
                str = args[1].trim();
                if (str.endsWith("%")) {
                  magenta = Float.parseFloat(str.substring(0,
                            str.length() - 1)) / 100.0f;
                } else {
                  magenta = Float.parseFloat(str);
                }
                str = args[2].trim();
                if (str.endsWith("%")) {
                  yellow = Float.parseFloat(str.substring(0,
                            str.length() - 1)) / 100.0f;
                } else {
                  yellow = Float.parseFloat(str);
                }
                str = args[3].trim();
                if (str.endsWith("%")) {
                  black = Float.parseFloat(str.substring(0,
                            str.length() - 1)) / 100.0f;
                } else {
                  black = Float.parseFloat(str);
                }
               
                if ((cyan < 0.0 || cyan > 1.0)
                        || (magenta < 0.0 || magenta > 1.0)
                        || (yellow < 0.0 || yellow > 1.0)
                        || (black < 0.0 || black > 1.0)) {
                    throw new PropertyException("Color values out of range"
                            + "Arguments to cmyk() must be in the range [0%-100%] or [0.0-1.0]");
                }
                float[] cmyk = new float[] {cyan, magenta, yellow, black};
                CMYKColorSpace cmykCs = CMYKColorSpace.getInstance();
                float[] rgb = cmykCs.toRGB(cmyk);
                parsedColor = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2],
                        null, "#CMYK", cmykCs, cmyk);
            } catch (PropertyException pe) {
                throw pe;
            } catch (Exception e) {
                throw new PropertyException(e);
            }
        } else {
            throw new PropertyException("Unknown color format: " + value
                    + ". Must be cmyk(c,m,y,k)");
        }
        return parsedColor;
    }
View Full Code Here

                } else if (propEnum == Constants.EN_NO_BLINK) {
                    if (deco != null) {
                        deco.decoration &= UNDERLINE | OVERLINE | LINE_THROUGH;
                    }
                } else {
                    throw new PropertyException("Illegal value encountered: " + prop.getString());
                }
            }
        }
        return deco;
    }
View Full Code Here

            ro = p.getNumeric().getValue();
        }
        if ((Math.abs(ro) % 90) == 0 && (Math.abs(ro) / 90) <= 3) {
            return p;
        } else {
            throw new PropertyException("Illegal property value: "
                    + "reference-orientation=\"" + ro + "\" "
                    + "on " + propertyList.getFObj().getName());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.fop.fo.expr.PropertyException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.