1 package com.nwalsh.saxon; 2 3 import org.xml.sax.SAXException ; 4 import org.w3c.dom.*; 5 6 import javax.xml.transform.TransformerException ; 7 8 import com.icl.saxon.om.NamePool; 9 import com.icl.saxon.output.Emitter; 10 import com.icl.saxon.tree.AttributeCollection; 11 12 import com.nwalsh.saxon.Callout; 13 14 34 35 public class FormatUnicodeCallout extends FormatCallout { 36 int unicodeMax = 0; 37 int unicodeStart = 0; 38 String unicodeFont = ""; 39 40 public FormatUnicodeCallout(NamePool nPool, 41 String font, 42 int start, 43 int max, 44 boolean fo) { 45 super(nPool, fo); 46 unicodeFont = font; 47 unicodeMax = max; 48 unicodeStart = start; 49 } 50 51 public void formatCallout(Emitter rtfEmitter, 52 Callout callout) { 53 Element area = callout.getArea(); 54 int num = callout.getCallout(); 55 String userLabel = areaLabel(area); 56 String label = ""; 57 58 if (userLabel != null) { 59 label = userLabel; 60 } 61 62 try { 63 if (userLabel == null && num <= unicodeMax) { 64 int inName = 0; 65 AttributeCollection inAttr = null; 66 int namespaces[] = new int[1]; 67 68 if (!unicodeFont.equals("")) { 69 if (foStylesheet) { 70 inName = namePool.allocate("fo", foURI, "inline"); 71 inAttr = new AttributeCollection(namePool); 72 inAttr.addAttribute("", "", "font-family", "CDATA", unicodeFont); 73 } else { 74 inName = namePool.allocate("", "", "font"); 75 inAttr = new AttributeCollection(namePool); 76 inAttr.addAttribute("", "", "face", "CDATA", unicodeFont); 77 } 78 79 startSpan(rtfEmitter); 80 rtfEmitter.startElement(inName, inAttr, namespaces, 0); 81 } 82 83 char chars[] = new char[1]; 84 chars[0] = (char) (unicodeStart + num - 1); 85 rtfEmitter.characters(chars, 0, 1); 86 87 if (!unicodeFont.equals("")) { 88 rtfEmitter.endElement(inName); 89 endSpan(rtfEmitter); 90 } 91 } else { 92 formatTextCallout(rtfEmitter, callout); 93 } 94 } catch (TransformerException e) { 95 System.out.println("Transformer Exception in graphic formatCallout"); 96 } 97 } 98 } 99 | Popular Tags |