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: FormatDingbatCallout.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: FormatDingbatCallout.java,v 1.4 2005-08-30 08:14:58 draganr Exp $
29: **/
30:
31: public class FormatDingbatCallout extends FormatCallout {
32: int graphicsMax = 0;
33:
34: public FormatDingbatCallout(int max, boolean fo) {
35: graphicsMax = max;
36: stylesheetFO = fo;
37: }
38:
39: public void formatCallout(DOMBuilder rtf, Callout callout) {
40: Element area = callout.getArea();
41: int num = callout.getCallout();
42: String label = areaLabel(area);
43:
44: try {
45: if (label == null && num <= graphicsMax) {
46: AttributesImpl imgAttr = new AttributesImpl();
47: String ns = "";
48: String prefix = "";
49: String imgName = "";
50:
51: if (stylesheetFO) {
52: ns = foURI;
53: prefix = "fo:"; // FIXME: this could be a problem...
54: imgName = "inline";
55: imgAttr.addAttribute("", "font-family",
56: "font-family", "CDATA", "ZapfDingbats");
57: } else {
58: ns = "";
59: prefix = "";
60: imgName = "font";
61: imgAttr.addAttribute("", "face", "face", "CDATA",
62: "ZapfDingbats");
63: }
64:
65: startSpan(rtf);
66: rtf
67: .startElement(ns, imgName, prefix + imgName,
68: imgAttr);
69:
70: char chars[] = new char[1];
71: chars[0] = (char) (0x2775 + num);
72: rtf.characters(chars, 0, 1);
73:
74: rtf.endElement(ns, imgName, prefix + imgName);
75: endSpan(rtf);
76: } else {
77: formatTextCallout(rtf, callout);
78: }
79: } catch (SAXException e) {
80: System.out
81: .println("SAX Exception in graphics formatCallout");
82: }
83: }
84: }
|