Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/nwalsh/saxon/FormatUnicodeCallout.java


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   *
18   * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
19   *
20   * <p><b>Change Log:</b></p>
21   * <dl>
22   * <dt>1.0</dt>
23   * <dd><p>Initial release.</p></dd>
24   * </dl>
25   *
26   * @author Norman Walsh
27   * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
28   *
29   * @see Verbatim
30   *
31   **/
32  
33  public class FormatUnicodeCallout extends FormatCallout {
34    int unicodeMax = 0;
35    int unicodeStart = 0;
36    String unicodeFont = "";
37  
38    public FormatUnicodeCallout(NamePool nPool,
39              String font,
40              int start,
41              int max,
42              boolean fo) {
43      super(nPool, fo);
44      unicodeFont = font;
45      unicodeMax = max;
46      unicodeStart = start;
47    }
48  
49    public void formatCallout(Emitter rtfEmitter,
50            Callout callout) {
51      Element area = callout.getArea();
52      int num = callout.getCallout();
53      String userLabel = areaLabel(area);
54      String label = "";
55  
56      if (userLabel != null) {
57        label = userLabel;
58      }
59  
60      try {
61        if (userLabel == null && num <= unicodeMax) {
62    int inName = 0;
63    AttributeCollection inAttr = null;
64    int namespaces[] = new int[1];
65  
66    if (!unicodeFont.equals("")) {
67      if (foStylesheet) {
68        inName = namePool.allocate("fo", foURI, "inline");
69        inAttr = new AttributeCollection(namePool);
70        inAttr.addAttribute("", "", "font-family", "CDATA", unicodeFont);
71      } else {
72        inName = namePool.allocate("", "", "font");
73        inAttr = new AttributeCollection(namePool);
74        inAttr.addAttribute("", "", "face", "CDATA", unicodeFont);
75      }
76  
77      startSpan(rtfEmitter);
78      rtfEmitter.startElement(inName, inAttr, namespaces, 0);
79    }
80  
81    char chars[] = new char[1];
82    chars[0] = (char) (unicodeStart + num - 1);
83    rtfEmitter.characters(chars, 0, 1);
84  
85    if (!unicodeFont.equals("")) {
86      rtfEmitter.endElement(inName);
87      endSpan(rtfEmitter);
88    }
89        } else {
90    formatTextCallout(rtfEmitter, callout);
91        }
92      } catch (TransformerException e) {
93        System.out.println("Transformer Exception in graphic formatCallout");
94      }
95    }
96  }