From c7a492055a746154a60e0995cde50484ee899fc0 Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Sat, 21 Sep 2002 04:39:30 +0000 Subject: [PATCH] Changed FOTree arg to refineParsing() to FONode. Added resolve() calls to IndirectValues. Added refineExpansionList() and applied to shorthand expansions. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@195238 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/Properties.java | 394 ++++++++++++++++---------- 1 file changed, 242 insertions(+), 152 deletions(-) diff --git a/src/org/apache/fop/fo/Properties.java b/src/org/apache/fop/fo/Properties.java index 7eb0c8e1a..d4e3a3a83 100644 --- a/src/org/apache/fop/fo/Properties.java +++ b/src/org/apache/fop/fo/Properties.java @@ -60,6 +60,7 @@ import org.apache.fop.datatypes.TextDecorator; import org.apache.fop.datatypes.ShadowEffect; import org.apache.fop.datatypes.Slash; import org.apache.fop.datatypes.indirect.Inherit; +import org.apache.fop.datatypes.indirect.InheritedValue; import org.apache.fop.datatypes.indirect.FromParent; import org.apache.fop.datatypes.indirect.FromNearestSpecified; @@ -313,19 +314,19 @@ public abstract class Properties { * *

This method is overriden by individual property classes which * require specific processing. - * @param foTree - the FOTree being built + * @param foNode - the FONode being built * @param value - PropertyValue returned by the parser */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { - return refineParsing(foTree, value, NOT_NESTED); + return refineParsing(foNode, value, NOT_NESTED); } /** * Do the work for the two argument refineParsing method. - * @param foTree - the FOTree being built + * @param foNode - the FONode being built * @param value - PropertyValue returned by the parser * @param nested - boolean indicating whether this method is * called normally (false), or as part of another refineParsing @@ -333,13 +334,14 @@ public abstract class Properties { * @see #refineParsing(FOTree,PropertyValue) */ protected static PropertyValue refineParsing - (FOTree foTree, PropertyValue value, boolean nested) + (FONode foNode, PropertyValue value, boolean nested) throws PropertyException { int property = value.getProperty(); String propName = PropNames.getPropertyName(property); int datatype = PropertyConsts.dataTypes.get(property); int proptype = value.getType(); + PropertyValue pv; switch (proptype) { case PropertyValue.NUMERIC: // Can be any of @@ -363,7 +365,7 @@ public abstract class Properties { if ((datatype & ENUM) != 0) return new EnumType(property, ncname); if ((datatype & MAPPED_LENGTH) != 0) - return (new MappedNumeric(property, ncname, foTree)) + return (new MappedNumeric(property, ncname, foNode.foTree)) .getMappedNumValue(); case PropertyValue.LITERAL: // Can be LITERAL or CHARACTER_T @@ -396,10 +398,28 @@ public abstract class Properties { if ((datatype & MIMETYPE) != 0) return value; throw new PropertyException ("mimetype invalid for " + propName); + // The following types cannot have their values validated in advance. + // The result must be validated from within the property type. + case PropertyValue.FROM_PARENT: + pv = ((FromParent)value).resolve(foNode); + if (pv == value) return value; // unable to resolve + // TODO: validate here + return pv; + case PropertyValue.FROM_NEAREST_SPECIFIED: + pv = ((FromNearestSpecified)value).resolve(foNode); + if (pv == value) return value; // unable to resolve + // TODO: validate here + return pv; + case PropertyValue.INHERITED_VALUE: + pv = ((InheritedValue)value).resolve(foNode); + if (pv == value) return value; // unable to resolve + // TODO: validate here + return pv; default: if ( ! nested) { if (proptype == PropertyValue.INHERIT) { - if ((datatype & INHERIT) != 0) return value; + if ((datatype & INHERIT) != 0) + return ((Inherit)value).resolve(foNode); throw new PropertyException ("'inherit' invalid for " + propName); } @@ -410,6 +430,41 @@ public abstract class Properties { } } + /** + * Refine a list of property values against their properties. + * Expansion lists are generated by shorthand and compound expansion. + * The set of properties will, in general, be different from the + * generating property, which will be the one associated with the list + * itself. + * @param foNode - the FONode for which the properties are + * being processed. + * @param list - the list of PropertyValues to be refined. + * @return a PropertyValueList>/tt> containing the refined property + * values. + */ + private static PropertyValueList refineExpansionList + (FONode foNode, PropertyValueList list) + throws PropertyException + { + PropertyValueList newlist = new PropertyValueList(list.getProperty()); + Iterator properties = list.iterator(); + while (properties.hasNext()) { + // refine the next element + PropertyValue pv = + PropertyConsts.refineParsing + (foNode, (PropertyValue)(properties.next())); + // if it's a list, recursively refine. This will return a list + if (pv.getType() == PropertyValue.LIST) { + PropertyValueList pvl = + refineExpansionList(foNode, (PropertyValueList)pv); + newlist.addAll(pvl); + } else { // single element + newlist.add(pv); + } + } + return newlist; + } + /** * Determine whether argument list contains a space-separated list * from the parser. @@ -534,31 +589,31 @@ public abstract class Properties { * N.B. this is the order of elements defined in * PropertySets.borderRightExpansion */ - protected static PropertyValue borderEdge(FOTree foTree, + protected static PropertyValue borderEdge(FONode foNode, PropertyValue value, int styleProp, int colorProp, int widthProp) throws PropertyException { return borderEdge - (foTree, value, styleProp, colorProp, widthProp, NOT_NESTED); + (foNode, value, styleProp, colorProp, widthProp, NOT_NESTED); } protected static PropertyValue borderEdge - (FOTree foTree, PropertyValue value, int styleProp, + (FONode foNode, PropertyValue value, int styleProp, int colorProp, int widthProp, boolean nested) throws PropertyException { if (value.getType() != PropertyValue.LIST) { return processEdgeValue - (foTree, value, styleProp, colorProp, widthProp, nested); + (foNode, value, styleProp, colorProp, widthProp, nested); } else { return processEdgeList - (foTree, spaceSeparatedList((PropertyValueList)value), + (foNode, spaceSeparatedList((PropertyValueList)value), styleProp, colorProp, widthProp); } } private static PropertyValueList processEdgeValue - (FOTree foTree, PropertyValue value, int styleProp, + (FONode foNode, PropertyValue value, int styleProp, int colorProp, int widthProp, boolean nested) throws PropertyException { @@ -567,18 +622,22 @@ public abstract class Properties { if (type == PropertyValue.INHERIT || type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) + { // Construct a list of Inherit values - return PropertySets.expandAndCopySHand(value); + PropertyValueList list = + PropertySets.expandAndCopySHand(value); + return refineExpansionList(foNode, list); + } } // Make a list and pass to processList PropertyValueList tmpList = new PropertyValueList(value.getProperty()); tmpList.add(value); return processEdgeList - (foTree, tmpList, styleProp, colorProp, widthProp); + (foNode, tmpList, styleProp, colorProp, widthProp); } - private static PropertyValueList processEdgeList(FOTree foTree, + private static PropertyValueList processEdgeList(FONode foNode, PropertyValueList value, int styleProp, int colorProp, int widthProp) throws PropertyException { @@ -623,7 +682,7 @@ public abstract class Properties { try { widthFound = - (new MappedNumeric(widthProp, ncname, foTree)) + (new MappedNumeric(widthProp, ncname, foNode.foTree)) .getMappedNumValue(); } catch (PropertyException e) {} if (widthFound != null) { @@ -1047,19 +1106,19 @@ public abstract class Properties { * a BackgroundPositionVertical Numeric or Inherit value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { if ( ! (value instanceof PropertyValueList)) { - return processValue(foTree, value); + return processValue(foNode, value); } else { return processList - (foTree, spaceSeparatedList((PropertyValueList)value)); + (foNode, spaceSeparatedList((PropertyValueList)value)); } } private static PropertyValueList processValue - (FOTree foTree, PropertyValue value) throws PropertyException + (FONode foNode, PropertyValue value) throws PropertyException { // Can be Inherit, ColorType, UriType, None, Numeric, or an // NCName (i.e. enum token) @@ -1069,18 +1128,19 @@ public abstract class Properties { type == PropertyValue.FROM_NEAREST_SPECIFIED) { // Construct a list of Inherit values - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); } else { // Make a list and pass to processList PropertyValueList tmpList = new PropertyValueList(value.getProperty()); tmpList.add(value); - return processList(foTree, tmpList); + return processList(foNode, tmpList); } } private static PropertyValueList processList - (FOTree foTree, PropertyValueList value) + (FONode foNode, PropertyValueList value) throws PropertyException { int property = value.getProperty(); @@ -1146,14 +1206,14 @@ public abstract class Properties { "position overrides previous position"); if (tmpval == null) position = BackgroundPosition.refineParsing - (foTree, pval, IS_NESTED); + (foNode, pval, IS_NESTED); else { // 2 elements // make a space-separated list PropertyValueList ssList = new PropertyValueList (PropNames.BACKGROUND_POSITION); ssList.add(posnList); position = BackgroundPosition.refineParsing - (foTree, ssList, IS_NESTED); + (foNode, ssList, IS_NESTED); } continue scanning_elements; } // end of case NUMERIC @@ -1236,11 +1296,11 @@ public abstract class Properties { (PropNames.BACKGROUND_POSITION); ssList.add(posnList); position = BackgroundPosition.refineParsing - (foTree, ssList, IS_NESTED); + (foNode, ssList, IS_NESTED); } else { // one only // Now send one NCName to BackgroundPosition position = BackgroundPosition.refineParsing - (foTree, pval, IS_NESTED); + (foNode, pval, IS_NESTED); } continue scanning_elements; } @@ -1386,20 +1446,20 @@ public abstract class Properties { * containing the expansion of the shorthand. I.e. the first * element is a value for BackgroundPositionHorizontal, and the * second is for BackgroundPositionVertical. - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { - return refineParsing(foTree, value, NOT_NESTED); + return refineParsing(foNode, value, NOT_NESTED); } /** * Do the work for the two argument refineParsing method. - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @param nested boolean indicating whether this method is * called normally (false), or as part of another refineParsing @@ -1408,11 +1468,11 @@ public abstract class Properties { * @see #refineParsing(FOTree,PropertyValue) */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value, boolean nested) + (FONode foNode, PropertyValue value, boolean nested) throws PropertyException { if ( ! (value instanceof PropertyValueList)) { - return processValue(value, nested); + return processValue(foNode, value, nested); } else { return processList (spaceSeparatedList((PropertyValueList)value)); @@ -1420,8 +1480,8 @@ public abstract class Properties { } private static PropertyValueList processValue - (PropertyValue value, boolean nested) - throws PropertyException + (FONode foNode, PropertyValue value, boolean nested) + throws PropertyException { PropertyValueList newlist = new PropertyValueList(value.getProperty()); @@ -1433,8 +1493,8 @@ public abstract class Properties { type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) { // Construct a list of Inherit values - newlist = PropertySets.expandAndCopySHand(value); - return newlist; + newlist = refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); } } @@ -1872,7 +1932,7 @@ public abstract class Properties { public static final int inherited = NO; public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { int type = value.getType(); @@ -1880,7 +1940,8 @@ public abstract class Properties { type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) // Construct a list of Inherit values - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); PropertyValueList ssList = null; // Must be a space-separated list or a single value from the @@ -1907,7 +1968,7 @@ public abstract class Properties { PropertyValue val = (PropertyValue)(values.next()); PropertyValue pv = null; try { - pv = BorderWidth.refineParsing(foTree, val, IS_NESTED); + pv = BorderWidth.refineParsing(foNode, val, IS_NESTED); if (width != null) MessageHandler.log("border: duplicate" + "width overrides previous width"); @@ -1915,7 +1976,7 @@ public abstract class Properties { continue; } catch (PropertyException e) {} try { - pv = BorderStyle.refineParsing(foTree, val, IS_NESTED); + pv = BorderStyle.refineParsing(foNode, val, IS_NESTED); if (style != null) MessageHandler.log("border: duplicate" + "style overrides previous style"); @@ -1923,7 +1984,7 @@ public abstract class Properties { continue; } catch (PropertyException e) {} try { - pv = BorderColor.refineParsing(foTree, val, IS_NESTED); + pv = BorderColor.refineParsing(foNode, val, IS_NESTED); if (color != null) MessageHandler.log("border: duplicate" + "color overrides previous color"); @@ -1938,7 +1999,8 @@ public abstract class Properties { } // Construct the shorthand expansion list PropertyValueList borderexp = - PropertySets.initialValueExpansion(foTree, PropNames.BORDER); + PropertySets.initialValueExpansion + (foNode.foTree, PropNames.BORDER); if (style != null) borderexp = PropertySets.overrideSHandElements(borderexp, (PropertyValueList)style); @@ -2176,15 +2238,15 @@ public abstract class Properties { * N.B. this is the order of elements defined in * PropertySets.borderRightExpansion * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { - return Properties.borderEdge(foTree, value, + return Properties.borderEdge(foNode, value, PropNames.BORDER_BOTTOM_STYLE, PropNames.BORDER_BOTTOM_COLOR, PropNames.BORDER_BOTTOM_WIDTH @@ -2295,29 +2357,29 @@ public abstract class Properties { * the third element is a value for border-bottom-color, * the fourth element is a value for border-left-color. * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { - return refineParsing(foTree, value, NOT_NESTED); + return refineParsing(foNode, value, NOT_NESTED); } /** * Do the work for the two argument refineParsing method. - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @param nested boolean indicating whether this method is * called normally (false), or as part of another refineParsing * method. * @return PropertyValue the verified value - * @see #refineParsing(FOTree,PropertyValue) + * @see #refineParsing(FONode,PropertyValue) */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value, boolean nested) + (FONode foNode, PropertyValue value, boolean nested) throws PropertyException { int type = value.getType(); @@ -2326,10 +2388,12 @@ public abstract class Properties { if (type == PropertyValue.INHERIT || type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); } if (type == PropertyValue.COLOR_TYPE) - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); if (type == PropertyValue.NCNAME) { // Must be a standard color ColorType color; @@ -2341,7 +2405,8 @@ public abstract class Properties { (((NCName)value).getNCName() + " not a standard color for border-color"); } - return PropertySets.expandAndCopySHand(color); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(color)); } else throw new PropertyException ("Invalid " + value.getClass().getName() + @@ -2542,15 +2607,15 @@ public abstract class Properties { * N.B. this is the order of elements defined in * PropertySets.borderRightExpansion * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { - return Properties.borderEdge(foTree, value, + return Properties.borderEdge(foNode, value, PropNames.BORDER_LEFT_STYLE, PropNames.BORDER_LEFT_COLOR, PropNames.BORDER_LEFT_WIDTH @@ -2628,15 +2693,15 @@ public abstract class Properties { * N.B. this is the order of elements defined in * PropertySets.borderRightExpansion * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { - return Properties.borderEdge(foTree, value, + return Properties.borderEdge(foNode, value, PropNames.BORDER_RIGHT_STYLE, PropNames.BORDER_RIGHT_COLOR, PropNames.BORDER_RIGHT_WIDTH @@ -2750,12 +2815,12 @@ public abstract class Properties { * Note: the Lengths cannot be percentages (what about relative * lengths?) * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { int type = value.getType(); @@ -2763,11 +2828,13 @@ public abstract class Properties { if (type == PropertyValue.INHERIT || type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); if (type == PropertyValue.NUMERIC && ((Numeric)value).isLength()) - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); throw new PropertyException ("Invalid " + value.getClass().getName() + @@ -2929,29 +2996,29 @@ public abstract class Properties { * the third element is a value for border-bottom-style, * the fourth element is a value for border-left-style. * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { - return refineParsing(foTree, value, NOT_NESTED); + return refineParsing(foNode, value, NOT_NESTED); } /** * Do the work for the two argument refineParsing method. - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @param nested boolean indicating whether this method is * called normally (false), or as part of another refineParsing * method. * @return PropertyValue the verified value - * @see #refineParsing(FOTree,PropertyValue) + * @see #refineParsing(FONode,PropertyValue) */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value, boolean nested) + (FONode foNode, PropertyValue value, boolean nested) throws PropertyException { int type = value.getType(); @@ -2960,7 +3027,8 @@ public abstract class Properties { if (type == PropertyValue.INHERIT || type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); } if (type == PropertyValue.NCNAME) { // Must be a border-style @@ -2973,7 +3041,8 @@ public abstract class Properties { (((NCName)value).getNCName() + " not a border-style"); } - return PropertySets.expandAndCopySHand(enum); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(enum)); } else throw new PropertyException ("Invalid " + value.getClass().getName() + @@ -3049,15 +3118,15 @@ public abstract class Properties { * N.B. this is the order of elements defined in * PropertySets.borderRightExpansion * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { - return Properties.borderEdge(foTree, value, + return Properties.borderEdge(foNode, value, PropNames.BORDER_TOP_STYLE, PropNames.BORDER_TOP_COLOR, PropNames.BORDER_TOP_WIDTH @@ -3146,29 +3215,29 @@ public abstract class Properties { * the third element is a value for border-bottom-width, * the fourth element is a value for border-left-width. * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { - return refineParsing(foTree, value, NOT_NESTED); + return refineParsing(foNode, value, NOT_NESTED); } /** * Do the work for the two argument refineParsing method. - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @param nested boolean indicating whether this method is * called normally (false), or as part of another refineParsing * method. * @return PropertyValue the verified value - * @see #refineParsing(FOTree,PropertyValue) + * @see #refineParsing(FONode,PropertyValue) */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value, boolean nested) + (FONode foNode, PropertyValue value, boolean nested) throws PropertyException { int type = value.getType(); @@ -3177,7 +3246,8 @@ public abstract class Properties { if (type == PropertyValue.INHERIT || type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); } if (type == PropertyValue.NCNAME) { // Must be a border-width @@ -3188,7 +3258,7 @@ public abstract class Properties { try { mapped = (new MappedNumeric(PropNames.BORDER_TOP_WIDTH, - ((NCName)value).getNCName(), foTree)) + ((NCName)value).getNCName(), foNode.foTree)) .getMappedNumValue(); } catch (PropertyException e) { throw new PropertyException @@ -3197,7 +3267,8 @@ public abstract class Properties { } // Correct the property in the mapped Numeric mapped.setProperty(PropNames.BORDER_WIDTH); - return PropertySets.expandAndCopySHand(mapped); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(mapped)); } else throw new PropertyException ("Invalid " + value.getClass().getName() + @@ -3221,11 +3292,13 @@ public abstract class Properties { // There must be at least two top = (new MappedNumeric (PropNames.BORDER_TOP_WIDTH, - ((NCName)(widths.next())).getNCName(), foTree) + ((NCName)(widths.next())).getNCName(), + foNode.foTree) ).getMappedNumValue(); right = (new MappedNumeric (PropNames.BORDER_RIGHT_WIDTH, - ((NCName)(widths.next())).getNCName(), foTree) + ((NCName)(widths.next())).getNCName(), + foNode.foTree) ).getMappedNumValue(); try { bottom = (Numeric)(top.clone()); @@ -3240,12 +3313,14 @@ public abstract class Properties { if (widths.hasNext()) bottom = (new MappedNumeric (PropNames.BORDER_BOTTOM_WIDTH, - ((NCName)(widths.next())).getNCName(), foTree) + ((NCName)(widths.next())).getNCName(), + foNode.foTree) ).getMappedNumValue(); if (widths.hasNext()) left = (new MappedNumeric (PropNames.BORDER_LEFT_WIDTH, - ((NCName)(widths.next())).getNCName(), foTree) + ((NCName)(widths.next())).getNCName(), + foNode.foTree) ).getMappedNumValue(); list = new PropertyValueList(PropNames.BORDER_WIDTH); @@ -3429,12 +3504,12 @@ public abstract class Properties { public static final int inherited = NO; /* - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { int type = value.getType(); @@ -3598,12 +3673,12 @@ public abstract class Properties { * The first element is a value for cue-before, * the second element is a value for cue-after. * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { int type = value.getType(); @@ -3612,7 +3687,8 @@ public abstract class Properties { type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED || type == PropertyValue.URI_TYPE) - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); throw new PropertyException ("Invalid " + value.getClass().getName() + " object for cue"); @@ -4022,18 +4098,18 @@ public abstract class Properties { *

The setup of the shorthand expansion list is determined by the * above considerations. * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { PropertyValueList startList = null; PropertyValueList fontList = null; if (value.getType() != PropertyValue.LIST) { - return processValue(foTree, value); + return processValue(foNode, value); } else { fontList = (PropertyValueList)value; try { @@ -4066,12 +4142,12 @@ public abstract class Properties { + "'font' expression"); startList = (PropertyValueList)tmpo; } - return processSpaceSepList(foTree, startList, fontList); + return processSpaceSepList(foNode, startList, fontList); } } private static PropertyValueList processValue - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { // Can be Inherit, FromParent, FromNearestSpecified, a @@ -4081,7 +4157,8 @@ public abstract class Properties { type == PropertyValue.FROM_PARENT || type == PropertyValue.FROM_NEAREST_SPECIFIED) { - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); } // else not Inherit/From../From.. FontFamilySet family = null; @@ -4096,6 +4173,8 @@ public abstract class Properties { ("Unrecognized NCName in font expression: " + ncname); } // A system font enum + // System font characteristics should require no further + // refinement return SystemFontFunction.expandFontSHand (PropNames.FONT, ncname); } @@ -4124,6 +4203,8 @@ public abstract class Properties { * must be from the specification * [font-style||font-variant||font-weight]? * + * @param foNode the FONode with which this property is + * associated. * @param list a PropertyValueList containing the actual * space-separated list; i.e. the single inner list from the * outer list returned by the parser. or removed from the front of @@ -4138,7 +4219,7 @@ public abstract class Properties { * @exception PropertyValueException */ private static PropertyValueList - processSpaceSepList(FOTree foTree, + processSpaceSepList(FONode foNode, PropertyValueList list, PropertyValueList fontList) throws PropertyException @@ -4178,11 +4259,11 @@ public abstract class Properties { familyStart = slash + 2; fontsize = slash - 1; size = FontSize.refineParsing - (foTree, propvals[fontsize], IS_NESTED); + (foNode, propvals[fontsize], IS_NESTED); // derive the line-height // line-height is at slash + 1 height = LineHeight.refineParsing - (foTree, propvals[slash + 1], IS_NESTED); + (foNode, propvals[slash + 1], IS_NESTED); } else { // Don''t know where slash is. If anything precedes the // font-family, it must be a font-size. Look for that. @@ -4193,7 +4274,7 @@ public abstract class Properties { String name = ((NCName)propvals[fontsize]).getNCName(); try { size = new MappedNumeric - (PropNames.FONT_SIZE, name, foTree); + (PropNames.FONT_SIZE, name, foNode.foTree); } catch (PropertyException e) { // Attempt to derive mapped numeric failed continue; @@ -4238,7 +4319,7 @@ public abstract class Properties { if (fontList.size() == 0 && familyStart == (propvals.length - 1)) { fontset = FontFamily.refineParsing - (foTree, propvals[familyStart], IS_NESTED); + (foNode, propvals[familyStart], IS_NESTED); } else { // Must develop a list to prepend to fontList PropertyValueList tmpList = @@ -4248,7 +4329,7 @@ public abstract class Properties { fontList.addFirst(tmpList); // Get a FontFamilySet fontset = FontFamily.refineParsing - (foTree, fontList, IS_NESTED); + (foNode, fontList, IS_NESTED); } // Only font-style font-variant and font-weight, in any order // remain as possibilities at the front of the expression @@ -4256,7 +4337,7 @@ public abstract class Properties { PropertyValue pv = null; try { pv = FontStyle.refineParsing - (foTree, propvals[i], IS_NESTED); + (foNode, propvals[i], IS_NESTED); if (style != null) MessageHandler.log("font: duplicate" + "style overrides previous style"); @@ -4266,7 +4347,7 @@ public abstract class Properties { try { pv = FontVariant.refineParsing - (foTree, propvals[i], IS_NESTED); + (foNode, propvals[i], IS_NESTED); if (variant != null) MessageHandler.log("font: duplicate" + "variant overrides previous variant"); @@ -4276,7 +4357,7 @@ public abstract class Properties { try { pv = FontWeight.refineParsing - (foTree, propvals[i], IS_NESTED); + (foNode, propvals[i], IS_NESTED); if (weight != null) MessageHandler.log("font: duplicate" + "weight overrides previous weight"); @@ -4292,7 +4373,8 @@ public abstract class Properties { // values of individual components newlist = - PropertySets.initialValueExpansion(foTree, PropNames.FONT); + PropertySets.initialValueExpansion + (foNode.foTree, PropNames.FONT); // For each discovered property, override the value in the // initial value expansion. ListIterator expansions = newlist.listIterator(); @@ -4357,7 +4439,7 @@ public abstract class Properties { } public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { // There is no point in attempting to validate the enumeration @@ -4373,11 +4455,11 @@ public abstract class Properties { // be at the top level, and any font family names // that contained spaces will be in PropertyValueLists. - return refineParsing(foTree, value, NOT_NESTED); + return refineParsing(foNode, value, NOT_NESTED); } public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value, boolean nested) + (FONode foNode, PropertyValue value, boolean nested) throws PropertyException { int property = value.getProperty(); @@ -4385,8 +4467,7 @@ public abstract class Properties { // First, check that we have a list if (type != PropertyValue.LIST) { if ( ! nested && type == PropertyValue.INHERIT) { - return value; // DUMMY - //return ((Inherit)value).resolve(foTree); + return ((Inherit)value).resolve(foNode); } if ( ! (value instanceof StringType)) throw new PropertyException @@ -4657,34 +4738,34 @@ public abstract class Properties { public static final ROStringArray enumValues = enums; /* - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { - return refineParsing(foTree, value, NOT_NESTED); + return refineParsing(foNode, value, NOT_NESTED); } /** * Do the work for the two argument refineParsing method. - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @param nested boolean indicating whether this method is * called normally (false), or as part of another refineParsing * method. * @return PropertyValue the verified value - * @see #refineParsing(FOTree,PropertyValue) + * @see #refineParsing(FONode,PropertyValue) */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value, boolean nested) + (FONode foNode, PropertyValue value, boolean nested) throws PropertyException { // Override the shadowed method to ensure that Integer values // are limited to the valid numbers - PropertyValue fw = Properties.refineParsing(foTree, value, nested); + PropertyValue fw = Properties.refineParsing(foNode, value, nested); // If the result is an IntegerType, restrict the values if (fw instanceof IntegerType) { int weight = ((IntegerType)fw).getInt(); @@ -5549,12 +5630,12 @@ public abstract class Properties { * the third element is a value for margin-bottom, * the fourth element is a value for margin-left. * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { if ( ! (value instanceof PropertyValueList)) { @@ -5562,9 +5643,13 @@ public abstract class Properties { || value instanceof FromParent || value instanceof FromNearestSpecified ) - return PropertySets.expandAndCopySHand(value); - return PropertySets.expandAndCopySHand - (autoOrDistance(value)); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); + // N.B. Does this require further refinement? + // Where is Auto expanded? + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand + (autoOrDistance(value))); } else { PropertyValueList list = spaceSeparatedList((PropertyValueList)value); @@ -5936,12 +6021,12 @@ public abstract class Properties { * the third element is a value for padding-bottom, * the fourth element is a value for padding-left. * - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { if ( ! (value instanceof PropertyValueList)) { @@ -5951,7 +6036,8 @@ public abstract class Properties { || (value instanceof Numeric && ((Numeric)value).isDistance()) ) - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); throw new PropertyException ("Invalid property value for 'padding': " + value.getClass().getName()); @@ -6253,12 +6339,12 @@ public abstract class Properties { } /* - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { if (value instanceof Inherit | @@ -6266,7 +6352,8 @@ public abstract class Properties { value instanceof FromNearestSpecified | value instanceof Auto) { - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); } if (value instanceof NCName) { EnumType enum = null; @@ -6315,12 +6402,12 @@ public abstract class Properties { = PageBreakAfter.rwEnumValues; /* - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { if (value instanceof Inherit | @@ -6328,7 +6415,8 @@ public abstract class Properties { value instanceof FromNearestSpecified | value instanceof Auto) { - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); } if (value instanceof NCName) { EnumType enum = null; @@ -6385,12 +6473,12 @@ public abstract class Properties { public static final ROStringArray enumValues = enums; /* - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { if (value instanceof Inherit | @@ -6398,7 +6486,8 @@ public abstract class Properties { value instanceof FromNearestSpecified | value instanceof Auto) { - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); } if (value instanceof NCName) { EnumType enum = null; @@ -6543,19 +6632,20 @@ public abstract class Properties { public static final ROStringArray enumValues = enums; /* - * @param foTree the FOTree being built + * @param foNode - the FONode being built * @param value PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue value) + (FONode foNode, PropertyValue value) throws PropertyException { if (value instanceof Inherit | value instanceof FromParent | value instanceof FromNearestSpecified) { - return PropertySets.expandAndCopySHand(value); + return refineExpansionList + (foNode, PropertySets.expandAndCopySHand(value)); } if (value instanceof NCName) { EnumType enum = null; @@ -7021,16 +7111,16 @@ public abstract class Properties { public static final int inherited = NO; /* - * @param foTree the FOTree being built - * @param value PropertyValue returned by the parser + * @param foNode - the FONode being built + * @param list PropertyValue returned by the parser * @return PropertyValue the verified value */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue list) + (FONode foNode, PropertyValue list) throws PropertyException { if ( ! (list instanceof PropertyValueList)) - return Properties.refineParsing(foTree, list); + return Properties.refineParsing(foNode, list); // Confirm that the list contains only UriType elements Iterator iter = ((PropertyValueList)list).iterator(); while (iter.hasNext()) { @@ -7536,14 +7626,14 @@ public abstract class Properties { public static final ROStringArray enumValues = enums; public static PropertyValue refineParsing - (FOTree foTree, PropertyValue list) + (FONode foNode, PropertyValue list) throws PropertyException { // Check for the enumeration. Look for a list of NCNames. // N.B. it may be possible to perform further checks on the // validity of the NCNames - do they match multi-case case names. if ( ! (list instanceof PropertyValueList)) - return Properties.refineParsing(foTree, list); + return Properties.refineParsing(foNode, list); PropertyValueList ssList = spaceSeparatedList((PropertyValueList)list); @@ -7814,7 +7904,7 @@ public abstract class Properties { }); public static PropertyValue refineParsing - (FOTree foTree, PropertyValue list) + (FONode foNode, PropertyValue list) throws PropertyException { byte onMask = NO_DECORATION; @@ -7919,12 +8009,12 @@ public abstract class Properties { * specifier. */ public static PropertyValue refineParsing - (FOTree foTree, PropertyValue list) + (FONode foNode, PropertyValue list) throws PropertyException { int property = list.getProperty(); if ( ! (list instanceof PropertyValueList)) { - return Properties.refineParsing(foTree, list); + return Properties.refineParsing(foNode, list); } if (((PropertyValueList)list).size() == 0) throw new PropertyException -- 2.39.5