1 51 package org.apache.fop.fo.flow; 52 53 import org.apache.fop.fo.*; 55 import org.apache.fop.layout.*; 56 import org.apache.fop.layout.BlockArea; 57 import org.apache.fop.apps.FOPException; 58 59 public class ListItem extends FObj { 60 61 public static class Maker extends FObj.Maker { 62 public FObj make(FObj parent, PropertyList propertyList, 63 String systemId, int line, int column) 64 throws FOPException { 65 return new ListItem(parent, propertyList, systemId, line, column); 66 } 67 68 } 69 70 public static FObj.Maker maker() { 71 return new ListItem.Maker(); 72 } 73 74 int align; 75 int alignLast; 76 int breakBefore; 77 int breakAfter; 78 int lineHeight; 79 int startIndent; 80 int endIndent; 81 int spaceBefore; 82 int spaceAfter; 83 String id; 84 BlockArea blockArea; 85 86 public ListItem(FObj parent, PropertyList propertyList, 87 String systemId, int line, int column) { 88 super(parent, propertyList, systemId, line, column); 89 } 90 91 public String getName() { 92 return "fo:list-item"; 93 } 94 95 public int layout(Area area) throws FOPException { 96 if (this.marker == START) { 97 98 AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); 100 101 AuralProps mAurProps = propMgr.getAuralProps(); 103 104 BorderAndPadding bap = propMgr.getBorderAndPadding(); 106 BackgroundProps bProps = propMgr.getBackgroundProps(); 107 108 MarginProps mProps = propMgr.getMarginProps(); 110 111 RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); 113 114 122 this.align = this.properties.get("text-align").getEnum(); 123 this.alignLast = this.properties.get("text-align-last").getEnum(); 124 this.lineHeight = 125 this.properties.get("line-height").getLength().mvalue(); 126 this.spaceBefore = 127 this.properties.get("space-before.optimum").getLength().mvalue(); 128 this.spaceAfter = 129 this.properties.get("space-after.optimum").getLength().mvalue(); 130 this.id = this.properties.get("id").getString(); 131 132 try { 133 area.getIDReferences().createID(id); 134 } 135 catch(FOPException e) { 136 if (!e.isLocationSet()) { 137 e.setLocation(systemId, line, column); 138 } 139 throw e; 140 } 141 142 this.marker = 0; 143 } 144 145 146 if (area instanceof BlockArea) { 147 area.end(); 148 } 149 150 if (spaceBefore != 0) { 151 area.addDisplaySpace(spaceBefore); 152 } 153 154 this.blockArea = 155 new BlockArea(propMgr.getFontState(area.getFontInfo()), 156 area.getAllocationWidth(), area.spaceLeft(), 0, 0, 157 0, align, alignLast, lineHeight); 158 159 blockArea.setTableCellXOffset(area.getTableCellXOffset()); 161 162 this.blockArea.setGeneratedBy(this); 163 this.areasGenerated++; 164 if (this.areasGenerated == 1) 165 this.blockArea.isFirst(true); 166 169 173 blockArea.setParent(area); 174 blockArea.setPage(area.getPage()); 175 blockArea.start(); 176 177 blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); 178 blockArea.setIDReferences(area.getIDReferences()); 179 180 int numChildren = this.children.size(); 181 if (numChildren != 2) { 182 throw new FOPException("list-item must have exactly two children", 183 systemId, line, column); 184 } 185 ListItemLabel label = (ListItemLabel)children.get(0); 186 ListItemBody body = (ListItemBody)children.get(1); 187 188 int status; 189 190 193 if (this.marker == 0) { 194 area.getIDReferences().configureID(id, area); 196 197 status = label.layout(blockArea); 198 if (Status.isIncomplete(status)) { 199 return status; 200 } 201 } 202 203 status = body.layout(blockArea); 204 if (Status.isIncomplete(status)) { 205 blockArea.end(); 206 area.addChild(blockArea); 207 area.increaseHeight(blockArea.getHeight()); 208 this.marker = 1; 209 return status; 210 } 211 212 blockArea.end(); 213 area.addChild(blockArea); 214 area.increaseHeight(blockArea.getHeight()); 215 216 if (spaceAfter != 0) { 217 area.addDisplaySpace(spaceAfter); 218 } 219 220 221 if (area instanceof BlockArea) { 222 area.start(); 223 } 224 this.blockArea.isLast(true); 225 return Status.OK; 226 } 227 228 231 public int getContentWidth() { 232 if (blockArea != null) 233 return blockArea.getContentWidth(); else 235 return 0; } 237 238 } 239 | Popular Tags |