Debian Codegraph @

src/com/nwalsh/saxon/FormatUnicodeCallout.java

raw symbols SCIP
1 package com.nwalsh.saxon;
2
3 import org.xml.sax.SAXException;
4 import org.w3c.dom.*;
5
6 import javax.xml.transform.TransformerException;
7
8 import com.icl.saxon.om.NamePool;
9 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 7007 2007-07-11 07:09:12Z mzjn $</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:[email protected]">[email protected]</a>
29 *
30 * @see Verbatim
31 *
32 * @version $Id: FormatUnicodeCallout.java 7007 2007-07-11 07:09:12Z mzjn $
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,
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 String id = areaID(area);
58
59 if (userLabel != null) {
60 label = userLabel;
61 }
62
63 try {
64 if (userLabel == null && num <= unicodeMax) {
65 int inName = 0;
66 AttributeCollection inAttr = null;
67 int namespaces[] = new int[1];
68
69 if (!unicodeFont.equals("")) {
70 if (foStylesheet) {
71 inName = namePool.allocate("fo", foURI, "inline");
72 inAttr = new AttributeCollection(namePool);
73 inAttr.addAttribute("", "", "font-family", "CDATA", unicodeFont);
74 inAttr.addAttribute("", "", "id", "ID", id);
75
76 } else {
77 inName = namePool.allocate("", "", "font");
78 inAttr = new AttributeCollection(namePool);
79 inAttr.addAttribute("", "", "face", "CDATA", unicodeFont);
80 inAttr.addAttribute("", "", "id", "ID", id);
81 }
82
83 startSpan(rtfEmitter, id);
84 rtfEmitter.startElement(inName, inAttr, namespaces, 0);
85 }
86
87 char chars[] = new char[1];
88 chars[0] = (char) (unicodeStart + num - 1);
89 rtfEmitter.characters(chars, 0, 1);
90
91 if (!unicodeFont.equals("")) {
92 rtfEmitter.endElement(inName);
93 endSpan(rtfEmitter);
94 }
95 } else {
96 formatTextCallout(rtfEmitter, callout);
97 }
98 } catch (TransformerException e) {
99 System.out.println("Transformer Exception in graphic formatCallout");
100 }
101 }
102 }