1 51 package org.apache.fop.fo.flow; 52 53 import org.apache.fop.fo.*; 55 import org.apache.fop.datatypes.ColorType; 56 import org.apache.fop.layout.BlockArea; 57 import org.apache.fop.layout.*; 58 import org.apache.fop.fo.FObj; 59 import org.apache.fop.layout.LineArea; 60 import org.apache.fop.apps.FOPException; 61 62 63 76 public class Character extends FObj { 77 public static final int OK = 0; 78 public static final int DOESNOT_FIT = 1; 79 80 public static class Maker extends FObj.Maker { 81 public FObj make(FObj parent, PropertyList propertyList, 82 String systemId, int line, int column) 83 throws FOPException { 84 return new Character (parent, propertyList, systemId, line, column); 85 } 86 } 87 88 public static FObj.Maker maker() { 89 return new Character.Maker (); 90 } 91 92 public Character(FObj parent, PropertyList propertyList, 93 String systemId, int line, int column) { 94 super(parent, propertyList, systemId, line, column); 95 } 96 97 public String getName() { 98 return "fo:character"; 99 } 100 101 public int layout(Area area) throws FOPException { 102 BlockArea blockArea; 103 if (!(area instanceof BlockArea)) { 104 log.warn("currently Character can only be in a BlockArea"); 105 return Status.OK; 106 } 107 blockArea = (BlockArea)area; 108 boolean textDecoration; 109 110 AuralProps mAurProps = propMgr.getAuralProps(); 112 113 BorderAndPadding bap = propMgr.getBorderAndPadding(); 115 BackgroundProps bProps = propMgr.getBackgroundProps(); 116 117 120 HyphenationProps mHyphProps = propMgr.getHyphenationProps(); 122 123 MarginInlineProps mProps = propMgr.getMarginInlineProps(); 125 126 RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); 128 129 153 ColorType c = this.properties.get("color").getColorType(); 155 float red = c.red(); 156 float green = c.green(); 157 float blue = c.blue(); 158 159 int whiteSpaceCollapse = 160 this.properties.get("white-space-collapse").getEnum(); 161 int wrapOption = this.parent.properties.get("wrap-option").getEnum(); 162 163 int tmp = this.properties.get("text-decoration").getEnum(); 164 if (tmp == org.apache.fop.fo.properties.TextDecoration.UNDERLINE) { 165 textDecoration = true; 166 } else { 167 textDecoration = false; 168 } 169 170 char characterValue = this.properties.get("character").getCharacter(); 172 173 174 String id = this.properties.get("id").getString(); 176 try { 177 blockArea.getIDReferences().initializeID(id, blockArea); 178 } 179 catch(FOPException e) { 180 if (!e.isLocationSet()) { 181 e.setLocation(systemId, line, column); 182 } 183 throw e; 184 } 185 186 LineArea la = blockArea.getCurrentLineArea(); 187 if (la == null) { 188 return Status.AREA_FULL_NONE; 189 } 190 la.changeFont(propMgr.getFontState(area.getFontInfo())); 191 la.changeColor(red, green, blue); 192 la.changeWrapOption(wrapOption); 193 la.changeWhiteSpaceCollapse(whiteSpaceCollapse); 194 blockArea.setupLinkSet(this.getLinkSet()); 195 int result = la.addCharacter(characterValue, this.getLinkSet(), 196 textDecoration); 197 if (result == Character.DOESNOT_FIT) { 198 la = blockArea.createNextLineArea(); 199 if (la == null) { 200 return Status.AREA_FULL_NONE; 201 } 202 la.changeFont(propMgr.getFontState(area.getFontInfo())); 203 la.changeColor(red, green, blue); 204 la.changeWrapOption(wrapOption); 205 la.changeWhiteSpaceCollapse(whiteSpaceCollapse); 206 blockArea.setupLinkSet(this.getLinkSet()); 207 la.addCharacter(characterValue, this.getLinkSet(), 208 textDecoration); 209 } 210 return Status.OK; 211 212 } 213 214 } 215 | Popular Tags |