aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop
diff options
context:
space:
mode:
authorLuis Bernardo <lbernardo@apache.org>2013-04-30 23:25:18 +0000
committerLuis Bernardo <lbernardo@apache.org>2013-04-30 23:25:18 +0000
commit4726c4f941c2179152a3c27e0dc7f62147e825f3 (patch)
tree4e0411f3e37be3c26fd5e1b04c847aa2ace6ca5e /src/java/org/apache/fop
parentca4802ab78be99b8a2cb4fc617a788c49938f5da (diff)
downloadxmlgraphics-fop-4726c4f941c2179152a3c27e0dc7f62147e825f3.tar.gz
xmlgraphics-fop-4726c4f941c2179152a3c27e0dc7f62147e825f3.zip
FOP-2245: height attribute on external-graphic with percentage value behaves incorrectly
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1477872 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
-rw-r--r--src/java/org/apache/fop/datatypes/Numeric.java6
-rw-r--r--src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java30
-rw-r--r--src/java/org/apache/fop/fo/properties/EnumNumber.java3
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java18
4 files changed, 30 insertions, 27 deletions
diff --git a/src/java/org/apache/fop/datatypes/Numeric.java b/src/java/org/apache/fop/datatypes/Numeric.java
index 2004c6721..8ed5a0e5c 100644
--- a/src/java/org/apache/fop/datatypes/Numeric.java
+++ b/src/java/org/apache/fop/datatypes/Numeric.java
@@ -19,8 +19,6 @@
package org.apache.fop.datatypes;
-import org.apache.fop.fo.expr.PropertyException;
-
/**
* An interface for classes that can participate in numeric operations.
* All the numeric operation (+, -, *, ...) are expressed in terms of
@@ -39,7 +37,7 @@ public interface Numeric {
* @return the computed value.
* @throws PropertyException if a property exception occurs
*/
- double getNumericValue() throws PropertyException;
+ double getNumericValue();
/**
* Return the value of this Numeric
@@ -47,7 +45,7 @@ public interface Numeric {
* @return the computed value.
* @throws PropertyException if a property exception occurs
*/
- double getNumericValue(PercentBaseContext context) throws PropertyException;
+ double getNumericValue(PercentBaseContext context);
/**
* Return the dimension of this numeric. Plain numbers has a dimension of
diff --git a/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java b/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java
index e99c8c7be..3d6b7df5b 100644
--- a/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java
+++ b/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java
@@ -142,15 +142,23 @@ public class RelativeNumericProperty extends Property implements Length {
* Return the resolved (calculated) value of the expression.
* {@inheritDoc}
*/
- public double getNumericValue() throws PropertyException {
- return getResolved(null).getNumericValue(null);
+ public double getNumericValue() {
+ try {
+ return getResolved(null).getNumericValue(null);
+ } catch (PropertyException pe) {
+ throw new RuntimeException(pe);
+ }
}
/**
* {@inheritDoc}
*/
- public double getNumericValue(PercentBaseContext context) throws PropertyException {
- return getResolved(context).getNumericValue(context);
+ public double getNumericValue(PercentBaseContext context) {
+ try {
+ return getResolved(context).getNumericValue(context);
+ } catch (PropertyException pe) {
+ throw new RuntimeException(pe);
+ }
}
/**
@@ -193,24 +201,14 @@ public class RelativeNumericProperty extends Property implements Length {
* {@inheritDoc}
*/
public int getValue() {
- try {
- return (int) getNumericValue();
- } catch (PropertyException exc) {
- log.error(exc);
- }
- return 0;
+ return (int) getNumericValue();
}
/**
* {@inheritDoc}
*/
public int getValue(PercentBaseContext context) {
- try {
- return (int) getNumericValue(context);
- } catch (PropertyException exc) {
- log.error(exc);
- }
- return 0;
+ return (int) getNumericValue(context);
}
/**
diff --git a/src/java/org/apache/fop/fo/properties/EnumNumber.java b/src/java/org/apache/fop/fo/properties/EnumNumber.java
index 9c018e0eb..dfe1eb877 100644
--- a/src/java/org/apache/fop/fo/properties/EnumNumber.java
+++ b/src/java/org/apache/fop/fo/properties/EnumNumber.java
@@ -21,7 +21,6 @@ package org.apache.fop.fo.properties;
import org.apache.fop.datatypes.Numeric;
import org.apache.fop.datatypes.PercentBaseContext;
-import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.util.CompareUtil;
/**
@@ -104,7 +103,7 @@ public final class EnumNumber extends Property implements Numeric {
* {@inheritDoc}
* logs an error, because it's not supposed to be called
*/
- public double getNumericValue(PercentBaseContext context) throws PropertyException {
+ public double getNumericValue(PercentBaseContext context) {
log.error("getNumericValue() called on " + enumProperty + " number");
return 0;
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java b/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
index 31ede9aee..183b83e70 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
@@ -75,12 +75,11 @@ public class ImageLayout implements Constants {
len = props.getBlockProgressionDimension().getOptimum(percentBaseContext).getLength();
if (len.getEnum() != EN_AUTO) {
- bpd = len.getValue(percentBaseContext);
+ bpd = evaluateLength(len, intrinsicSize.height);
}
len = props.getBlockProgressionDimension().getMinimum(percentBaseContext).getLength();
if (bpd == -1 && len.getEnum() != EN_AUTO) {
- //Establish minimum viewport size
- bpd = len.getValue(percentBaseContext);
+ bpd = evaluateLength(len, intrinsicSize.height);
}
len = props.getInlineProgressionDimension().getOptimum(percentBaseContext).getLength();
@@ -197,14 +196,14 @@ public class ImageLayout implements Constants {
Length len;
len = range.getMaximum(percentBaseContext).getLength();
if (len.getEnum() != EN_AUTO) {
- int max = len.getValue(percentBaseContext);
+ int max = evaluateLength(len);
if (max != -1 && mayScaleDown) {
extent = Math.min(extent, max);
}
}
len = range.getMinimum(percentBaseContext).getLength();
if (len.getEnum() != EN_AUTO) {
- int min = len.getValue(percentBaseContext);
+ int min = evaluateLength(len);
if (min != -1 && mayScaleUp) {
extent = Math.max(extent, min);
}
@@ -364,4 +363,13 @@ public class ImageLayout implements Constants {
return this.clip;
}
+ private int evaluateLength(Length length, int referenceValue) {
+ double numericValue = length.getNumericValue(percentBaseContext);
+ int bpd = numericValue < 0 ? referenceValue : (int) Math.round(numericValue);
+ return bpd;
+ }
+
+ private int evaluateLength(Length length) {
+ return evaluateLength(length, -1);
+ }
}