You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2006/07/11 14:45:30 UTC

svn commit: r420824 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties: FixedLength.java LengthProperty.java NumberProperty.java

Author: jeremias
Date: Tue Jul 11 05:45:29 2006
New Revision: 420824

URL: http://svn.apache.org/viewvc?rev=420824&view=rev
Log:
Bugzilla #39608:
Let numeric property values without a unit be treated as pixels like in HTML. This fixes certain NullPointerExceptions when no units are specified.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthProperty.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/NumberProperty.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java?rev=420824&r1=420823&r2=420824&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FixedLength.java Tue Jul 11 05:45:29 2006
@@ -60,7 +60,7 @@
     protected void convert(double dvalue, String unit) {
         // TODO: the whole routine smells fishy.
 
-        int assumedResolution = 1;    // points/pixel
+        int assumedResolution = 1;    // points/pixel = 72dpi
 
         if (unit.equals("in")) {
             dvalue = dvalue * 72;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthProperty.java?rev=420824&r1=420823&r2=420824&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthProperty.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/LengthProperty.java Tue Jul 11 05:45:29 2006
@@ -34,7 +34,6 @@
      * Inner class for making instances of LengthProperty
      */
     public static class Maker extends PropertyMaker {
-        private boolean autoOk = false;
 
         /**
          * @param propId the id of the property for which a Maker should be created
@@ -44,7 +43,9 @@
         }
 
         /**
-         * @see PropertyMaker#convertProperty
+         * @see org.apache.fop.fo.properties.PropertyMaker#convertProperty(
+         *          org.apache.fop.fo.properties.Property, org.apache.fop.fo.PropertyList, 
+         *          org.apache.fop.fo.FObj)
          */
         public Property convertProperty(Property p,
                                         PropertyList propertyList,
@@ -55,6 +56,10 @@
             if (p instanceof LengthProperty) {
                 return p;
             }
+            if (p instanceof NumberProperty) {
+                //Assume pixels (like in HTML) when there's no unit
+                return new FixedLength(p.getNumeric().getNumericValue(), "px");
+            }
             Length val = p.getLength();
             if (val != null) {
                 return (Property) val;
@@ -82,7 +87,7 @@
     }
 
     /**
-     * Return the numeric dimension. Length always a dimension of 1.
+     * @return the numeric dimension. Length always a dimension of 1.
      */
     public int getDimension() {
         return 1;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/NumberProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/NumberProperty.java?rev=420824&r1=420823&r2=420824&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/NumberProperty.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/NumberProperty.java Tue Jul 11 05:45:29 2006
@@ -20,6 +20,7 @@
 
 import java.awt.Color;
 
+import org.apache.fop.datatypes.Length;
 import org.apache.fop.datatypes.Numeric;
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FObj;
@@ -164,6 +165,12 @@
      */
     public Numeric getNumeric() {
         return this;
+    }
+
+    /** @see org.apache.fop.fo.properties.Property#getLength() */
+    public Length getLength() {
+        //Assume pixels (like in HTML) when there's no unit
+        return new FixedLength(getNumericValue(), "px");
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org