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

Quick Search    Search Deep

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


1   package com.nwalsh.xalan;
2   
3   import org.xml.sax.helpers.AttributesImpl;
4   import org.xml.sax.SAXException;
5   import org.w3c.dom.*;
6   import org.apache.xml.utils.DOMBuilder;
7   import com.nwalsh.xalan.Callout;
8   import org.apache.xml.utils.AttList;
9   
10  /**
11   * <p>Utility class for the Verbatim extension (ignore this).</p>
12   *
13   *
14   * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
15   *
16   * <p><b>Change Log:</b></p>
17   * <dl>
18   * <dt>1.0</dt>
19   * <dd><p>Initial release.</p></dd>
20   * </dl>
21   *
22   * @author Norman Walsh
23   * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
24   *
25   * @see Verbatim
26   *
27   **/
28  
29  public class FormatDingbatCallout extends FormatCallout {
30    int graphicsMax = 0;
31  
32    public FormatDingbatCallout(int max, boolean fo) {
33      graphicsMax = max;
34      stylesheetFO = fo;
35    }
36  
37    public void formatCallout(DOMBuilder rtf,
38            Callout callout) {
39      Element area = callout.getArea();
40      int num = callout.getCallout();
41      String label = areaLabel(area);
42  
43      try {
44        if (label == null && num <= graphicsMax) {
45    AttributesImpl imgAttr = new AttributesImpl();
46    String ns = "";
47    String prefix = "";
48    String imgName = "";
49  
50    if (stylesheetFO) {
51      ns = foURI;
52      prefix = "fo:"; // FIXME: this could be a problem...
53      imgName = "inline";
54      imgAttr.addAttribute("", "font-family", "font-family", "CDATA",
55               "ZapfDingbats");
56    } else {
57      ns = "";
58      prefix = "";
59      imgName = "font";
60      imgAttr.addAttribute("", "face", "face", "CDATA",
61               "ZapfDingbats");
62    }
63  
64    startSpan(rtf);
65    rtf.startElement(ns, imgName, prefix+imgName, imgAttr);
66  
67    char chars[] = new char[1];
68    chars[0] = (char) (0x2775 + num);
69    rtf.characters(chars, 0, 1);
70  
71    rtf.endElement(ns, imgName, prefix+imgName);
72    endSpan(rtf);
73        } else {
74    formatTextCallout(rtf, callout);
75        }
76      } catch (SAXException e) {
77        System.out.println("SAX Exception in graphics formatCallout");
78      }
79    }
80  }