From: Peter Bernard West Date: Tue, 27 Apr 2004 15:20:22 +0000 (+0000) Subject: More work on border corresponding properties; X-Git-Tag: Defoe_export~212 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7212953b1ec3131ebfb1d55f9bf664c8cfde74be;p=xmlgraphics-fop.git More work on border corresponding properties; Resolving compound corresponding properties git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197542 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index f19375681..72ba65119 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -288,6 +288,14 @@ public class FONode extends SyncedNode{ PropertyConsts.pconsts.getProperty(property); specifiedProps.set(property); // Handle corresponding properties here + // Note that the resolution of corresponding properties, like + // shorthands and compounds, relies on the ordering imposed by the + // property indices. Each property, in increasing index order, is + // processed as if it were the only relevant assignment. The lowest + // priority properties (among shorthands and their expansions, + // compounds and their expansions, and corresponding properties and + // their correspondents) are processed first, then higher priority + // assignments simply overwrite the earlier value assignments. if (tempP instanceof CorrespondingProperty) { // Update the propertySet propertySet[property] = propval; diff --git a/src/java/org/apache/fop/fo/properties/Property.java b/src/java/org/apache/fop/fo/properties/Property.java index ad67a1744..ea37b3139 100644 --- a/src/java/org/apache/fop/fo/properties/Property.java +++ b/src/java/org/apache/fop/fo/properties/Property.java @@ -366,7 +366,7 @@ public class Property { /** * Do the work for the three argument refineParsing method. - * @param property - the int property index. + * @param propindex - the int property index. * @param foNode - the FONode being built * @param value - PropertyValue returned by the parser * @param nested - boolean indicating whether this method is @@ -374,17 +374,17 @@ public class Property { * method. * @see #refineParsing(int,FONode,PropertyValue) */ - public PropertyValue refineParsing(int property, + public PropertyValue refineParsing(int propindex, FONode foNode, PropertyValue value, boolean nested) throws PropertyException { - //int property = value.getProperty(); - if (property != value.getProperty()) // DEBUG + //int propindex = value.getProperty(); + if (propindex != value.getProperty()) // DEBUG throw new PropertyException ("Mismatched property and value.property."); - String propName = PropNames.getPropertyName(property); + String propName = PropNames.getPropertyName(propindex); int proptype = value.getType(); - int dataTypes = PropertyConsts.pconsts.getDataTypes(property); + int dataTypes = PropertyConsts.pconsts.getDataTypes(propindex); PropertyValue pv; if ((dataTypes & AURAL) != 0) throw new PropertyNotImplementedException @@ -411,16 +411,16 @@ public class Property { if ((dataTypes & (NCNAME | CHARACTER_T)) != 0) return value; if ((dataTypes & COUNTRY_T) != 0) - return new CountryType(property, ncname); + return new CountryType(propindex, ncname); if ((dataTypes & LANGUAGE_T) != 0) - return new LanguageType(property, ncname); + return new LanguageType(propindex, ncname); if ((dataTypes & SCRIPT_T) != 0) - return new ScriptType(property, ncname); + return new ScriptType(propindex, ncname); if ((dataTypes & ENUM) != 0) - return new EnumType(property, ncname); + return new EnumType(propindex, ncname); if ((dataTypes & MAPPED_LENGTH) != 0) return (new MappedNumeric - (foNode, property, ncname)).getMappedNumValue(); + (foNode, propindex, ncname)).getMappedNumValue(); throw new PropertyException ("NCName value invalid for " + propName); case PropertyValue.ENUM: @@ -480,10 +480,54 @@ public class Property { ("PropertyValueList passed to Property.refineParsing for " + propName + "\n" + value.toString()); default: + // The COMPOUND test was orginally protected by the + // if ( ! nested) fence. Only within Font, Border and + // Background shorthands is refineParsing called with a + // nested value of 'true'. This may cause problems, in which case + // the COMPOUND processing will have to be repeated within the + // (property instanceof CorrespondingProperty) case. + if ((dataTypes & COMPOUND) != 0) + return ShorthandPropSets.expandCompoundProperty + (foNode.getFOTree(), value); if ( ! nested) { - if ((dataTypes & COMPOUND) != 0) - return ShorthandPropSets.expandCompoundProperty - (foNode.getFOTree(), value); + int correspIndex = 0; + Property property = + PropertyConsts.pconsts.getProperty(propindex); + if (property instanceof CorrespondingProperty) { + correspIndex = + ((CorrespondingProperty)property) + .getCorrespondingProperty(foNode); + // Note - can't call refineParsing recursively to resolve + // corresponding compounds, because the compound is itself + // a corresponding property + // Create a list, containing this PropertyValue on + // the original property, plus the value on the + // expansion of the corresponding property + PropertyValueList newlist = + new PropertyValueList(propindex); + newlist.add(value); + PropertyValue corresPv = null; + try { + corresPv = (PropertyValue)(value.clone()); + } catch (CloneNotSupportedException e) { + throw new PropertyException(e.getMessage()); + } + corresPv.setProperty(correspIndex); + corresPv = PropertyConsts.pconsts.refineParsing( + corresPv.getProperty(), foNode, + corresPv, IS_NESTED); +// if it's a list, recursively refine. This will return a list + if (corresPv.getType() == PropertyValue.LIST) { + PropertyValueList pvl = + refineExpansionList( + corresPv.getProperty(), foNode, + (PropertyValueList)corresPv); + newlist.addAll(pvl); + } else { // single element + newlist.add(corresPv); + } + return newlist; + } if (proptype == PropertyValue.INHERIT) { if ((dataTypes & INHERIT) != 0) return ((Inherit)value).resolve(foNode);