diff options
Diffstat (limited to 'src/java/org/apache/fop/fo/PropertyList.java')
-rw-r--r-- | src/java/org/apache/fop/fo/PropertyList.java | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/fo/PropertyList.java b/src/java/org/apache/fop/fo/PropertyList.java index c9e9250f0..49bbf48a0 100644 --- a/src/java/org/apache/fop/fo/PropertyList.java +++ b/src/java/org/apache/fop/fo/PropertyList.java @@ -20,6 +20,11 @@ package org.apache.fop.fo; // Java +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + import org.xml.sax.Attributes; import org.apache.commons.logging.Log; @@ -27,6 +32,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.util.QName; +import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.expr.PropertyException; import org.apache.fop.fo.properties.CommonAbsolutePosition; @@ -55,6 +61,8 @@ public abstract class PropertyList { private static Log log = LogFactory.getLog(PropertyList.class); + private final UnknownPropertyHandler unknownPropertyHandler = new UnknownPropertyHandler(); + /** * Basic constructor. * @param fObjToAttach the FO this PropertyList should be attached to @@ -85,6 +93,25 @@ public abstract class PropertyList { } /** + * Adds an unknown property value to the property list so that if + * necessary, a warning can be displayed. + * @param propertyValue The unknown property value + * @param output The output of the property to validate + * @param property The original property containing the full value + */ + public void validatePropertyValue(String propertyValue, Property output, Property property) { + unknownPropertyHandler.validatePropertyValue(propertyValue, output, property); + } + + /** + * Gets the current list of unknown property values + * @return The set containing the list of unknown property values + */ + public Map<String, Property> getUnknownPropertyValues() { + return unknownPropertyHandler.getUnknownPropertyValues(); + } + + /** * @return the FObj object attached to the parentPropetyList */ public PropertyList getParentPropertyList() { @@ -108,6 +135,36 @@ public abstract class PropertyList { } /** + * A class to handle unknown shorthand property values e.g. border="solit 1pt" + */ + private static class UnknownPropertyHandler { + + /** + * A list of unknown properties identified by the value and property in which its featured + */ + private Map<String, Property> unknownPropertyValues = new HashMap<String, Property>(); + + /** + * A list of known properties which have already been processed + */ + private Set<Property> knownProperties = new HashSet<Property>(); + + void validatePropertyValue(String propertyValue, Property output, Property property) { + if (!knownProperties.contains(property) && output == null) { + if (propertyValue != null) { + unknownPropertyValues.put(propertyValue, property); + } + } else { + knownProperties.add(property); + } + } + + Map<String, Property> getUnknownPropertyValues() { + return unknownPropertyValues; + } + } + + /** * Return the value explicitly specified on this FO. * @param propId The ID of the property whose value is desired. * @return The value if the property is explicitly set, otherwise null. @@ -357,6 +414,27 @@ public abstract class PropertyList { && findSubPropertyName(propertyName) != null)); } + public Property getPropertyForAttribute(Attributes attributes, String attributeName, String attributeValue) + throws FOPException { + if (attributeValue != null) { + if (attributeName.startsWith("xmlns:") || "xmlns".equals(attributeName)) { + return null; + } + String basePropertyName = findBasePropertyName(attributeName); + String subPropertyName = findSubPropertyName(attributeName); + + int propId = FOPropertyMapping.getPropertyId(basePropertyName); + int subpropId = FOPropertyMapping.getSubPropertyId(subPropertyName); + + if (propId == -1 || (subpropId == -1 && subPropertyName != null)) { + return null; + } + + return getExplicit(propId); + } + return null; + } + /** * * @param attributes Collection of attributes |