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.datatypes.*; 57 import org.apache.fop.fo.properties.*; 58 import org.apache.fop.apps.FOPException; 59 60 public class PageNumber extends FObj { 61 62 public static class Maker extends FObj.Maker { 63 public FObj make(FObj parent, PropertyList propertyList, 64 String systemId, int line, int column) 65 throws FOPException { 66 return new PageNumber(parent, propertyList, systemId, line, column); 67 } 68 69 } 70 71 public static FObj.Maker maker() { 72 return new PageNumber.Maker(); 73 } 74 75 float red; 76 float green; 77 float blue; 78 int wrapOption; 79 int whiteSpaceCollapse; 80 TextState ts; 81 82 public PageNumber(FObj parent, PropertyList propertyList, 83 String systemId, int line, int column) { 84 super(parent, propertyList, systemId, line, column); 85 } 86 87 public String getName() { 88 return "fo:page-number"; 89 } 90 91 public int layout(Area area) throws FOPException { 92 if (!(area instanceof BlockArea)) { 93 log.warn("page-number outside block area"); 94 return Status.OK; 95 } 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 111 MarginInlineProps mProps = propMgr.getMarginInlineProps(); 113 114 RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); 116 117 133 ColorType c = this.properties.get("color").getColorType(); 134 this.red = c.red(); 135 this.green = c.green(); 136 this.blue = c.blue(); 137 138 this.wrapOption = this.properties.get("wrap-option").getEnum(); 139 this.whiteSpaceCollapse = 140 this.properties.get("white-space-collapse").getEnum(); 141 ts = new TextState(); 142 this.marker = 0; 143 144 String id = this.properties.get("id").getString(); 146 try { 147 area.getIDReferences().initializeID(id, area); 148 } 149 catch(FOPException e) { 150 if (!e.isLocationSet()) { 151 e.setLocation(systemId, line, column); 152 } 153 throw e; 154 } 155 } 156 157 String p = area.getPage().getFormattedNumber(); 158 this.marker = FOText.addText((BlockArea)area, 159 propMgr.getFontState(area.getFontInfo()), 160 red, green, blue, wrapOption, null, 161 whiteSpaceCollapse, p.toCharArray(), 0, 162 p.length(), ts, VerticalAlign.BASELINE); 163 return Status.OK; 164 } 165 166 } 167 | Popular Tags |