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.layout.*; 57 import org.apache.fop.apps.FOPException; 58 import org.apache.fop.datatypes.*; 59 60 public class TableColumn extends FObj { 61 62 Length columnWidthPropVal; 63 int columnWidth; 64 int columnOffset; 65 int numColumnsRepeated; 66 int iColumnNumber; 67 68 boolean setup = false; 69 70 AreaContainer areaContainer; 71 72 public static class Maker extends FObj.Maker { 73 public FObj make(FObj parent, PropertyList propertyList, 74 String systemId, int line, int column) 75 throws FOPException { 76 return new TableColumn(parent, propertyList, 77 systemId, line, column); 78 } 79 } 80 81 public static FObj.Maker maker() { 82 return new TableColumn.Maker(); 83 } 84 85 public TableColumn(FObj parent, PropertyList propertyList, 86 String systemId, int line, int column) 87 throws FOPException { 88 super(parent, propertyList, systemId, line, column); 89 if (!(parent instanceof Table)) { 90 throw new FOPException("A table column must be child of fo:table, not " 91 + parent.getName(), systemId, line, column); 92 } 93 } 94 95 public String getName() { 96 return "fo:table-column"; 97 } 98 99 public Length getColumnWidthAsLength() { 100 return columnWidthPropVal; 101 } 102 103 public int getColumnWidth() { 104 return columnWidth; 105 } 106 107 111 public void setColumnWidth(int columnWidth) { 112 this.columnWidth = columnWidth; 113 } 114 115 public int getColumnNumber() { 116 return iColumnNumber; 117 } 118 119 public int getNumColumnsRepeated() { 120 return numColumnsRepeated; 121 } 122 123 public void doSetup(Area area) throws FOPException { 124 125 BorderAndPadding bap = propMgr.getBorderAndPadding(); 129 BackgroundProps bProps = propMgr.getBackgroundProps(); 130 131 136 this.iColumnNumber = 137 this.properties.get("column-number").getNumber().intValue(); 138 139 this.numColumnsRepeated = 140 this.properties.get("number-columns-repeated").getNumber().intValue(); 141 142 this.columnWidthPropVal = 143 this.properties.get("column-width").getLength(); 144 this.columnWidth = columnWidthPropVal.mvalue(); 146 147 String id = this.properties.get("id").getString(); 149 try { 150 area.getIDReferences().initializeID(id, area); 151 } 152 catch(FOPException e) { 153 if (!e.isLocationSet()) { 154 e.setLocation(systemId, line, column); 155 } 156 throw e; 157 } 158 159 setup = true; 160 } 161 162 public int layout(Area area) throws FOPException { 163 if (this.marker == BREAK_AFTER) { 164 return Status.OK; 165 } 166 167 if (this.marker == START) { 168 if (!setup) { 169 doSetup(area); 170 } 171 } 172 if (columnWidth > 0) { 173 this.areaContainer = 174 new AreaContainer(propMgr.getFontState(area.getFontInfo()), 175 columnOffset, 0, columnWidth, 176 area.getContentHeight(), Position.RELATIVE); 177 areaContainer.foCreator = this; areaContainer.setPage(area.getPage()); 179 areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding()); 180 areaContainer.setBackground(propMgr.getBackgroundProps()); 181 areaContainer.setHeight(area.getHeight()); 182 area.addChild(areaContainer); 183 } 184 return Status.OK; 185 } 186 187 public void setColumnOffset(int columnOffset) { 188 this.columnOffset = columnOffset; 189 } 190 191 public void setHeight(int height) { 192 if (areaContainer != null) { 193 areaContainer.setMaxHeight(height); 194 areaContainer.setHeight(height); 195 } 196 } 197 198 } 199 | Popular Tags |