package org.apache.fop.area.inline;
import java.util.Iterator;
+import java.util.ArrayList;
import java.util.List;
+import java.lang.Math;
import org.apache.fop.area.Area;
/**
* The list of inline areas added to this inline parent.
*/
- protected List<InlineArea> inlines = new java.util.ArrayList<InlineArea>();
+ protected List<InlineArea> inlines = new ArrayList<InlineArea>();
/** Controls whether the IPD is automatically adjusted based on the area's children. */
protected transient boolean autoSize;
-
+
/** The offset of the <q>beforest</q> child area of this area. */
protected int minChildOffset;
-
+
/**
* The offset of the <q>afterest</q> child area of this area. Offset from the
* before-edge of this area's content-rectangle and the after-edge of the child area's
import org.apache.fop.fo.extensions.ExtensionAttachment;
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.fo.flow.table.TableCell;
+import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.properties.PropertyMaker;
/**
if (!inMarker() || "marker".equals(elementName)) {
bind(pList);
}
+ warnOnUnknownProperties(attlist, elementName, pList);
+ }
+
+ private void warnOnUnknownProperties(Attributes attlist, String objName, PropertyList propertyList)
+ throws FOPException {
+ Map<String, Property> unknowns = propertyList.getUnknownPropertyValues();
+ for (String propertyValue : unknowns.keySet()) {
+ FOValidationEventProducer producer = FOValidationEventProducer.Provider.get(getUserAgent()
+ .getEventBroadcaster());
+ producer.invalidPropertyValue(this, objName,
+ getAttributeNameForValue(attlist, unknowns.get(propertyValue), propertyList),
+ propertyValue, null,
+ getLocator());
+ }
+ }
+
+ private String getAttributeNameForValue(Attributes attList, Property value, PropertyList propertyList)
+ throws FOPException {
+ for (int i = 0; i < attList.getLength(); i++) {
+ String attributeName = attList.getQName(i);
+ String attributeValue = attList.getValue(i);
+ Property prop = propertyList.getPropertyForAttribute(attList, attributeName, attributeValue);
+ if (prop.equals(value)) {
+ return attributeName;
+ }
+ }
+ return "unknown";
}
/**
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;
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;
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
}
}
+ /**
+ * 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
*/
return p;
}
+ /**
+ * 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.
&& 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