1 51 package org.apache.fop.fo.flow; 52 53 import org.apache.fop.fo.*; 55 import org.apache.fop.fo.pagination.*; 56 import org.apache.fop.layout.Area; 57 import org.apache.fop.apps.FOPException; 58 59 public class StaticContent extends AbstractFlow { 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 StaticContent(parent, propertyList, 66 systemId, line, column); 67 } 68 } 69 70 public static FObj.Maker maker() { 71 return new StaticContent.Maker(); 72 } 73 74 protected StaticContent(FObj parent, PropertyList propertyList, 75 String systemId, int line, int column) 76 throws FOPException { 77 super(parent, propertyList, systemId, line, column); 78 setFlowName(getProperty("flow-name").getString()); 79 pageSequence.addStaticContent(this); 80 } 81 82 public String getName() { 83 return "fo:static-content"; 84 } 85 86 public int layout(Area area, Region region) throws FOPException { 87 88 int numChildren = this.children.size(); 89 String regionClass = "none"; 91 if (region != null) { 92 regionClass = region.getRegionClass(); 93 } else { 94 if (getFlowName().equals("xsl-region-before")) { 95 regionClass = RegionBefore.REGION_CLASS; 96 } else if (getFlowName().equals("xsl-region-after")) { 97 regionClass = RegionAfter.REGION_CLASS; 98 } else if (getFlowName().equals("xsl-region-start")) { 99 regionClass = RegionStart.REGION_CLASS; 100 } else if (getFlowName().equals("xsl-region-end")) { 101 regionClass = RegionEnd.REGION_CLASS; 102 } 103 104 } 105 106 if (area instanceof org.apache.fop.layout.AreaContainer) 107 ((org.apache.fop.layout.AreaContainer)area).setAreaName(regionClass); 108 109 area.setAbsoluteHeight(0); 111 setContentWidth(area.getContentWidth()); 112 113 for (int i = 0; i < numChildren; i++) { 114 FObj fo = (FObj)children.get(i); 115 116 int status; 117 if (Status.isIncomplete((status = fo.layout(area)))) { 118 log.warn("Some static content could not fit in the area."); 120 this.marker = i; 121 if ((i != 0) && (status == Status.AREA_FULL_NONE)) { 122 status = Status.AREA_FULL_SOME; 123 } 124 return (status); 125 } 126 } 127 resetMarker(); 128 return Status.OK; 129 } 130 131 protected void setFlowName(String name) throws FOPException { 133 if (name == null || name.equals("")) { 134 throw new FOPException("A 'flow-name' is required for " 135 + getName() + ".", systemId, line, column); 136 } else { 137 _flowName = name; 138 } 139 140 } 141 142 } 143 | Popular Tags |