1 51 package org.apache.fop.datatypes; 52 53 import org.apache.fop.fo.FObj; 54 import org.apache.fop.fo.PropertyList; 55 import org.apache.fop.messaging.MessageHandler; 56 57 public class LengthBase implements PercentBase { 58 public static final int CUSTOM_BASE = 0; 60 public static final int FONTSIZE = 1; 61 public static final int INH_FONTSIZE = 2; 62 public static final int CONTAINING_BOX = 3; 63 public static final int CONTAINING_REFAREA = 4; 64 65 68 protected FObj parentFO; 69 70 73 private PropertyList propertyList; 74 75 78 private int iBaseType; 79 80 public LengthBase(FObj parentFO, PropertyList plist, int iBaseType) { 81 this.parentFO = parentFO; 82 this.propertyList = plist; 83 this.iBaseType = iBaseType; 84 } 85 86 90 protected FObj getParentFO() { 91 return parentFO; 92 } 93 94 98 protected PropertyList getPropertyList() { 99 return propertyList; 100 } 101 102 public int getDimension() { 103 return 1; 104 } 105 106 public double getBaseValue() { 107 return 1.0; 108 } 109 110 public int getBaseLength() { 111 switch (iBaseType) { 112 case FONTSIZE: 113 return propertyList.get("font-size").getLength().mvalue(); 114 case INH_FONTSIZE: 115 return propertyList.getInherited("font-size").getLength().mvalue(); 116 case CONTAINING_BOX: 117 return parentFO.getContentWidth(); 119 case CONTAINING_REFAREA: { 121 FObj fo; 122 for (fo = parentFO; fo != null &&!fo.generatesReferenceAreas(); 123 fo = fo.getParent()); 124 return (fo != null ? fo.getContentWidth() : 0); 125 } 126 case CUSTOM_BASE: 127 MessageHandler.errorln("!!! LengthBase.getBaseLength() called on CUSTOM_BASE type !!!"); 128 return 0; 129 default: 130 MessageHandler.errorln("Unknown base type for LengthBase."); 131 return 0; 132 } 133 } 134 135 } 136 137 | Popular Tags |