01: package com.nwalsh.xalan;
02:
03: import org.xml.sax.helpers.AttributesImpl;
04: import org.xml.sax.SAXException;
05: import org.w3c.dom.*;
06: import org.apache.xml.utils.DOMBuilder;
07: import com.nwalsh.xalan.Callout;
08: import org.apache.xml.utils.AttList;
09:
10: /**
11: * <p>Utility class for the Verbatim extension (ignore this).</p>
12: *
13: * <p>$Id: FormatUnicodeCallout.java,v 1.4 2005-08-30 08:14:58 draganr 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.4 2005-08-30 08:14:58 draganr Exp $
29: **/
30:
31: public 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,
37: boolean fo) {
38: unicodeFont = font;
39: unicodeMax = max;
40: unicodeStart = start;
41: stylesheetFO = fo;
42: }
43:
44: public void formatCallout(DOMBuilder rtf, 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",
62: "CDATA", unicodeFont);
63: } else {
64: inName = "font";
65: inAttr.addAttribute("", "", "face", "CDATA",
66: unicodeFont);
67: }
68: }
69:
70: char chars[] = new char[1];
71: chars[0] = (char) (unicodeStart + num - 1);
72:
73: startSpan(rtf);
74: if (!unicodeFont.equals("")) {
75: rtf.startElement(ns, inName, prefix + inName,
76: inAttr);
77: }
78: rtf.characters(chars, 0, 1);
79: if (!unicodeFont.equals("")) {
80: rtf.endElement(ns, inName, prefix + inName);
81: }
82: endSpan(rtf);
83: } else {
84: formatTextCallout(rtf, callout);
85: }
86: } catch (SAXException e) {
87: System.out
88: .println("SAX Exception in unicode formatCallout");
89: }
90: }
91: }
|