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 cb...@apache.org on 2013/01/04 16:11:52 UTC

svn commit: r1428918 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java status.xml

Author: cbowditch
Date: Fri Jan  4 15:11:52 2013
New Revision: 1428918

URL: http://svn.apache.org/viewvc?rev=1428918&view=rev
Log:
Jira FOP-2174: When using SVG drawings, if no content-width and content-height is specified, 72 will be used instead of the source-resolution option
Patch submitted by Robert Meyer (rmeyer at hotmail dot co dot uk)

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java?rev=1428918&r1=1428917&r2=1428918&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java Fri Jan  4 15:11:52 2013
@@ -25,10 +25,14 @@ import java.awt.Rectangle;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.xmlgraphics.util.UnitConv;
+
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.GraphicsProperties;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.flow.AbstractGraphics;
 import org.apache.fop.fo.properties.LengthRangeProperty;
 
 /**
@@ -98,9 +102,9 @@ public class ImageLayout implements Cons
         boolean constrainIntrinsicSize = false;
         int cwidth = -1;
         int cheight = -1;
-        len = props.getContentWidth();
-        if (len.getEnum() != EN_AUTO) {
-            switch (len.getEnum()) {
+        Length lenWidth = props.getContentWidth();
+        if (lenWidth.getEnum() != EN_AUTO) {
+            switch (lenWidth.getEnum()) {
             case EN_SCALE_TO_FIT:
                 if (ipd != -1) {
                     cwidth = ipd;
@@ -120,12 +124,12 @@ public class ImageLayout implements Cons
                 constrainIntrinsicSize = true;
                 break;
             default:
-                cwidth = len.getValue(percentBaseContext);
+                cwidth = lenWidth.getValue(percentBaseContext);
             }
         }
-        len = props.getContentHeight();
-        if (len.getEnum() != EN_AUTO) {
-            switch (len.getEnum()) {
+        Length lenHeight = props.getContentHeight();
+        if (lenHeight.getEnum() != EN_AUTO) {
+            switch (lenHeight.getEnum()) {
             case EN_SCALE_TO_FIT:
                 if (bpd != -1) {
                     cheight = bpd;
@@ -145,10 +149,21 @@ public class ImageLayout implements Cons
                 constrainIntrinsicSize = true;
                 break;
             default:
-                cheight = len.getValue(percentBaseContext);
+                cheight = lenHeight.getValue(percentBaseContext);
             }
         }
 
+        //If no content-width or height is specified, adjust dimensions based upon the source resolution
+        int sourceResolution = 72;
+        if (props instanceof AbstractGraphics) {
+            sourceResolution = (int) ((AbstractGraphics)props).getUserAgent().getSourceResolution();
+        }
+        boolean foundNonAuto = (lenWidth.getEnum() != EN_AUTO || lenHeight.getEnum() != EN_AUTO);
+        if (!foundNonAuto) {
+            cwidth = intrinsicSize.width / (sourceResolution / UnitConv.IN2PT);
+            cheight = intrinsicSize.height / (sourceResolution / UnitConv.IN2PT);
+        }
+
         Dimension constrainedIntrinsicSize;
         if (constrainIntrinsicSize) {
             constrainedIntrinsicSize = constrain(intrinsicSize);
@@ -164,11 +179,13 @@ public class ImageLayout implements Cons
         //Adjust viewport if not explicit
         if (ipd == -1) {
             ipd = constrainExtent(cwidth,
-                    props.getInlineProgressionDimension(), props.getContentWidth());
+                    props.getInlineProgressionDimension(), (foundNonAuto)
+                    ? props.getContentWidth() : new DefaultLength());
         }
         if (bpd == -1) {
             bpd = constrainExtent(cheight,
-                    props.getBlockProgressionDimension(), props.getContentHeight());
+                    props.getBlockProgressionDimension(), (foundNonAuto)
+                    ? props.getContentHeight() : new DefaultLength());
         }
 
         this.clip = false;
@@ -191,6 +208,36 @@ public class ImageLayout implements Cons
         this.placement = new Rectangle(xoffset, yoffset, cwidth, cheight);
     }
 
+    private static class DefaultLength implements Length {
+        public double getNumericValue() throws PropertyException {
+            return 0;
+        }
+
+        public double getNumericValue(PercentBaseContext context) throws PropertyException {
+            return 0;
+        }
+
+        public int getDimension() {
+            return 0;
+        }
+
+        public boolean isAbsolute() {
+            return false;
+        }
+
+        public int getEnum() {
+            return 0;
+        }
+
+        public int getValue() {
+            return 0;
+        }
+
+        public int getValue(PercentBaseContext context) {
+            return 0;
+        }
+    }
+
     private int constrainExtent(int extent, LengthRangeProperty range, Length contextExtent) {
         boolean mayScaleUp = (contextExtent.getEnum() != EN_SCALE_DOWN_TO_FIT);
         boolean mayScaleDown = (contextExtent.getEnum() != EN_SCALE_UP_TO_FIT);

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1428918&r1=1428917&r2=1428918&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Fri Jan  4 15:11:52 2013
@@ -59,6 +59,10 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Layout" dev="CB" type="fix" fixes-bug="FOP-2174" due-to="Robert Meyer">
+        When using SVG drawings, if no content-width and content-height is specified, 72 will
+        be used instead of the source-resolution option. 
+      </action>
       <action context="Code" dev="GA" type="fix" fixes-bug="FOP-2179" due-to="Robert Meyer">
         Fix checkstyle and findbugs warnings.
       </action>



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


RE: svn commit: r1428918 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java status.xml

Posted by Robert Meyer <rm...@hotmail.co.uk>.
Hi Glenn and Chris,

I have created the following issue for creating a junit test for this:

https://issues.apache.org/jira/browse/FOP-2181

I did look into creating an AT test for this originally, but because the AT tests don't seem to support specifying an xconf section or file reference, the test I wanted to create would not work. I may look into adding support for this optional section in the future myself if I get the chance.

Regards,

Robert

From: rmeyer@hotmail.co.uk
To: fop-dev@xmlgraphics.apache.org
Subject: RE: svn commit: r1428918 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java status.xml
Date: Fri, 4 Jan 2013 16:58:59 +0000




Hi,

I'll look into creating an AT test and / or junit test next week for this. I'll update the existing jira issue if that's possible, but if not then I'll create a new one.

Regards,

Robert

> Date: Fri, 4 Jan 2013 16:43:12 +0000
> From: bowditch_chris@hotmail.com
> To: fop-dev@xmlgraphics.apache.org
> Subject: Re: svn commit: r1428918 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java status.xml
> 
> Hi Glenn,
> 
> Rob didn't submit one, but since the change affects layout that is a 
> reasonable request.
> 
> Thanks,
> 
> Chris
> 
> On 04/01/2013 16:25, Glenn Adams wrote:
> > are there any new tests to go along with this?
> >
> > On Fri, Jan 4, 2013 at 9:11 AM, <cbowditch@apache.org 
> > <ma...@apache.org>> wrote:
> >
> >     Author: cbowditch
> >     Date: Fri Jan  4 15:11:52 2013
> >     New Revision: 1428918
> >
> >     URL: http://svn.apache.org/viewvc?rev=1428918&view=rev
> >     Log:
> >     Jira FOP-2174: When using SVG drawings, if no content-width and
> >     content-height is specified, 72 will be used instead of the
> >     source-resolution option
> >     Patch submitted by Robert Meyer (rmeyer at hotmail dot co dot uk)
> >
> >     Modified:
> >     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
> >         xmlgraphics/fop/trunk/status.xml
> >
> >     Modified:
> >     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
> >     URL:
> >     http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java?rev=1428918&r1=1428917&r2=1428918&view=diff
> >     ==============================================================================
> >     ---
> >     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
> >     (original)
> >     +++
> >     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
> >     Fri Jan  4 15:11:52 2013
> >     @@ -25,10 +25,14 @@ import java.awt.Rectangle;
> >      import org.apache.commons.logging.Log;
> >      import org.apache.commons.logging.LogFactory;
> >
> >     +import org.apache.xmlgraphics.util.UnitConv;
> >     +
> >      import org.apache.fop.datatypes.Length;
> >      import org.apache.fop.datatypes.PercentBaseContext;
> >      import org.apache.fop.fo.Constants;
> >      import org.apache.fop.fo.GraphicsProperties;
> >     +import org.apache.fop.fo.expr.PropertyException;
> >     +import org.apache.fop.fo.flow.AbstractGraphics;
> >      import org.apache.fop.fo.properties.LengthRangeProperty;
> >
> >      /**
> >     @@ -98,9 +102,9 @@ public class ImageLayout implements Cons
> >              boolean constrainIntrinsicSize = false;
> >              int cwidth = -1;
> >              int cheight = -1;
> >     -        len = props.getContentWidth();
> >     -        if (len.getEnum() != EN_AUTO) {
> >     -            switch (len.getEnum()) {
> >     +        Length lenWidth = props.getContentWidth();
> >     +        if (lenWidth.getEnum() != EN_AUTO) {
> >     +            switch (lenWidth.getEnum()) {
> >                  case EN_SCALE_TO_FIT:
> >                      if (ipd != -1) {
> >                          cwidth = ipd;
> >     @@ -120,12 +124,12 @@ public class ImageLayout implements Cons
> >                      constrainIntrinsicSize = true;
> >                      break;
> >                  default:
> >     -                cwidth = len.getValue(percentBaseContext);
> >     +                cwidth = lenWidth.getValue(percentBaseContext);
> >                  }
> >              }
> >     -        len = props.getContentHeight();
> >     -        if (len.getEnum() != EN_AUTO) {
> >     -            switch (len.getEnum()) {
> >     +        Length lenHeight = props.getContentHeight();
> >     +        if (lenHeight.getEnum() != EN_AUTO) {
> >     +            switch (lenHeight.getEnum()) {
> >                  case EN_SCALE_TO_FIT:
> >                      if (bpd != -1) {
> >                          cheight = bpd;
> >     @@ -145,10 +149,21 @@ public class ImageLayout implements Cons
> >                      constrainIntrinsicSize = true;
> >                      break;
> >                  default:
> >     -                cheight = len.getValue(percentBaseContext);
> >     +                cheight = lenHeight.getValue(percentBaseContext);
> >                  }
> >              }
> >
> >     +        //If no content-width or height is specified, adjust
> >     dimensions based upon the source resolution
> >     +        int sourceResolution = 72;
> >     +        if (props instanceof AbstractGraphics) {
> >     +            sourceResolution = (int)
> >     ((AbstractGraphics)props).getUserAgent().getSourceResolution();
> >     +        }
> >     +        boolean foundNonAuto = (lenWidth.getEnum() != EN_AUTO ||
> >     lenHeight.getEnum() != EN_AUTO);
> >     +        if (!foundNonAuto) {
> >     +            cwidth = intrinsicSize.width / (sourceResolution /
> >     UnitConv.IN2PT);
> >     +            cheight = intrinsicSize.height / (sourceResolution /
> >     UnitConv.IN2PT);
> >     +        }
> >     +
> >              Dimension constrainedIntrinsicSize;
> >              if (constrainIntrinsicSize) {
> >                  constrainedIntrinsicSize = constrain(intrinsicSize);
> >     @@ -164,11 +179,13 @@ public class ImageLayout implements Cons
> >              //Adjust viewport if not explicit
> >              if (ipd == -1) {
> >                  ipd = constrainExtent(cwidth,
> >     -                    props.getInlineProgressionDimension(),
> >     props.getContentWidth());
> >     +                    props.getInlineProgressionDimension(),
> >     (foundNonAuto)
> >     +                    ? props.getContentWidth() : new DefaultLength());
> >              }
> >              if (bpd == -1) {
> >                  bpd = constrainExtent(cheight,
> >     -                    props.getBlockProgressionDimension(),
> >     props.getContentHeight());
> >     +                    props.getBlockProgressionDimension(),
> >     (foundNonAuto)
> >     +                    ? props.getContentHeight() : new
> >     DefaultLength());
> >              }
> >
> >              this.clip = false;
> >     @@ -191,6 +208,36 @@ public class ImageLayout implements Cons
> >              this.placement = new Rectangle(xoffset, yoffset, cwidth,
> >     cheight);
> >          }
> >
> >     +    private static class DefaultLength implements Length {
> >     +        public double getNumericValue() throws PropertyException {
> >     +            return 0;
> >     +        }
> >     +
> >     +        public double getNumericValue(PercentBaseContext context)
> >     throws PropertyException {
> >     +            return 0;
> >     +        }
> >     +
> >     +        public int getDimension() {
> >     +            return 0;
> >     +        }
> >     +
> >     +        public boolean isAbsolute() {
> >     +            return false;
> >     +        }
> >     +
> >     +        public int getEnum() {
> >     +            return 0;
> >     +        }
> >     +
> >     +        public int getValue() {
> >     +            return 0;
> >     +        }
> >     +
> >     +        public int getValue(PercentBaseContext context) {
> >     +            return 0;
> >     +        }
> >     +    }
> >     +
> >          private int constrainExtent(int extent, LengthRangeProperty
> >     range, Length contextExtent) {
> >              boolean mayScaleUp = (contextExtent.getEnum() !=
> >     EN_SCALE_DOWN_TO_FIT);
> >              boolean mayScaleDown = (contextExtent.getEnum() !=
> >     EN_SCALE_UP_TO_FIT);
> >
> >     Modified: xmlgraphics/fop/trunk/status.xml
> >     URL:
> >     http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1428918&r1=1428917&r2=1428918&view=diff
> >     ==============================================================================
> >     --- xmlgraphics/fop/trunk/status.xml (original)
> >     +++ xmlgraphics/fop/trunk/status.xml Fri Jan  4 15:11:52 2013
> >     @@ -59,6 +59,10 @@
> >            documents. Example: the fix of marks layering will be such
> >     a case when it's done.
> >          -->
> >          <release version="FOP Trunk" date="TBD">
> >     +      <action context="Layout" dev="CB" type="fix"
> >     fixes-bug="FOP-2174" due-to="Robert Meyer">
> >     +        When using SVG drawings, if no content-width and
> >     content-height is specified, 72 will
> >     +        be used instead of the source-resolution option.
> >     +      </action>
> >            <action context="Code" dev="GA" type="fix"
> >     fixes-bug="FOP-2179" due-to="Robert Meyer">
> >              Fix checkstyle and findbugs warnings.
> >            </action>
> >
> >
> >
> >     ---------------------------------------------------------------------
> >     To unsubscribe, e-mail:
> >     fop-commits-unsubscribe@xmlgraphics.apache.org
> >     <ma...@xmlgraphics.apache.org>
> >     For additional commands, e-mail:
> >     fop-commits-help@xmlgraphics.apache.org
> >     <ma...@xmlgraphics.apache.org>
> >
> >
> 
 		 	   		   		 	   		  

RE: svn commit: r1428918 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java status.xml

Posted by Robert Meyer <rm...@hotmail.co.uk>.
Hi,

I'll look into creating an AT test and / or junit test next week for this. I'll update the existing jira issue if that's possible, but if not then I'll create a new one.

Regards,

Robert

> Date: Fri, 4 Jan 2013 16:43:12 +0000
> From: bowditch_chris@hotmail.com
> To: fop-dev@xmlgraphics.apache.org
> Subject: Re: svn commit: r1428918 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java status.xml
> 
> Hi Glenn,
> 
> Rob didn't submit one, but since the change affects layout that is a 
> reasonable request.
> 
> Thanks,
> 
> Chris
> 
> On 04/01/2013 16:25, Glenn Adams wrote:
> > are there any new tests to go along with this?
> >
> > On Fri, Jan 4, 2013 at 9:11 AM, <cbowditch@apache.org 
> > <ma...@apache.org>> wrote:
> >
> >     Author: cbowditch
> >     Date: Fri Jan  4 15:11:52 2013
> >     New Revision: 1428918
> >
> >     URL: http://svn.apache.org/viewvc?rev=1428918&view=rev
> >     Log:
> >     Jira FOP-2174: When using SVG drawings, if no content-width and
> >     content-height is specified, 72 will be used instead of the
> >     source-resolution option
> >     Patch submitted by Robert Meyer (rmeyer at hotmail dot co dot uk)
> >
> >     Modified:
> >     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
> >         xmlgraphics/fop/trunk/status.xml
> >
> >     Modified:
> >     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
> >     URL:
> >     http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java?rev=1428918&r1=1428917&r2=1428918&view=diff
> >     ==============================================================================
> >     ---
> >     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
> >     (original)
> >     +++
> >     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
> >     Fri Jan  4 15:11:52 2013
> >     @@ -25,10 +25,14 @@ import java.awt.Rectangle;
> >      import org.apache.commons.logging.Log;
> >      import org.apache.commons.logging.LogFactory;
> >
> >     +import org.apache.xmlgraphics.util.UnitConv;
> >     +
> >      import org.apache.fop.datatypes.Length;
> >      import org.apache.fop.datatypes.PercentBaseContext;
> >      import org.apache.fop.fo.Constants;
> >      import org.apache.fop.fo.GraphicsProperties;
> >     +import org.apache.fop.fo.expr.PropertyException;
> >     +import org.apache.fop.fo.flow.AbstractGraphics;
> >      import org.apache.fop.fo.properties.LengthRangeProperty;
> >
> >      /**
> >     @@ -98,9 +102,9 @@ public class ImageLayout implements Cons
> >              boolean constrainIntrinsicSize = false;
> >              int cwidth = -1;
> >              int cheight = -1;
> >     -        len = props.getContentWidth();
> >     -        if (len.getEnum() != EN_AUTO) {
> >     -            switch (len.getEnum()) {
> >     +        Length lenWidth = props.getContentWidth();
> >     +        if (lenWidth.getEnum() != EN_AUTO) {
> >     +            switch (lenWidth.getEnum()) {
> >                  case EN_SCALE_TO_FIT:
> >                      if (ipd != -1) {
> >                          cwidth = ipd;
> >     @@ -120,12 +124,12 @@ public class ImageLayout implements Cons
> >                      constrainIntrinsicSize = true;
> >                      break;
> >                  default:
> >     -                cwidth = len.getValue(percentBaseContext);
> >     +                cwidth = lenWidth.getValue(percentBaseContext);
> >                  }
> >              }
> >     -        len = props.getContentHeight();
> >     -        if (len.getEnum() != EN_AUTO) {
> >     -            switch (len.getEnum()) {
> >     +        Length lenHeight = props.getContentHeight();
> >     +        if (lenHeight.getEnum() != EN_AUTO) {
> >     +            switch (lenHeight.getEnum()) {
> >                  case EN_SCALE_TO_FIT:
> >                      if (bpd != -1) {
> >                          cheight = bpd;
> >     @@ -145,10 +149,21 @@ public class ImageLayout implements Cons
> >                      constrainIntrinsicSize = true;
> >                      break;
> >                  default:
> >     -                cheight = len.getValue(percentBaseContext);
> >     +                cheight = lenHeight.getValue(percentBaseContext);
> >                  }
> >              }
> >
> >     +        //If no content-width or height is specified, adjust
> >     dimensions based upon the source resolution
> >     +        int sourceResolution = 72;
> >     +        if (props instanceof AbstractGraphics) {
> >     +            sourceResolution = (int)
> >     ((AbstractGraphics)props).getUserAgent().getSourceResolution();
> >     +        }
> >     +        boolean foundNonAuto = (lenWidth.getEnum() != EN_AUTO ||
> >     lenHeight.getEnum() != EN_AUTO);
> >     +        if (!foundNonAuto) {
> >     +            cwidth = intrinsicSize.width / (sourceResolution /
> >     UnitConv.IN2PT);
> >     +            cheight = intrinsicSize.height / (sourceResolution /
> >     UnitConv.IN2PT);
> >     +        }
> >     +
> >              Dimension constrainedIntrinsicSize;
> >              if (constrainIntrinsicSize) {
> >                  constrainedIntrinsicSize = constrain(intrinsicSize);
> >     @@ -164,11 +179,13 @@ public class ImageLayout implements Cons
> >              //Adjust viewport if not explicit
> >              if (ipd == -1) {
> >                  ipd = constrainExtent(cwidth,
> >     -                    props.getInlineProgressionDimension(),
> >     props.getContentWidth());
> >     +                    props.getInlineProgressionDimension(),
> >     (foundNonAuto)
> >     +                    ? props.getContentWidth() : new DefaultLength());
> >              }
> >              if (bpd == -1) {
> >                  bpd = constrainExtent(cheight,
> >     -                    props.getBlockProgressionDimension(),
> >     props.getContentHeight());
> >     +                    props.getBlockProgressionDimension(),
> >     (foundNonAuto)
> >     +                    ? props.getContentHeight() : new
> >     DefaultLength());
> >              }
> >
> >              this.clip = false;
> >     @@ -191,6 +208,36 @@ public class ImageLayout implements Cons
> >              this.placement = new Rectangle(xoffset, yoffset, cwidth,
> >     cheight);
> >          }
> >
> >     +    private static class DefaultLength implements Length {
> >     +        public double getNumericValue() throws PropertyException {
> >     +            return 0;
> >     +        }
> >     +
> >     +        public double getNumericValue(PercentBaseContext context)
> >     throws PropertyException {
> >     +            return 0;
> >     +        }
> >     +
> >     +        public int getDimension() {
> >     +            return 0;
> >     +        }
> >     +
> >     +        public boolean isAbsolute() {
> >     +            return false;
> >     +        }
> >     +
> >     +        public int getEnum() {
> >     +            return 0;
> >     +        }
> >     +
> >     +        public int getValue() {
> >     +            return 0;
> >     +        }
> >     +
> >     +        public int getValue(PercentBaseContext context) {
> >     +            return 0;
> >     +        }
> >     +    }
> >     +
> >          private int constrainExtent(int extent, LengthRangeProperty
> >     range, Length contextExtent) {
> >              boolean mayScaleUp = (contextExtent.getEnum() !=
> >     EN_SCALE_DOWN_TO_FIT);
> >              boolean mayScaleDown = (contextExtent.getEnum() !=
> >     EN_SCALE_UP_TO_FIT);
> >
> >     Modified: xmlgraphics/fop/trunk/status.xml
> >     URL:
> >     http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1428918&r1=1428917&r2=1428918&view=diff
> >     ==============================================================================
> >     --- xmlgraphics/fop/trunk/status.xml (original)
> >     +++ xmlgraphics/fop/trunk/status.xml Fri Jan  4 15:11:52 2013
> >     @@ -59,6 +59,10 @@
> >            documents. Example: the fix of marks layering will be such
> >     a case when it's done.
> >          -->
> >          <release version="FOP Trunk" date="TBD">
> >     +      <action context="Layout" dev="CB" type="fix"
> >     fixes-bug="FOP-2174" due-to="Robert Meyer">
> >     +        When using SVG drawings, if no content-width and
> >     content-height is specified, 72 will
> >     +        be used instead of the source-resolution option.
> >     +      </action>
> >            <action context="Code" dev="GA" type="fix"
> >     fixes-bug="FOP-2179" due-to="Robert Meyer">
> >              Fix checkstyle and findbugs warnings.
> >            </action>
> >
> >
> >
> >     ---------------------------------------------------------------------
> >     To unsubscribe, e-mail:
> >     fop-commits-unsubscribe@xmlgraphics.apache.org
> >     <ma...@xmlgraphics.apache.org>
> >     For additional commands, e-mail:
> >     fop-commits-help@xmlgraphics.apache.org
> >     <ma...@xmlgraphics.apache.org>
> >
> >
> 
 		 	   		  

Re: svn commit: r1428918 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java status.xml

Posted by Chris Bowditch <bo...@hotmail.com>.
Hi Glenn,

Rob didn't submit one, but since the change affects layout that is a 
reasonable request.

Thanks,

Chris

On 04/01/2013 16:25, Glenn Adams wrote:
> are there any new tests to go along with this?
>
> On Fri, Jan 4, 2013 at 9:11 AM, <cbowditch@apache.org 
> <ma...@apache.org>> wrote:
>
>     Author: cbowditch
>     Date: Fri Jan  4 15:11:52 2013
>     New Revision: 1428918
>
>     URL: http://svn.apache.org/viewvc?rev=1428918&view=rev
>     Log:
>     Jira FOP-2174: When using SVG drawings, if no content-width and
>     content-height is specified, 72 will be used instead of the
>     source-resolution option
>     Patch submitted by Robert Meyer (rmeyer at hotmail dot co dot uk)
>
>     Modified:
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
>         xmlgraphics/fop/trunk/status.xml
>
>     Modified:
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
>     URL:
>     http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java?rev=1428918&r1=1428917&r2=1428918&view=diff
>     ==============================================================================
>     ---
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
>     (original)
>     +++
>     xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
>     Fri Jan  4 15:11:52 2013
>     @@ -25,10 +25,14 @@ import java.awt.Rectangle;
>      import org.apache.commons.logging.Log;
>      import org.apache.commons.logging.LogFactory;
>
>     +import org.apache.xmlgraphics.util.UnitConv;
>     +
>      import org.apache.fop.datatypes.Length;
>      import org.apache.fop.datatypes.PercentBaseContext;
>      import org.apache.fop.fo.Constants;
>      import org.apache.fop.fo.GraphicsProperties;
>     +import org.apache.fop.fo.expr.PropertyException;
>     +import org.apache.fop.fo.flow.AbstractGraphics;
>      import org.apache.fop.fo.properties.LengthRangeProperty;
>
>      /**
>     @@ -98,9 +102,9 @@ public class ImageLayout implements Cons
>              boolean constrainIntrinsicSize = false;
>              int cwidth = -1;
>              int cheight = -1;
>     -        len = props.getContentWidth();
>     -        if (len.getEnum() != EN_AUTO) {
>     -            switch (len.getEnum()) {
>     +        Length lenWidth = props.getContentWidth();
>     +        if (lenWidth.getEnum() != EN_AUTO) {
>     +            switch (lenWidth.getEnum()) {
>                  case EN_SCALE_TO_FIT:
>                      if (ipd != -1) {
>                          cwidth = ipd;
>     @@ -120,12 +124,12 @@ public class ImageLayout implements Cons
>                      constrainIntrinsicSize = true;
>                      break;
>                  default:
>     -                cwidth = len.getValue(percentBaseContext);
>     +                cwidth = lenWidth.getValue(percentBaseContext);
>                  }
>              }
>     -        len = props.getContentHeight();
>     -        if (len.getEnum() != EN_AUTO) {
>     -            switch (len.getEnum()) {
>     +        Length lenHeight = props.getContentHeight();
>     +        if (lenHeight.getEnum() != EN_AUTO) {
>     +            switch (lenHeight.getEnum()) {
>                  case EN_SCALE_TO_FIT:
>                      if (bpd != -1) {
>                          cheight = bpd;
>     @@ -145,10 +149,21 @@ public class ImageLayout implements Cons
>                      constrainIntrinsicSize = true;
>                      break;
>                  default:
>     -                cheight = len.getValue(percentBaseContext);
>     +                cheight = lenHeight.getValue(percentBaseContext);
>                  }
>              }
>
>     +        //If no content-width or height is specified, adjust
>     dimensions based upon the source resolution
>     +        int sourceResolution = 72;
>     +        if (props instanceof AbstractGraphics) {
>     +            sourceResolution = (int)
>     ((AbstractGraphics)props).getUserAgent().getSourceResolution();
>     +        }
>     +        boolean foundNonAuto = (lenWidth.getEnum() != EN_AUTO ||
>     lenHeight.getEnum() != EN_AUTO);
>     +        if (!foundNonAuto) {
>     +            cwidth = intrinsicSize.width / (sourceResolution /
>     UnitConv.IN2PT);
>     +            cheight = intrinsicSize.height / (sourceResolution /
>     UnitConv.IN2PT);
>     +        }
>     +
>              Dimension constrainedIntrinsicSize;
>              if (constrainIntrinsicSize) {
>                  constrainedIntrinsicSize = constrain(intrinsicSize);
>     @@ -164,11 +179,13 @@ public class ImageLayout implements Cons
>              //Adjust viewport if not explicit
>              if (ipd == -1) {
>                  ipd = constrainExtent(cwidth,
>     -                    props.getInlineProgressionDimension(),
>     props.getContentWidth());
>     +                    props.getInlineProgressionDimension(),
>     (foundNonAuto)
>     +                    ? props.getContentWidth() : new DefaultLength());
>              }
>              if (bpd == -1) {
>                  bpd = constrainExtent(cheight,
>     -                    props.getBlockProgressionDimension(),
>     props.getContentHeight());
>     +                    props.getBlockProgressionDimension(),
>     (foundNonAuto)
>     +                    ? props.getContentHeight() : new
>     DefaultLength());
>              }
>
>              this.clip = false;
>     @@ -191,6 +208,36 @@ public class ImageLayout implements Cons
>              this.placement = new Rectangle(xoffset, yoffset, cwidth,
>     cheight);
>          }
>
>     +    private static class DefaultLength implements Length {
>     +        public double getNumericValue() throws PropertyException {
>     +            return 0;
>     +        }
>     +
>     +        public double getNumericValue(PercentBaseContext context)
>     throws PropertyException {
>     +            return 0;
>     +        }
>     +
>     +        public int getDimension() {
>     +            return 0;
>     +        }
>     +
>     +        public boolean isAbsolute() {
>     +            return false;
>     +        }
>     +
>     +        public int getEnum() {
>     +            return 0;
>     +        }
>     +
>     +        public int getValue() {
>     +            return 0;
>     +        }
>     +
>     +        public int getValue(PercentBaseContext context) {
>     +            return 0;
>     +        }
>     +    }
>     +
>          private int constrainExtent(int extent, LengthRangeProperty
>     range, Length contextExtent) {
>              boolean mayScaleUp = (contextExtent.getEnum() !=
>     EN_SCALE_DOWN_TO_FIT);
>              boolean mayScaleDown = (contextExtent.getEnum() !=
>     EN_SCALE_UP_TO_FIT);
>
>     Modified: xmlgraphics/fop/trunk/status.xml
>     URL:
>     http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1428918&r1=1428917&r2=1428918&view=diff
>     ==============================================================================
>     --- xmlgraphics/fop/trunk/status.xml (original)
>     +++ xmlgraphics/fop/trunk/status.xml Fri Jan  4 15:11:52 2013
>     @@ -59,6 +59,10 @@
>            documents. Example: the fix of marks layering will be such
>     a case when it's done.
>          -->
>          <release version="FOP Trunk" date="TBD">
>     +      <action context="Layout" dev="CB" type="fix"
>     fixes-bug="FOP-2174" due-to="Robert Meyer">
>     +        When using SVG drawings, if no content-width and
>     content-height is specified, 72 will
>     +        be used instead of the source-resolution option.
>     +      </action>
>            <action context="Code" dev="GA" type="fix"
>     fixes-bug="FOP-2179" due-to="Robert Meyer">
>              Fix checkstyle and findbugs warnings.
>            </action>
>
>
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail:
>     fop-commits-unsubscribe@xmlgraphics.apache.org
>     <ma...@xmlgraphics.apache.org>
>     For additional commands, e-mail:
>     fop-commits-help@xmlgraphics.apache.org
>     <ma...@xmlgraphics.apache.org>
>
>


Re: svn commit: r1428918 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java status.xml

Posted by Glenn Adams <gl...@skynav.com>.
are there any new tests to go along with this?

On Fri, Jan 4, 2013 at 9:11 AM, <cb...@apache.org> wrote:

> Author: cbowditch
> Date: Fri Jan  4 15:11:52 2013
> New Revision: 1428918
>
> URL: http://svn.apache.org/viewvc?rev=1428918&view=rev
> Log:
> Jira FOP-2174: When using SVG drawings, if no content-width and
> content-height is specified, 72 will be used instead of the
> source-resolution option
> Patch submitted by Robert Meyer (rmeyer at hotmail dot co dot uk)
>
> Modified:
>
> xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
>     xmlgraphics/fop/trunk/status.xml
>
> Modified:
> xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java?rev=1428918&r1=1428917&r2=1428918&view=diff
>
> ==============================================================================
> ---
> xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
> (original)
> +++
> xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
> Fri Jan  4 15:11:52 2013
> @@ -25,10 +25,14 @@ import java.awt.Rectangle;
>  import org.apache.commons.logging.Log;
>  import org.apache.commons.logging.LogFactory;
>
> +import org.apache.xmlgraphics.util.UnitConv;
> +
>  import org.apache.fop.datatypes.Length;
>  import org.apache.fop.datatypes.PercentBaseContext;
>  import org.apache.fop.fo.Constants;
>  import org.apache.fop.fo.GraphicsProperties;
> +import org.apache.fop.fo.expr.PropertyException;
> +import org.apache.fop.fo.flow.AbstractGraphics;
>  import org.apache.fop.fo.properties.LengthRangeProperty;
>
>  /**
> @@ -98,9 +102,9 @@ public class ImageLayout implements Cons
>          boolean constrainIntrinsicSize = false;
>          int cwidth = -1;
>          int cheight = -1;
> -        len = props.getContentWidth();
> -        if (len.getEnum() != EN_AUTO) {
> -            switch (len.getEnum()) {
> +        Length lenWidth = props.getContentWidth();
> +        if (lenWidth.getEnum() != EN_AUTO) {
> +            switch (lenWidth.getEnum()) {
>              case EN_SCALE_TO_FIT:
>                  if (ipd != -1) {
>                      cwidth = ipd;
> @@ -120,12 +124,12 @@ public class ImageLayout implements Cons
>                  constrainIntrinsicSize = true;
>                  break;
>              default:
> -                cwidth = len.getValue(percentBaseContext);
> +                cwidth = lenWidth.getValue(percentBaseContext);
>              }
>          }
> -        len = props.getContentHeight();
> -        if (len.getEnum() != EN_AUTO) {
> -            switch (len.getEnum()) {
> +        Length lenHeight = props.getContentHeight();
> +        if (lenHeight.getEnum() != EN_AUTO) {
> +            switch (lenHeight.getEnum()) {
>              case EN_SCALE_TO_FIT:
>                  if (bpd != -1) {
>                      cheight = bpd;
> @@ -145,10 +149,21 @@ public class ImageLayout implements Cons
>                  constrainIntrinsicSize = true;
>                  break;
>              default:
> -                cheight = len.getValue(percentBaseContext);
> +                cheight = lenHeight.getValue(percentBaseContext);
>              }
>          }
>
> +        //If no content-width or height is specified, adjust dimensions
> based upon the source resolution
> +        int sourceResolution = 72;
> +        if (props instanceof AbstractGraphics) {
> +            sourceResolution = (int)
> ((AbstractGraphics)props).getUserAgent().getSourceResolution();
> +        }
> +        boolean foundNonAuto = (lenWidth.getEnum() != EN_AUTO ||
> lenHeight.getEnum() != EN_AUTO);
> +        if (!foundNonAuto) {
> +            cwidth = intrinsicSize.width / (sourceResolution /
> UnitConv.IN2PT);
> +            cheight = intrinsicSize.height / (sourceResolution /
> UnitConv.IN2PT);
> +        }
> +
>          Dimension constrainedIntrinsicSize;
>          if (constrainIntrinsicSize) {
>              constrainedIntrinsicSize = constrain(intrinsicSize);
> @@ -164,11 +179,13 @@ public class ImageLayout implements Cons
>          //Adjust viewport if not explicit
>          if (ipd == -1) {
>              ipd = constrainExtent(cwidth,
> -                    props.getInlineProgressionDimension(),
> props.getContentWidth());
> +                    props.getInlineProgressionDimension(), (foundNonAuto)
> +                    ? props.getContentWidth() : new DefaultLength());
>          }
>          if (bpd == -1) {
>              bpd = constrainExtent(cheight,
> -                    props.getBlockProgressionDimension(),
> props.getContentHeight());
> +                    props.getBlockProgressionDimension(), (foundNonAuto)
> +                    ? props.getContentHeight() : new DefaultLength());
>          }
>
>          this.clip = false;
> @@ -191,6 +208,36 @@ public class ImageLayout implements Cons
>          this.placement = new Rectangle(xoffset, yoffset, cwidth, cheight);
>      }
>
> +    private static class DefaultLength implements Length {
> +        public double getNumericValue() throws PropertyException {
> +            return 0;
> +        }
> +
> +        public double getNumericValue(PercentBaseContext context) throws
> PropertyException {
> +            return 0;
> +        }
> +
> +        public int getDimension() {
> +            return 0;
> +        }
> +
> +        public boolean isAbsolute() {
> +            return false;
> +        }
> +
> +        public int getEnum() {
> +            return 0;
> +        }
> +
> +        public int getValue() {
> +            return 0;
> +        }
> +
> +        public int getValue(PercentBaseContext context) {
> +            return 0;
> +        }
> +    }
> +
>      private int constrainExtent(int extent, LengthRangeProperty range,
> Length contextExtent) {
>          boolean mayScaleUp = (contextExtent.getEnum() !=
> EN_SCALE_DOWN_TO_FIT);
>          boolean mayScaleDown = (contextExtent.getEnum() !=
> EN_SCALE_UP_TO_FIT);
>
> Modified: xmlgraphics/fop/trunk/status.xml
> URL:
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1428918&r1=1428917&r2=1428918&view=diff
>
> ==============================================================================
> --- xmlgraphics/fop/trunk/status.xml (original)
> +++ xmlgraphics/fop/trunk/status.xml Fri Jan  4 15:11:52 2013
> @@ -59,6 +59,10 @@
>        documents. Example: the fix of marks layering will be such a case
> when it's done.
>      -->
>      <release version="FOP Trunk" date="TBD">
> +      <action context="Layout" dev="CB" type="fix" fixes-bug="FOP-2174"
> due-to="Robert Meyer">
> +        When using SVG drawings, if no content-width and content-height
> is specified, 72 will
> +        be used instead of the source-resolution option.
> +      </action>
>        <action context="Code" dev="GA" type="fix" fixes-bug="FOP-2179"
> due-to="Robert Meyer">
>          Fix checkstyle and findbugs warnings.
>        </action>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org
>
>