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

Quick Search    Search Deep

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


1   package com.nwalsh.xalan;
2   
3   import org.xml.sax.SAXException;
4   import org.w3c.dom.*;
5   import org.apache.xml.utils.DOMBuilder;
6   import com.nwalsh.xalan.Callout;
7   import org.apache.xml.utils.AttList;
8   
9   /**
10   * <p>Utility class for the Verbatim extension (ignore this).</p>
11   *
12   *
13   * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
14   *
15   * <p><b>Change Log:</b></p>
16   * <dl>
17   * <dt>1.0</dt>
18   * <dd><p>Initial release.</p></dd>
19   * </dl>
20   *
21   * @author Norman Walsh
22   * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
23   *
24   * @see Verbatim
25   *
26   **/
27  
28  public class FormatUnicodeCallout extends FormatCallout {
29    int unicodeMax = 0;
30    int unicodeStart = 0;
31  
32    public FormatUnicodeCallout(int start, int max, boolean fo) {
33      unicodeMax = max;
34      unicodeStart = start;
35      stylesheetFO = fo;
36    }
37  
38    public void formatCallout(DOMBuilder rtf,
39            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 <= unicodeMax) {
46    char chars[] = new char[1];
47    chars[0] = (char) (unicodeStart + num - 1);
48  
49    startSpan(rtf);
50    rtf.characters(chars, 0, 1);
51    endSpan(rtf);
52        } else {
53    formatTextCallout(rtf, callout);
54        }
55      } catch (SAXException e) {
56        System.out.println("SAX Exception in unicode formatCallout");
57      }
58    }
59  }