1 51 package org.apache.fop.fo.flow; 52 53 import org.apache.fop.fo.*; 55 import org.apache.fop.datatypes.*; 56 import org.apache.fop.fo.properties.*; 57 import org.apache.fop.layout.*; 58 import org.apache.fop.apps.FOPException; 59 60 61 115 public class PageNumberCitation extends FObj { 116 117 public static class Maker extends FObj.Maker { 118 public FObj make(FObj parent, PropertyList propertyList, 119 String systemId, int line, int column) 120 throws FOPException { 121 return new PageNumberCitation(parent, propertyList, 122 systemId, line, column); 123 } 124 125 } 126 127 public static FObj.Maker maker() { 128 return new PageNumberCitation.Maker(); 129 } 130 131 float red; 132 float green; 133 float blue; 134 int wrapOption; 135 int whiteSpaceCollapse; 136 Area area; 137 String pageNumber; 138 String refId; 139 String id; 140 TextState ts; 141 142 143 public PageNumberCitation(FObj parent, PropertyList propertyList, 144 String systemId, int line, int column) { 145 super(parent, propertyList, systemId, line, column); 146 } 147 148 public String getName() { 149 return "fo:page-number-citation"; 150 } 151 152 public int layout(Area area) throws FOPException { 153 if (!(area instanceof BlockArea)) { 154 log.warn("page-number-citation outside block area"); 155 return Status.OK; 156 } 157 158 IDReferences idReferences = area.getIDReferences(); 159 this.area = area; 160 if (this.marker == START) { 161 162 AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); 164 165 AuralProps mAurProps = propMgr.getAuralProps(); 167 168 BorderAndPadding bap = propMgr.getBorderAndPadding(); 170 BackgroundProps bProps = propMgr.getBackgroundProps(); 171 172 175 MarginInlineProps mProps = propMgr.getMarginInlineProps(); 177 178 RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); 180 181 198 ColorType c = this.properties.get("color").getColorType(); 199 this.red = c.red(); 200 this.green = c.green(); 201 this.blue = c.blue(); 202 203 this.wrapOption = this.properties.get("wrap-option").getEnum(); 204 this.whiteSpaceCollapse = 205 this.properties.get("white-space-collapse").getEnum(); 206 207 this.refId = this.properties.get("ref-id").getString(); 208 209 if (this.refId.equals("")) { 210 throw new FOPException("page-number-citation must contain \"ref-id\"", systemId, line, column); 211 } 212 213 this.id = this.properties.get("id").getString(); 215 try { 216 idReferences.createID(id); 217 } 218 catch(FOPException e) { 219 if (!e.isLocationSet()) { 220 e.setLocation(systemId, line, column); 221 } 222 throw e; 223 } 224 ts = new TextState(); 225 226 this.marker = 0; 227 } 228 229 if (marker == 0) { 230 idReferences.configureID(id, area); 231 } 232 233 234 pageNumber = idReferences.getPageNumber(refId); 235 236 if (pageNumber != null) { this.marker = 238 FOText.addText((BlockArea)area, 239 propMgr.getFontState(area.getFontInfo()), red, 240 green, blue, wrapOption, null, 241 whiteSpaceCollapse, pageNumber.toCharArray(), 242 0, pageNumber.length(), ts, 243 VerticalAlign.BASELINE); 244 } else { BlockArea blockArea = (BlockArea)area; 246 LineArea la = blockArea.getCurrentLineArea(); 247 if (la == null) { 248 return Status.AREA_FULL_NONE; 249 } 250 la.changeFont(propMgr.getFontState(area.getFontInfo())); 251 la.changeColor(red, green, blue); 252 la.changeWrapOption(wrapOption); 253 la.changeWhiteSpaceCollapse(whiteSpaceCollapse); 254 259 260 la.addPageNumberCitation(refId, null); 262 this.marker = -1; 263 } 264 265 266 if (this.marker == -1) { 267 return Status.OK; 268 } else { 269 return Status.AREA_FULL_NONE; 270 } 271 272 } 273 274 } 275 276 | Popular Tags |