pbwest      2004/06/17 04:17:29

  Modified:    src/java/org/apache/fop/fo/properties Tag:
                        FOP_0-20-0_Alt-Design ReferenceOrientation.java
  Log:
  Added refneParsing() to validate the rotation values
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.4   +41 -1     
xml-fop/src/java/org/apache/fop/fo/properties/Attic/ReferenceOrientation.java
  
  Index: ReferenceOrientation.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/fo/properties/Attic/ReferenceOrientation.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- ReferenceOrientation.java 19 Feb 2004 03:11:41 -0000      1.1.2.3
  +++ ReferenceOrientation.java 17 Jun 2004 11:17:29 -0000      1.1.2.4
  @@ -22,6 +22,7 @@
   
   import org.apache.fop.datatypes.IntegerType;
   import org.apache.fop.datatypes.PropertyValue;
  +import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.PropNames;
   import org.apache.fop.fo.expr.PropertyException;
   
  @@ -53,6 +54,45 @@
   
       public int getInherited() {
           return inherited;
  +    }
  +
  +    public PropertyValue refineParsing
  +                        (int propindex, FONode foNode, PropertyValue value)
  +                    throws PropertyException
  +    {
  +        return refineParsing(propindex, foNode, value, NOT_NESTED);
  +    }
  +
  +    public PropertyValue refineParsing
  +        (int propindex, FONode foNode, PropertyValue value, boolean nested)
  +                    throws PropertyException
  +    {
  +        int proptype = value.getType();
  +        switch (proptype) {
  +        case PropertyValue.INTEGER:
  +            int angle = ((IntegerType)value).getInt();
  +            int absangle = Math.abs(angle);
  +            if (absangle == 0 || absangle == 90
  +                    || absangle == 180 || absangle == 270) {
  +                if (angle < 0) {
  +                    angle += 360;
  +                    ((IntegerType)value).setInt(angle);
  +                }
  +                return value;
  +            } else {
  +                int adjangle = angle % 360;
  +                if (adjangle < 0) {
  +                    adjangle += 360;
  +                }
  +                adjangle = (int)(Math.round(adjangle / 90.0f)) * 4;
  +                logger.warning("Illegal orientation value " + angle +
  +                        ". Replaced with " + adjangle);
  +                ((IntegerType)value).setInt(adjangle);
  +                return value;
  +            }
  +        default:
  +            return super.refineParsing(propindex, foNode, value, nested);
  +        }
       }
   
   }
  
  
  

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

Reply via email to