1 51 package org.apache.fop.fo.flow; 52 53 import org.apache.fop.fo.*; 55 import org.apache.fop.fo.properties.*; 56 import org.apache.fop.fo.pagination.PageSequence; 57 import org.apache.fop.layout.*; 58 import org.apache.fop.apps.FOPException; 59 60 public class BlockContainer extends FObj { 61 62 int position; 63 64 int top; 65 int bottom; 66 int left; 67 int right; 68 int width; 69 int height; 70 71 int span; 72 73 AreaContainer areaContainer; 74 75 public static class Maker extends FObj.Maker { 76 public FObj make(FObj parent, PropertyList propertyList, 77 String systemId, int line, int column) 78 throws FOPException { 79 return new BlockContainer(parent, propertyList, 80 systemId, line, column); 81 } 82 83 } 84 85 public static FObj.Maker maker() { 86 return new BlockContainer.Maker(); 87 } 88 89 PageSequence pageSequence; 90 91 protected BlockContainer(FObj parent, PropertyList propertyList, 92 String systemId, int line, int column) 93 throws FOPException { 94 super(parent, propertyList, systemId, line, column); 95 this.span = this.properties.get("span").getEnum(); 96 } 97 98 public String getName() { 99 return "fo:block-container"; 100 } 101 102 public int layout(Area area) throws FOPException { 103 if (this.marker == START) { 104 105 AbsolutePositionProps mAbsProps = propMgr.getAbsolutePositionProps(); 107 108 BorderAndPadding bap = propMgr.getBorderAndPadding(); 110 BackgroundProps bProps = propMgr.getBackgroundProps(); 111 112 MarginProps mProps = propMgr.getMarginProps(); 114 115 131 this.marker = 0; 132 133 this.position = this.properties.get("position").getEnum(); 134 this.top = this.properties.get("top").getLength().mvalue(); 135 this.bottom = this.properties.get("bottom").getLength().mvalue(); 136 this.left = this.properties.get("left").getLength().mvalue(); 137 this.right = this.properties.get("right").getLength().mvalue(); 138 this.width = this.properties.get("width").getLength().mvalue(); 139 this.height = this.properties.get("height").getLength().mvalue(); 140 span = this.properties.get("span").getEnum(); 141 142 String id = this.properties.get("id").getString(); 144 try { 145 area.getIDReferences().initializeID(id, area); 146 } 147 catch(FOPException e) { 148 if (!e.isLocationSet()) { 149 e.setLocation(systemId, line, column); 150 } 151 throw e; 152 } 153 } 154 155 boolean prevChildMustKeepWithNext = false; 156 157 AreaContainer container = (AreaContainer)area; 158 if ((this.width == 0) && (this.height == 0)) { 159 width = right - left; 160 height = bottom - top; 161 } 162 163 this.areaContainer = 164 new AreaContainer(propMgr.getFontState(container.getFontInfo()), 165 container.getXPosition() + left, 166 container.getYPosition() - top, width, height, 167 position); 168 169 areaContainer.setPage(area.getPage()); 170 areaContainer.setBackground(propMgr.getBackgroundProps()); 171 areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding()); 172 areaContainer.start(); 173 174 areaContainer.setAbsoluteHeight(0); 176 areaContainer.setIDReferences(area.getIDReferences()); 177 178 int numChildren = this.children.size(); 179 for (int i = this.marker; i < numChildren; i++) { 180 FObj fo = (FObj)children.get(i); 181 int status; 182 if (Status.isIncomplete((status = fo.layout(areaContainer)))) { 183 197 } 198 if (status == Status.KEEP_WITH_NEXT) { 199 prevChildMustKeepWithNext = true; 200 } 201 } 202 203 areaContainer.end(); 204 if (position == Position.ABSOLUTE) 205 areaContainer.setHeight(height); 206 area.addChild(areaContainer); 207 208 return Status.OK; 209 } 210 211 215 public int getContentWidth() { 216 if (areaContainer != null) 217 return areaContainer.getContentWidth(); else 219 return 0; } 221 222 public boolean generatesReferenceAreas() { 223 return true; 224 } 225 226 public int getSpan() { 227 return this.span; 228 } 229 230 } 231 | Popular Tags |