1 51 package org.apache.fop.fo; 52 53 import org.apache.fop.layout.Area; 55 import org.apache.fop.apps.FOPException; 56 import org.apache.fop.datatypes.IDReferences; 57 58 import java.util.HashSet ; 60 61 64 public abstract class FObj extends FONode { 65 66 public abstract static class Maker { 67 public abstract FObj make(FObj parent, PropertyList propertyList, 68 String systemId, int line, int column) 69 throws FOPException; 70 } 71 72 public PropertyList properties; 74 protected PropertyManager propMgr; 75 protected String systemId; 76 protected int line; 77 protected int column; 78 79 private HashSet markerClassNames; 81 82 protected FObj(FObj parent, PropertyList propertyList, 83 String systemId, int line, int column) { 84 super(parent); 85 this.properties = propertyList; propertyList.setFObj(this); 87 this.propMgr = makePropertyManager(propertyList); 88 this.systemId = systemId; 89 this.line = line; 90 this.column = column; 91 setWritingMode(); 92 } 93 94 protected PropertyManager makePropertyManager(PropertyList propertyList) { 95 return new PropertyManager(propertyList); 96 } 97 98 104 protected void addCharacters(char data[], int start, int length) { 105 } 107 108 115 public int layout(Area area) throws FOPException { 116 return Status.OK; 118 } 119 120 124 public abstract String getName(); 125 126 129 133 136 protected void end() { 137 } 139 140 146 public Property getProperty(String name) { 147 return (properties.get(name)); 148 } 149 150 151 161 public int getContentWidth() { 162 return 0; 163 } 164 165 169 public void removeID(IDReferences idReferences) { 170 if (((FObj)this).properties.get("id") == null 171 || ((FObj)this).properties.get("id").getString() == null) 172 return; 173 idReferences.removeID(((FObj)this).properties.get("id").getString()); 174 int numChildren = this.children.size(); 175 for (int i = 0; i < numChildren; i++) { 176 FONode child = (FONode)children.get(i); 177 if ((child instanceof FObj)) { 178 ((FObj)child).removeID(idReferences); 179 } 180 } 181 } 182 183 public boolean generatesReferenceAreas() { 184 return false; 185 } 186 187 193 protected void setWritingMode() { 194 FObj p; 195 FObj parent; 196 for (p = this; 197 !p.generatesReferenceAreas() && (parent = p.getParent()) != null; 198 p = parent); 199 this.properties.setWritingMode(p.getProperty("writing-mode").getEnum()); 200 } 201 202 203 public void addMarker(String markerClassName) throws FOPException { 204 if (children != null) { 206 for (int i = 0; i < children.size(); i++) { 207 FONode child = (FONode)children.get(i); 208 if (!child.mayPrecedeMarker()) { 209 throw new FOPException("A fo:marker must be an initial child of '" 210 + getName()+"'", systemId, line, column); 211 } 212 } 213 } 214 if (markerClassNames==null) { 215 markerClassNames = new HashSet (); 216 markerClassNames.add(markerClassName); 217 } else if (!markerClassNames.contains(markerClassName) ) { 218 markerClassNames.add(markerClassName); 219 } else { 220 throw new FOPException("marker-class-name '" 221 + markerClassName 222 + "' already exists for this parent", 223 systemId, line, column); 224 } 225 } 226 227 231 } 240 241 | Popular Tags |