diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-11-29 10:33:01 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-11-29 10:33:01 +0000 |
commit | c1e5695d67b7496ec611c52b345d4022415ae1d4 (patch) | |
tree | a3d5bafdb9b97a69e0045af5ff0194b3733d5fe3 /src | |
parent | 39e0e48745f7f7368e02d56f2636da9217a3c31f (diff) | |
download | xmlgraphics-fop-c1e5695d67b7496ec611c52b345d4022415ae1d4.tar.gz xmlgraphics-fop-c1e5695d67b7496ec611c52b345d4022415ae1d4.zip |
Bugfix for "/ by zero" ArithmeticExceptions when an URL to a non-existing image is used and content-width and/or content-height is used.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@349698 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java index 204c69e8f..01fd854d6 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java @@ -22,7 +22,6 @@ import java.awt.geom.Rectangle2D; import java.util.LinkedList; import org.apache.fop.area.Area; -import org.apache.fop.area.inline.InlineArea; import org.apache.fop.area.inline.Viewport; import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.LengthBase; @@ -71,7 +70,6 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage int bpd = -1; int ipd = -1; - boolean bpdauto = false; if (hasLH) { bpd = fobj.getLineHeight().getOptimum(this).getLength().getValue(this); } else { @@ -130,20 +128,33 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage cwidth = fobj.getIntrinsicWidth(); cheight = fobj.getIntrinsicHeight(); } else if (cwidth == -1) { - cwidth = (int)(fobj.getIntrinsicWidth() * (double)cheight - / fobj.getIntrinsicHeight()); + if (fobj.getIntrinsicHeight() == 0) { + cwidth = 0; + } else { + cwidth = (int)(fobj.getIntrinsicWidth() * (double)cheight + / fobj.getIntrinsicHeight()); + } } else if (cheight == -1) { - cheight = (int)(fobj.getIntrinsicHeight() * (double)cwidth - / fobj.getIntrinsicWidth()); + if (fobj.getIntrinsicWidth() == 0) { + cheight = 0; + } else { + cheight = (int)(fobj.getIntrinsicHeight() * (double)cwidth + / fobj.getIntrinsicWidth()); + } } else { // adjust the larger - double rat1 = cwidth / fobj.getIntrinsicWidth(); - double rat2 = cheight / fobj.getIntrinsicHeight(); - if (rat1 < rat2) { - // reduce cheight - cheight = (int)(rat1 * fobj.getIntrinsicHeight()); - } else if (rat1 > rat2) { - cwidth = (int)(rat2 * fobj.getIntrinsicWidth()); + if (fobj.getIntrinsicWidth() == 0 || fobj.getIntrinsicHeight() == 0) { + cwidth = 0; + cheight = 0; + } else { + double rat1 = cwidth / fobj.getIntrinsicWidth(); + double rat2 = cheight / fobj.getIntrinsicHeight(); + if (rat1 < rat2) { + // reduce cheight + cheight = (int)(rat1 * fobj.getIntrinsicHeight()); + } else if (rat1 > rat2) { + cwidth = (int)(rat2 * fobj.getIntrinsicWidth()); + } } } } |