1 51 package org.apache.fop.fo.expr; 52 53 import org.apache.fop.datatypes.*; 54 import org.apache.fop.fo.Property; 55 import org.apache.fop.fo.LengthProperty; 56 import org.apache.fop.fo.FObj; 57 import org.apache.fop.fo.flow.ListItem; 58 59 public class LabelEndFunction extends FunctionBase { 60 61 public int nbArgs() { 62 return 0; 63 } 64 65 public Property eval(Property[] args, 66 PropertyInfo pInfo) throws PropertyException { 67 68 Length distance = 69 pInfo.getPropertyList().get("provisional-distance-between-starts").getLength(); 70 Length separation = 71 pInfo.getPropertyList().getNearestSpecified("provisional-label-separation").getLength(); 72 73 FObj item = pInfo.getFO(); 74 while (item != null &&!(item instanceof ListItem)) { 75 item = item.getParent(); 76 } 77 if (item == null) { 78 throw new PropertyException("label-end() called from outside an fo:list-item"); 79 } 80 Length startIndent = item.properties.get("start-indent").getLength(); 81 82 LinearCombinationLength labelEnd = new LinearCombinationLength(); 83 84 LengthBase base = new LengthBase(item, pInfo.getPropertyList(), 86 LengthBase.CONTAINING_BOX); 87 PercentLength refWidth = new PercentLength(1.0, base); 88 89 labelEnd.addTerm(1.0, refWidth); 90 labelEnd.addTerm(-1.0, distance); 91 labelEnd.addTerm(-1.0, startIndent); 92 labelEnd.addTerm(1.0, separation); 93 94 return new LengthProperty(labelEnd); 95 } 96 97 } 98 | Popular Tags |