From 61173ad5a278a128d7917276ad0f17ebcca60667 Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Thu, 24 Aug 2006 20:08:26 +0000 Subject: Fix: suppressed call to PercentLength.getBaseLength() without context (introduced in r433385) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@434497 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/fo/properties/LengthRangeProperty.java | 14 +++++++++----- src/java/org/apache/fop/fo/properties/PercentLength.java | 13 +++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src/java') diff --git a/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java b/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java index 886cd01ea..09e64a714 100644 --- a/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java +++ b/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java @@ -73,10 +73,14 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { if (this.propId == PR_BLOCK_PROGRESSION_DIMENSION || this.propId == PR_INLINE_PROGRESSION_DIMENSION) { Length len = p.getLength(); - if (len != null && len.getValue() < 0) { - log.warn("Replaced negative value for " + getName() - + " with 0mpt"); - p = new FixedLength(0); + if (len != null) { + if ((len instanceof FixedLength && len.getValue() < 0) + || (len instanceof PercentLength + && ((PercentLength) len).getPercentage() < 0)) { + log.warn("Replaced negative value for " + getName() + + " with 0mpt"); + p = new FixedLength(0); + } } } @@ -283,7 +287,7 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { /** * @return this.lengthRange cast as an Object */ - public Object getObject() { + protected Object getObject() { return this; } diff --git a/src/java/org/apache/fop/fo/properties/PercentLength.java b/src/java/org/apache/fop/fo/properties/PercentLength.java index e43ac529c..a1865d7cd 100644 --- a/src/java/org/apache/fop/fo/properties/PercentLength.java +++ b/src/java/org/apache/fop/fo/properties/PercentLength.java @@ -63,12 +63,13 @@ public class PercentLength extends LengthProperty { } /** - * - * @return the factor - * TODO: Should this really exists? + * Used during property resolution to check for + * negative percentages + * + * @return the percentage value */ - public double value() { - return factor; + protected double getPercentage() { + return factor * 100; } /** @@ -113,7 +114,7 @@ public class PercentLength extends LengthProperty { public int getValue(PercentBaseContext context) { return (int) getNumericValue(context); } - + /** * @return the String equivalent of this */ -- cgit v1.2.3