1package com.nwalsh.saxon; 2 3import org.xml.sax.SAXException; 4import org.w3c.dom.*; 5 6import javax.xml.transform.TransformerException; 7 8import com.icl.saxon.om.NamePool; 9import com.icl.saxon.output.Emitter; 10import com.icl.saxon.tree.AttributeCollection; 11 12import com.nwalsh.saxon.Callout; 13 14/** 15 * <p>Utility class for the Verbatim extension (ignore this).</p> 16 * 17 * <p>$Id: FormatUnicodeCallout.java,v 1.2 2001/08/05 22:35:38 nwalsh Exp $</p> 18 * 19 * <p>Copyright (C) 2000, 2001 Norman Walsh.</p> 20 * 21 * <p><b>Change Log:</b></p> 22 * <dl> 23 * <dt>1.0</dt> 24 * <dd><p>Initial release.</p></dd> 25 * </dl> 26 * 27 * @author Norman Walsh 28 * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a> 29 * 30 * @see Verbatim 31 * 32 * @version $Id: FormatUnicodeCallout.java,v 1.2 2001/08/05 22:35:38 nwalsh Exp $ 33 **/ 34 35public 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