Author: adelmelle
Date: Sun Feb 10 04:31:46 2008
New Revision: 620272

URL: http://svn.apache.org/viewvc?rev=620272&view=rev
Log:
Some minor tweaks:
* added convenience shortcut to PropertyInfo to get to the user agent.
* replaced occurrences to use the shortcut in PropertyParser and 
RGBColorFunction.
* PropertyParser -> 0% of a length always yields FixedLength.ZERO_FIXED_LENGTH

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PropertyInfo.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PropertyParser.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RGBColorFunction.java

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PropertyInfo.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PropertyInfo.java?rev=620272&r1=620271&r2=620272&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PropertyInfo.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PropertyInfo.java Sun 
Feb 10 04:31:46 2008
@@ -21,6 +21,7 @@
 
 import java.util.Stack;
 
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.datatypes.PercentBase;
 import org.apache.fop.fo.Constants;
@@ -114,6 +115,17 @@
         }
     }
 
+    /**
+     * Convenience shortcut to get a reference to the FOUserAgent
+     * 
+     * @return  the FOUserAgent
+     */
+    protected FOUserAgent getUserAgent() {
+        return (plist.getFObj() != null) 
+            ? plist.getFObj().getUserAgent() 
+                    : null;
+    }
+    
     private PercentBase getFunctionPercentBase() {
         if (stkFunction != null) {
             Function f = (Function)stkFunction.peek();

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PropertyParser.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PropertyParser.java?rev=620272&r1=620271&r2=620272&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PropertyParser.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PropertyParser.java 
Sun Feb 10 04:31:46 2008
@@ -275,6 +275,11 @@
                     prop = NumberProperty.getInstance(pcval * 
pcBase.getBaseValue());
                 } else if (pcBase.getDimension() == 1) {
                     if (pcBase instanceof LengthBase) {
+                        if (pcval == 0.0) {
+                            prop = FixedLength.ZERO_FIXED_LENGTH;
+                            break;
+                        }
+
                         //If the base of the percentage is known
                         //and absolute, it can be resolved by the
                         //parser
@@ -319,9 +324,7 @@
             break;
 
         case TOK_COLORSPEC:
-            prop = ColorProperty.getInstance(
-                    propInfo.getPropertyList().getFObj().getUserAgent(), 
-                    currentTokenValue);
+            prop = ColorProperty.getInstance(propInfo.getUserAgent(), 
currentTokenValue);
             break;
 
         case TOK_FUNCTION_LPAR:

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RGBColorFunction.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RGBColorFunction.java?rev=620272&r1=620271&r2=620272&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RGBColorFunction.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/RGBColorFunction.java 
Sun Feb 10 04:31:46 2008
@@ -19,7 +19,6 @@
  
 package org.apache.fop.fo.expr;
 
-import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.datatypes.PercentBase;
 import org.apache.fop.fo.properties.ColorProperty;
@@ -47,14 +46,13 @@
     /** [EMAIL PROTECTED] */
     public Property eval(Property[] args,
                          PropertyInfo pInfo) throws PropertyException {
-      FOUserAgent ua = (pInfo == null) 
-              ? null 
-              : (pInfo.getFO() == null ? null : pInfo.getFO().getUserAgent());
-      return ColorProperty.getInstance(ua, "rgb(" + args[0] + "," + args[1] + 
"," + args[2] + ")");
+      return ColorProperty.getInstance(pInfo.getUserAgent(), 
+                                       "rgb(" + args[0] + "," 
+                                       + args[1] + "," + args[2] + ")");
 
     }
 
-    static class RGBPercentBase implements PercentBase {
+    private static class RGBPercentBase implements PercentBase {
         public int getDimension() {
             return 0;
         }



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

Reply via email to