1package com.nwalsh.xalan; 2 3import org.xml.sax.helpers.AttributesImpl; 4import org.xml.sax.SAXException; 5import org.w3c.dom.*; 6import org.apache.xml.utils.DOMBuilder; 7import com.nwalsh.xalan.Callout; 8import org.apache.xml.utils.AttList; 9 10/** 11 * <p>Utility class for the Verbatim extension (ignore this).</p> 12 * 13 * <p>$Id: FormatUnicodeCallout.java,v 1.1 2006/05/04 13:23:51 nwalsh Exp $</p> 14 * 15 * <p>Copyright (C) 2000, 2001 Norman Walsh.</p> 16 * 17 * <p><b>Change Log:</b></p> 18 * <dl> 19 * <dt>1.0</dt> 20 * <dd><p>Initial release.</p></dd> 21 * </dl> 22 * 23 * @author Norman Walsh 24 * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a> 25 * 26 * @see Verbatim 27 * 28 * @version $Id: FormatUnicodeCallout.java,v 1.1 2006/05/04 13:23:51 nwalsh Exp $ 29 **/ 30 31public class FormatUnicodeCallout extends FormatCallout { 32 int unicodeMax = 0; 33 int unicodeStart = 0; 34 String unicodeFont = ""; 35 36 public FormatUnicodeCallout(String font, int start, int max, boolean fo) { 37 unicodeFont = font; 38 unicodeMax = max; 39 unicodeStart = start; 40 stylesheetFO = fo; 41 } 42 43 public void formatCallout(DOMBuilder rtf, 44 Callout callout) { 45 Element area = callout.getArea(); 46 int num = callout.getCallout(); 47 String label = areaLabel(area); 48 49 try { 50 if (label == null && num <= unicodeMax) { 51 AttributesImpl inAttr = new AttributesImpl(); 52 String ns = ""; 53 String prefix = ""; 54 String inName = ""; 55 56 if (!unicodeFont.equals("")) { 57 if (stylesheetFO) { 58 ns = foURI; 59 prefix = "fo:"; 60 inName = "inline"; 61 inAttr.addAttribute("", "", "font-family", "CDATA", unicodeFont); 62 } else { 63 inName = "font"; 64 inAttr.addAttribute("", "", "face", "CDATA", unicodeFont); 65 } 66 } 67 68 char chars[] = new char[1]; 69 chars[0] = (char) (unicodeStart + num - 1); 70 71 startSpan(rtf); 72 if (!unicodeFont.equals("")) { 73 rtf.startElement(ns, inName, prefix+inName, inAttr); 74 } 75 rtf.characters(chars, 0, 1); 76 if (!unicodeFont.equals("")) { 77 rtf.endElement(ns, inName, prefix+inName); 78 } 79 endSpan(rtf); 80 } else { 81 formatTextCallout(rtf, callout); 82 } 83 } catch (SAXException e) { 84 System.out.println("SAX Exception in unicode formatCallout"); 85 } 86 } 87} 88