return baseLen;
}
+ /** {@inheritDoc} */
+ public String toString() {
+ return super.toString()
+ + "[fo=" + fobj + ","
+ + "baseType=" + baseType + ","
+ + "baseLength=" + baseLength + "]";
+ }
+
+ /**@return the base length as a {@link Length} */
+ public Length getBaseLength() {
+ return baseLength;
+ }
}
package org.apache.fop.fo.expr;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.LengthBase;
import org.apache.fop.datatypes.Numeric;
import org.apache.fop.datatypes.PercentBase;
import org.apache.fop.fo.properties.ColorProperty;
private static final String RELUNIT = "em";
private static final HashMap FUNCTION_TABLE = new HashMap();
-
+
static {
// Initialize the HashMap of XSL-defined functions
FUNCTION_TABLE.put("ceiling", new CeilingFunction());
if (pcBase.getDimension() == 0) {
prop = NumberProperty.getInstance(pcval * pcBase.getBaseValue());
} else if (pcBase.getDimension() == 1) {
+ if (pcBase instanceof LengthBase) {
+ //If the base of the percentage is known
+ //and absolute, it can be resolved by the
+ //parser
+ Length base = ((LengthBase)pcBase).getBaseLength();
+ if (base != null && base.isAbsolute()) {
+ prop = FixedLength.getInstance(pcval * base.getValue());
+ break;
+ }
+ }
prop = new PercentLength(pcval, pcBase);
} else {
throw new PropertyException("Illegal percent dimension value");
package org.apache.fop.fo.properties;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.LengthBase;
import org.apache.fop.datatypes.Numeric;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FObj;
FObj fo) throws PropertyException {
Numeric numval = p.getNumeric();
if (numval != null && numval.getDimension() == 0) {
- p = new PercentLength(numval.getNumericValue(), getPercentBase(propertyList));
+ if (getPercentBase(propertyList) instanceof LengthBase) {
+ Length base = ((LengthBase)getPercentBase(propertyList)).getBaseLength();
+ if (base != null && base.isAbsolute()) {
+ p = FixedLength.getInstance(
+ numval.getNumericValue() * base.getNumericValue());
+ } else {
+ p = new PercentLength(
+ numval.getNumericValue(), getPercentBase(propertyList));
+ }
+ }
Property spaceProp = super.convertProperty(p, propertyList, fo);
spaceProp.setSpecifiedValue(String.valueOf(numval.getNumericValue()));
return spaceProp;
<test:assert property="font-size" expected="10000mpt"/>
<test:assert property="font-weight" expected="700" />
<test:assert property="font-style" expected="NORMAL" />
- <test:assert property="line-height.optimum" expected="120.0%" />
+ <test:assert property="line-height.optimum" expected="12000mpt" />
<test:assert property="font-variant" expected="NORMAL" />
</fo:block>
<fo:block font="italic small-caps 14pt 'Times New Roman', serif">
<test:assert property="font-size" expected="14000mpt"/>
<test:assert property="font-weight" expected="400" />
<test:assert property="font-style" expected="ITALIC" />
- <test:assert property="line-height.optimum" expected="120.0%" />
+ <test:assert property="line-height.optimum" expected="16800mpt" />
<test:assert property="font-variant" expected="SMALL_CAPS" />
Test font shorthand
</fo:block>
<test:assert property="font-size" expected="14000mpt"/>
<test:assert property="font-weight" expected="700" />
<test:assert property="font-style" expected="ITALIC" />
- <test:assert property="line-height.optimum" expected="80.0%" />
+ <test:assert property="line-height.optimum" expected="11200mpt" />
<test:assert property="font-variant" expected="NORMAL" />
Test font shorthand
</fo:block>
<test:assert property="font-size" expected="20736mpt"/>
<test:assert property="font-weight" expected="400" />
<test:assert property="font-style" expected="NORMAL" />
- <test:assert property="line-height.optimum" expected="140.0%" />
+ <test:assert property="line-height.optimum" expected="29030mpt" />
<test:assert property="font-variant" expected="NORMAL" />
Test font shorthand
</fo:block>
<test:assert property="font-size" expected="14000mpt"/>
<test:assert property="font-weight" expected="700" />
<test:assert property="font-style" expected="ITALIC" />
- <test:assert property="line-height.optimum" expected="80.0%" />
+ <test:assert property="line-height.optimum" expected="11200mpt" />
<test:assert property="font-variant" expected="NORMAL" />
Test font shorthand inheritance
</fo:block>