01: package com.nwalsh.saxon;
02:
03: import org.xml.sax.SAXException;
04: import org.w3c.dom.*;
05:
06: import javax.xml.transform.TransformerException;
07:
08: import com.icl.saxon.om.NamePool;
09: import com.icl.saxon.output.Emitter;
10: import com.icl.saxon.tree.AttributeCollection;
11:
12: import 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.1 2006/05/31 17:21:20 mbatchelor 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.1 2006/05/31 17:21:20 mbatchelor Exp $
33: **/
34:
35: public class FormatUnicodeCallout extends FormatCallout {
36: int unicodeMax = 0;
37: int unicodeStart = 0;
38: String unicodeFont = "";
39:
40: public FormatUnicodeCallout(NamePool nPool, String font, int start,
41: int max, boolean fo) {
42: super (nPool, fo);
43: unicodeFont = font;
44: unicodeMax = max;
45: unicodeStart = start;
46: }
47:
48: public void formatCallout(Emitter rtfEmitter, Callout callout) {
49: Element area = callout.getArea();
50: int num = callout.getCallout();
51: String userLabel = areaLabel(area);
52: String label = "";
53:
54: if (userLabel != null) {
55: label = userLabel;
56: }
57:
58: try {
59: if (userLabel == null && num <= unicodeMax) {
60: int inName = 0;
61: AttributeCollection inAttr = null;
62: int namespaces[] = new int[1];
63:
64: if (!unicodeFont.equals("")) {
65: if (foStylesheet) {
66: inName = namePool.allocate("fo", foURI,
67: "inline");
68: inAttr = new AttributeCollection(namePool);
69: inAttr.addAttribute("", "", "font-family",
70: "CDATA", unicodeFont);
71: } else {
72: inName = namePool.allocate("", "", "font");
73: inAttr = new AttributeCollection(namePool);
74: inAttr.addAttribute("", "", "face", "CDATA",
75: unicodeFont);
76: }
77:
78: startSpan(rtfEmitter);
79: rtfEmitter.startElement(inName, inAttr, namespaces,
80: 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
96: .println("Transformer Exception in graphic formatCallout");
97: }
98: }
99: }
|