]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
More work on border corresponding properties;
authorPeter Bernard West <pbwest@apache.org>
Tue, 27 Apr 2004 15:20:22 +0000 (15:20 +0000)
committerPeter Bernard West <pbwest@apache.org>
Tue, 27 Apr 2004 15:20:22 +0000 (15:20 +0000)
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

src/java/org/apache/fop/fo/FONode.java
src/java/org/apache/fop/fo/properties/Property.java

index f193756814532d255b4246926a01fc03e8b2a51d..72ba65119a4eec81999ba8ead545e463078115fd 100644 (file)
@@ -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;
index ad67a174476dfdbab0d215580079f3e2ebfed59a..ea37b31398735b8dbd88804ddefd46f216979387 100644 (file)
@@ -366,7 +366,7 @@ public class Property {
 
     /**
      * 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 @@ 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);