pbwest      2004/04/27 08:20:22

  Modified:    src/java/org/apache/fop/fo/properties Tag:
                        FOP_0-20-0_Alt-Design Property.java
               src/java/org/apache/fop/fo Tag: FOP_0-20-0_Alt-Design
                        FONode.java
  Log:
  More work on border corresponding properties;
  Resolving compound corresponding properties
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.13  +61 -17    xml-fop/src/java/org/apache/fop/fo/properties/Property.java
  
  Index: Property.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/properties/Property.java,v
  retrieving revision 1.1.2.12
  retrieving revision 1.1.2.13
  diff -u -r1.1.2.12 -r1.1.2.13
  --- Property.java     24 Apr 2004 13:43:25 -0000      1.1.2.12
  +++ Property.java     27 Apr 2004 15:20:21 -0000      1.1.2.13
  @@ -366,7 +366,7 @@
   
       /**
        * Do the work for the three argument refineParsing method.
  -     * @param property - the <tt>int</tt> property index.
  +     * @param propindex - the <tt>int</tt> property index.
        * @param foNode - the <tt>FONode</tt> being built
        * @param value - <tt>PropertyValue</tt> returned by the parser
        * @param nested - <tt>boolean</tt> indicating whether this method is
  @@ -374,17 +374,17 @@
        * 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 @@
               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 @@
                   ("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);
  
  
  
  No                   revision
  No                   revision
  1.2.2.21  +8 -0      xml-fop/src/java/org/apache/fop/fo/FONode.java
  
  Index: FONode.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FONode.java,v
  retrieving revision 1.2.2.20
  retrieving revision 1.2.2.21
  diff -u -r1.2.2.20 -r1.2.2.21
  --- FONode.java       26 Apr 2004 14:47:23 -0000      1.2.2.20
  +++ FONode.java       27 Apr 2004 15:20:22 -0000      1.2.2.21
  @@ -288,6 +288,14 @@
               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;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to