]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
More String->Int Conversions.
authorGlen Mazza <gmazza@apache.org>
Mon, 5 Jan 2004 01:31:09 +0000 (01:31 +0000)
committerGlen Mazza <gmazza@apache.org>
Mon, 5 Jan 2004 01:31:09 +0000 (01:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197115 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/datatypes/LengthBase.java
src/java/org/apache/fop/fo/PropertyList.java
src/java/org/apache/fop/fo/expr/InheritedPropFunction.java
src/java/org/apache/fop/fo/pagination/RegionBody.java

index 705603762cc0abddf47ab3763406877df415f14a..b0d49496624ebaa6e87609013ac0b89549523534 100644 (file)
@@ -142,7 +142,7 @@ public class LengthBase implements PercentBase {
         case FONTSIZE:
             return propertyList.get(Constants.PR_FONT_SIZE).getLength().getValue();
         case INH_FONTSIZE:
-            return propertyList.getInherited("font-size").getLength().getValue();
+            return propertyList.getInherited(Constants.PR_FONT_SIZE).getLength().getValue();
         //case CONTAINING_BOX:
             // depends on property?? inline-progression vs block-progression
             //return parentFO.getContentWidth();
index 08b44bf4f9f27213fd21ab0a566408f8c6668d22..0f02b013254aaffc9256b4c0af3d8d33388afa8f 100644 (file)
@@ -184,20 +184,11 @@ public class PropertyList extends HashMap {
      */
     public Property getExplicitOrShorthand(int propId) {
         /* Handle request for one part of a compound property */
-        String propertyName = FOPropertyMapping.getPropertyName(propId);
-
-        int sepchar = propertyName.indexOf('.');
-        String baseName;
-        if (sepchar > -1) {
-            baseName = propertyName.substring(0, sepchar);
-        } else {
-            baseName = propertyName;
-        }
-        Property p = getExplicitBaseProp(baseName);
+        Property p = getExplicitBaseProp(propId & Constants.PROPERTY_MASK);
         if (p == null) {
             p = getShorthand(propId & Constants.PROPERTY_MASK);
         }
-        if (p != null && sepchar > -1) {
+        if (p != null && (propId & Constants.PROPERTY_MASK) != 0) {
             return getSubpropValue(p, propId);
         }
         return p;
@@ -213,10 +204,8 @@ public class PropertyList extends HashMap {
         String propertyName = FOPropertyMapping.getPropertyName(propId);
 
         /* Handle request for one part of a compound property */
-        int sepchar = propertyName.indexOf('.');
-        if (sepchar > -1) {
-            String baseName = propertyName.substring(0, sepchar);
-            Property p = getExplicitBaseProp(baseName);
+        if ((propId & Constants.COMPOUND_MASK) != 0) {
+            Property p = getExplicitBaseProp(propId & Constants.PROPERTY_MASK);
             if (p != null) {
                 return getSubpropValue(p, propId);
             } else {
@@ -231,7 +220,8 @@ public class PropertyList extends HashMap {
      * @param propertyName The name of the base property whose value is desired.
      * @return The value if the property is explicitly set, otherwise null.
      */
-    public Property getExplicitBaseProp(String propertyName) {
+    public Property getExplicitBaseProp(int propId) {
+        String propertyName = FOPropertyMapping.getPropertyName(propId);
         return (Property) super.get(propertyName);
     }
 
@@ -239,11 +229,10 @@ public class PropertyList extends HashMap {
      * Return the value of this property inherited by this FO.
      * Implements the inherited-property-value function.
      * The property must be inheritable!
-     * @param propertyName The name of the property whose value is desired.
+     * @param propID The ID of the property whose value is desired.
      * @return The inherited value, otherwise null.
      */
-    public Property getInherited(String propertyName) {
-        int propId = FOPropertyMapping.getPropertyId(propertyName);
+    public Property getInherited(int propId) {
 
         if (parentPropertyList != null
                 && isInherited(propId)) {
@@ -315,14 +304,12 @@ public class PropertyList extends HashMap {
      * happens in computeProperty.
      */
     private Property findProperty(int propId, boolean bTryInherit) {
-
-        String propertyName = FOPropertyMapping.getPropertyName(propId);
-
         Property p = null;
+
         if (isCorrespondingForced(propId)) {
             p = computeProperty(propId);
         } else {
-            p = getExplicitBaseProp(propertyName);
+            p = getExplicitBaseProp(propId);
             if (p == null) {
                 p = this.computeProperty(propId);
             }
@@ -348,13 +335,13 @@ public class PropertyList extends HashMap {
      * ancestor of the current FO, else the initial value.
      */
     public Property getNearestSpecified(int propId) {
-        String propertyName = FOPropertyMapping.getPropertyName(propId);
-
         Property p = null;
+
         for (PropertyList plist = this; p == null && plist != null;
                 plist = plist.parentPropertyList) {
             p = plist.getExplicit(propId);
         }
+
         if (p == null) {
             // If no explicit setting found, return initial (default) value.
             try {
@@ -506,7 +493,7 @@ public class PropertyList extends HashMap {
                  * the base attribute was already created in 
                  * findBaseProperty()
                  */
-                if (getExplicitBaseProp(basePropertyName) != null) {
+                if (super.get(basePropertyName) != null) {
                     return;
                 }
                 prop = propertyMaker.make(this, attributeValue, parentFO);
@@ -534,7 +521,9 @@ public class PropertyList extends HashMap {
         /* If the baseProperty has already been created, return it
          * e.g. <fo:leader xxxx="120pt" xxxx.maximum="200pt"... />
          */
-        Property baseProperty = getExplicitBaseProp(basePropName);
+        int propId = FOPropertyMapping.getPropertyId(basePropName);
+        Property baseProperty = getExplicitBaseProp(propId);
+
         if (baseProperty != null) {
             return baseProperty;
         }
@@ -544,13 +533,10 @@ public class PropertyList extends HashMap {
          */
         String basePropertyValue = attributes.getValue(basePropName);
         
-        if (basePropertyValue != null) {
-            int propertyId = FOPropertyMapping.getPropertyId(basePropName);
-            if (propertyId != -1) {
-                baseProperty = propertyMaker.make(this, basePropertyValue,
-                    parentFO);
-                return baseProperty;
-            }
+        if (basePropertyValue != null && propertyMaker != null) {
+            baseProperty = propertyMaker.make(this, basePropertyValue,
+                                              parentFO);
+            return baseProperty;
         }
         
         return null;  // could not find base property
index 7cdcdd85015851d358ea36d91306f92c40765a50..8b660412f4e3fbe57d7d505696fef8b77288cc79 100644 (file)
@@ -51,6 +51,7 @@
 package org.apache.fop.fo.expr;
 
 import org.apache.fop.fo.Property;
+import org.apache.fop.fo.properties.FOPropertyMapping;
 
 /**
  * Class modelling the inherited-property-value Property Value function. See
@@ -79,7 +80,9 @@ public class InheritedPropFunction extends FunctionBase {
         if (propName == null) {
             throw new PropertyException("Incorrect parameter to inherited-property-value function");
         }
-        return pInfo.getPropertyList().getInherited(propName);
+
+        int propId = FOPropertyMapping.getPropertyId(propName);
+        return pInfo.getPropertyList().getInherited(propId);
     }
 
 }
index 0ead9798138e6d48d93d7aa03199cb62b083c5f4..38b0f8cd0badb6db7aa8ebe5f3c3fdac895134b2 100644 (file)
@@ -60,6 +60,7 @@ import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.Property;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.properties.CommonMarginBlock;
+import org.apache.fop.fo.properties.FOPropertyMapping;
 import org.apache.fop.fo.properties.WritingMode;
 
 /**
@@ -112,9 +113,11 @@ public class RegionBody extends Region {
         FObj parent = (FObj) getParent();
         String sPropName = "margin-"
                 + parent.propertyList.wmRelToAbs(reldir);
-        Property prop = propertyList.getExplicitBaseProp(sPropName);
+        int propId = FOPropertyMapping.getPropertyId(sPropName);
+        Property prop = propertyList.getExplicitBaseProp(propId);
         if (prop == null) {
-            prop = propertyList.getExplicitBaseProp(sRelPropName);
+            propId = FOPropertyMapping.getPropertyId(sRelPropName);
+            prop = propertyList.getExplicitBaseProp(propId);
         }
         return ((prop != null) ? prop.getLength().getValue() : 0);
     }