From: Andreas L. Delmelle Date: Mon, 21 Aug 2006 21:59:30 +0000 (+0000) Subject: Minor fix: set negative values to zero for b-p-d/i-p-d X-Git-Tag: fop-0_93~122 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c29f3f30a167f2e1919cd945e7dcf30574326f9a;p=xmlgraphics-fop.git Minor fix: set negative values to zero for b-p-d/i-p-d git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@433385 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java b/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java index 69217a56f..84fee1490 100644 --- a/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java +++ b/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java @@ -20,6 +20,7 @@ package org.apache.fop.fo.properties; import org.apache.fop.datatypes.CompoundDatatype; +import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; @@ -61,14 +62,49 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { /** * @see CompoundPropertyMaker#convertProperty */ - public Property convertProperty(Property p, PropertyList propertyList, FObj fo) - throws PropertyException - { + public Property convertProperty(Property p, + PropertyList propertyList, FObj fo) + throws PropertyException { + if (p instanceof LengthRangeProperty) { return p; } + + 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); + } + } + return super.convertProperty(p, propertyList, fo); } + + + /** + * @see org.apache.fop.fo.properties.PropertyMaker#getSubprop() + */ + protected Property setSubprop(Property baseProperty, int subpropertyId, + Property subproperty) { + CompoundDatatype val = (CompoundDatatype) baseProperty.getObject(); + if (this.propId == PR_BLOCK_PROGRESSION_DIMENSION + || this.propId == PR_INLINE_PROGRESSION_DIMENSION) { + Length len = subproperty.getLength(); + if (len != null && len.getValue() < 0) { + log.warn("Replaced negative value for " + getName() + + " with 0mpt"); + val.setComponent(subpropertyId, + new FixedLength(0), false); + return baseProperty; + } + } + val.setComponent(subpropertyId, subproperty, false); + return baseProperty; + } + } @@ -186,8 +222,9 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { // opt is default and max is explicit or default optimum = maximum; } - } else if (!optimum.isAuto() && !minimum.isAuto() && - optimum.getLength().getValue(context) < minimum.getLength().getValue(context)) { + } else if (!optimum.isAuto() && !minimum.isAuto() + && optimum.getLength().getValue(context) + < minimum.getLength().getValue(context)) { if ((bfSet & MINSET) != 0) { // if minimum is explicit, force opt to min if ((bfSet & OPTSET) != 0) { @@ -246,7 +283,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/status.xml b/status.xml index d013359e6..1f84b1963 100644 --- a/status.xml +++ b/status.xml @@ -28,6 +28,9 @@ + + Minor fix: correctly set negative values to zero. + Rework of default column-creation / column-width setting from cells in the first row. diff --git a/test/fotree/disabled-testcases.xml b/test/fotree/disabled-testcases.xml index bcf065667..0b623b450 100755 --- a/test/fotree/disabled-testcases.xml +++ b/test/fotree/disabled-testcases.xml @@ -22,20 +22,10 @@ demo-test-failure.fo - - Negative values on block-progression-dimension - block-progression-dimension_negative.fo - The code currently doesn't set negative values to 0mpt as mandated by the spec. - - - Negative values on inline-progression-dimension - inline-progression-dimension_negative.fo - The code currently doesn't set negative values to 0mpt as mandated by the spec. - Markers and core function evaluation from-table-column_marker.fo The code currently evaluates this function according to the column in which the - marker appearsin the source document, rather than the column it is retrieved in. + marker appears in the source document, rather than the column it is retrieved in.