]> granicus.if.org Git - docbook-dsssl/commitdiff
Dingbat hackery; this may all get pulled out
authorNorman Walsh <ndw@nwalsh.com>
Sat, 7 Jul 2001 22:10:38 +0000 (22:10 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Sat, 7 Jul 2001 22:10:38 +0000 (22:10 +0000)
xsl/extensions/saxon551/com/nwalsh/saxon/FormatDingbatCallout.java [new file with mode: 0644]
xsl/extensions/saxon551/com/nwalsh/saxon/Verbatim.java
xsl/extensions/saxon6/com/nwalsh/saxon/FormatDingbatCallout.java [new file with mode: 0644]
xsl/extensions/saxon6/com/nwalsh/saxon/Verbatim.java
xsl/extensions/saxon61/com/nwalsh/saxon/FormatDingbatCallout.java [new file with mode: 0644]
xsl/extensions/saxon61/com/nwalsh/saxon/Verbatim.java
xsl/extensions/saxon63/com/nwalsh/saxon/FormatDingbatCallout.java [new file with mode: 0644]
xsl/extensions/saxon63/com/nwalsh/saxon/Verbatim.java

diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/FormatDingbatCallout.java b/xsl/extensions/saxon551/com/nwalsh/saxon/FormatDingbatCallout.java
new file mode 100644 (file)
index 0000000..25adaa3
--- /dev/null
@@ -0,0 +1,88 @@
+package com.nwalsh.saxon;
+
+import org.xml.sax.SAXException;
+import org.w3c.dom.*;
+
+import com.icl.saxon.om.ElementInfo;
+import com.icl.saxon.om.Name;
+import com.icl.saxon.output.Emitter;
+import com.icl.saxon.AttributeCollection;
+
+import com.nwalsh.saxon.Callout;
+
+/**
+ * <p>Utility class for the Verbatim extension (ignore this).</p>
+ *
+ * <p>$Id$</p>
+ *
+ * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
+ *
+ * <p><b>Change Log:</b></p>
+ * <dl>
+ * <dt>1.0</dt>
+ * <dd><p>Initial release.</p></dd>
+ * </dl>
+ *
+ * @author Norman Walsh
+ * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
+ *
+ * @see Verbatim
+ *
+ * @version $Id$
+ **/
+
+public class FormatDingbatCallout extends FormatCallout {
+  int graphicsMax = 0;
+
+  public FormatDingbatCallout(int max, boolean fo) {
+    super(fo);
+    graphicsMax = max;
+  }
+
+  public void formatCallout(Emitter rtfEmitter,
+                           Callout callout) {
+    ElementInfo area = callout.getArea();
+    int num = callout.getCallout();
+    String userLabel = areaLabel(area);
+    String label = "";
+
+    if (userLabel != null) {
+      label = userLabel;
+    }
+
+    try {
+      if (userLabel == null && num <= graphicsMax) {
+       Name imgName = null;
+       AttributeCollection imgAttr = null;
+
+       if (foStylesheet) {
+         imgName = new Name("fo",
+                            "http://www.w3.org/1999/XSL/Format",
+                            "inline");
+         imgAttr = new AttributeCollection();
+         imgAttr.addAttribute(new Name("font-family"), "CDATA",
+                              "ZapfDingbats");
+       } else {
+         imgName = new Name("font");
+         imgAttr = new AttributeCollection();
+         imgAttr.addAttribute(new Name("face"), "CDATA",
+                              "ZapfDingbats");
+       }
+
+       startSpan(rtfEmitter);
+       rtfEmitter.startElement(imgName, imgAttr);
+
+       char chars[] = new char[1];
+       chars[0] = (char) (0x2775 + num);
+       rtfEmitter.characters(chars, 0, 1);
+
+       rtfEmitter.endElement(imgName);
+       endSpan(rtfEmitter);
+      } else {
+       formatTextCallout(rtfEmitter, callout);
+      }
+    } catch (SAXException e) {
+      System.out.println("SAX Exception in graphic formatCallout");
+    }
+  }
+}
index 91ae39c27c59a105641c684de14dc6700203ab09..61e503cd721e8527a69450b2d27c3f229b03e323 100644 (file)
@@ -475,9 +475,11 @@ public class Verbatim {
   private static void setupCallouts(Context context) {
     boolean useGraphics = false;
     boolean useUnicode = false;
+    boolean useDingbats = false;
 
     int unicodeStart = 48;
     int unicodeMax = 0;
+    int dingbatMax = 10;
 
     // Hardcoded defaults
     defaultColumn = 60;
@@ -506,10 +508,14 @@ public class Verbatim {
     varString = getVariable(context, "callout.graphics");
     useGraphics = !(varString.equals("0") || varString.equals(""));
 
-      // Use unicode at all?
+    // Use unicode at all?
     varString = getVariable(context, "callout.unicode");
     useUnicode = !(varString.equals("0") || varString.equals(""));
 
+    // Use dingbats at all?
+    varString = getVariable(context, "callout.dingbats");
+    useUnicode = !(varString.equals("0") || varString.equals(""));
+
     if (useGraphics) {
       // Get the graphics path
       varString = getVariable(context, "callout.graphics.path");
@@ -557,6 +563,9 @@ public class Verbatim {
       fCallout = new FormatUnicodeCallout(unicodeStart,
                                          unicodeMax,
                                          foStylesheet);
+    } else if (useDingbats) {
+      fCallout = new FormatDingbatCallout(dingbatMax,
+                                         foStylesheet);
     } else {
       fCallout = new FormatTextCallout(foStylesheet);
     }
diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/FormatDingbatCallout.java b/xsl/extensions/saxon6/com/nwalsh/saxon/FormatDingbatCallout.java
new file mode 100644 (file)
index 0000000..e69b25a
--- /dev/null
@@ -0,0 +1,85 @@
+package com.nwalsh.saxon;
+
+import org.xml.sax.SAXException;
+import org.w3c.dom.*;
+
+import com.icl.saxon.om.ElementInfo;
+import com.icl.saxon.om.NamePool;
+import com.icl.saxon.output.Emitter;
+import com.icl.saxon.tree.AttributeCollection;
+
+import com.nwalsh.saxon.Callout;
+
+/**
+ * <p>Utility class for the Verbatim extension (ignore this).</p>
+ *
+ * <p>$Id$</p>
+ *
+ * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
+ *
+ * <p><b>Change Log:</b></p>
+ * <dl>
+ * <dt>1.0</dt>
+ * <dd><p>Initial release.</p></dd>
+ * </dl>
+ *
+ * @author Norman Walsh
+ * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
+ *
+ * @see Verbatim
+ *
+ * @version $Id$
+ **/
+
+public class FormatDingbatCallout extends FormatCallout {
+  int graphicsMax = 0;
+
+  public FormatDingbatCallout(NamePool nPool, int max, boolean fo) {
+    super(nPool, fo);
+    graphicsMax = max;
+  }
+
+  public void formatCallout(Emitter rtfEmitter,
+                           Callout callout) {
+    ElementInfo area = callout.getArea();
+    int num = callout.getCallout();
+    String userLabel = areaLabel(area);
+    String label = "";
+
+    if (userLabel != null) {
+      label = userLabel;
+    }
+
+    try {
+      if (userLabel == null && num <= graphicsMax) {
+       int inName = 0;
+       AttributeCollection inAttr = null;
+       int namespaces[] = new int[1];
+
+       if (foStylesheet) {
+         inName = namePool.allocate("fo", foURI, "inline");
+         inAttr = new AttributeCollection(namePool);
+         inAttr.addAttribute("", "", "font-family", "CDATA", "ZapfDingbats");
+       } else {
+         inName = namePool.allocate("", "", "font");
+         inAttr = new AttributeCollection(namePool);
+         inAttr.addAttribute("", "", "face", "CDATA", "ZapfDingbats");
+       }
+
+       startSpan(rtfEmitter);
+       rtfEmitter.startElement(inName, inAttr, namespaces, 0);
+
+       char chars[] = new char[1];
+       chars[0] = (char) (0x2775 + num);
+       rtfEmitter.characters(chars, 0, 1);
+
+       rtfEmitter.endElement(inName);
+       endSpan(rtfEmitter);
+      } else {
+       formatTextCallout(rtfEmitter, callout);
+      }
+    } catch (SAXException e) {
+      System.out.println("SAX Exception in graphic formatCallout");
+    }
+  }
+}
index 6e63dda526b8931d8c646ee30ced60ebce57c4a2..fe46553f3f705fd076721c91541484eef767f7aa 100644 (file)
@@ -283,6 +283,7 @@ public class Verbatim {
 
     boolean useGraphics = false;
     boolean useUnicode = false;
+    boolean useDingbats = false;
 
     // Hardcoded defaults
     defaultColumn = 60;
@@ -290,6 +291,7 @@ public class Verbatim {
 
     int unicodeStart = 48;
     int unicodeMax = 0;
+    int dingbatMax = 10;
 
     String graphicsPath = null;
     String graphicsExt = null;
@@ -319,6 +321,10 @@ public class Verbatim {
     varString = getVariable(context, "callout.unicode");
     useUnicode = !(varString.equals("0") || varString.equals(""));
 
+    // Use dingbats at all?
+    varString = getVariable(context, "callout.dingbats");
+    useDingbats = !(varString.equals("0") || varString.equals(""));
+
     if (useGraphics) {
       // Get the graphics path
       varString = getVariable(context, "callout.graphics.path");
@@ -368,6 +374,10 @@ public class Verbatim {
                                          unicodeStart,
                                          unicodeMax,
                                          foStylesheet);
+    } else if (useDingbats) {
+      fCallout = new FormatDingbatCallout(namePool,
+                                         dingbatMax,
+                                         foStylesheet);
     } else {
       fCallout = new FormatTextCallout(namePool, foStylesheet);
     }
diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/FormatDingbatCallout.java b/xsl/extensions/saxon61/com/nwalsh/saxon/FormatDingbatCallout.java
new file mode 100644 (file)
index 0000000..fa85977
--- /dev/null
@@ -0,0 +1,88 @@
+package com.nwalsh.saxon;
+
+import org.xml.sax.SAXException;
+import org.w3c.dom.*;
+
+import javax.xml.transform.TransformerException;
+
+import com.icl.saxon.om.ElementInfo;
+import com.icl.saxon.om.NamePool;
+import com.icl.saxon.output.Emitter;
+import com.icl.saxon.tree.AttributeCollection;
+
+import com.nwalsh.saxon.Callout;
+
+/**
+ * <p>Utility class for the Verbatim extension (ignore this).</p>
+ *
+ * <p>$Id$</p>
+ *
+ * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
+ *
+ * <p><b>Change Log:</b></p>
+ * <dl>
+ * <dt>1.0</dt>
+ * <dd><p>Initial release.</p></dd>
+ * </dl>
+ *
+ * @author Norman Walsh
+ * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
+ *
+ * @see Verbatim
+ *
+ * @version $Id$
+ **/
+
+public class FormatDingbatCallout extends FormatCallout {
+  int graphicsMax = 0;
+
+  public FormatDingbatCallout(NamePool nPool, int max, boolean fo) {
+    super(nPool, fo);
+    graphicsMax = max;
+  }
+
+  public void formatCallout(Emitter rtfEmitter,
+                           Callout callout) {
+    ElementInfo area = callout.getArea();
+    int num = callout.getCallout();
+    String userLabel = areaLabel(area);
+    String label = "";
+
+    if (userLabel != null) {
+      label = userLabel;
+    }
+
+    try {
+      if (userLabel == null && num <= graphicsMax) {
+       int inName = 0;
+       AttributeCollection inAttr = null;
+       int namespaces[] = new int[1];
+
+       if (foStylesheet) {
+         inName = namePool.allocate("fo", foURI, "inline");
+         inAttr = new AttributeCollection(namePool);
+         inAttr.addAttribute("", "", "font-family", "CDATA", "ZapfDingbats");
+       } else {
+         inName = namePool.allocate("", "", "font");
+         inAttr = new AttributeCollection(namePool);
+         inAttr.addAttribute("", "", "face", "CDATA", "ZapfDingbats");
+       }
+
+       startSpan(rtfEmitter);
+       rtfEmitter.startElement(inName, inAttr, namespaces, 0);
+
+       char chars[] = new char[1];
+       chars[0] = (char) (0x2775 + num);
+       rtfEmitter.characters(chars, 0, 1);
+
+       rtfEmitter.endElement(inName);
+       endSpan(rtfEmitter);
+      } else {
+       formatTextCallout(rtfEmitter, callout);
+      }
+    } catch (TransformerException e) {
+      System.out.println("Transformer Exception in graphic formatCallout");
+    }
+  }
+}
+
index 2f608e12fef5daa821f0fb10d0910afd7d9e06e0..87f47e43b78bce7ea0fbe3d56b9ff9f5f73131bb 100644 (file)
@@ -293,9 +293,11 @@ public class Verbatim {
 
     boolean useGraphics = false;
     boolean useUnicode = false;
+    boolean useDingbats = false;
 
     int unicodeStart = 49;
     int unicodeMax = 0;
+    int dingbatMax = 10;
 
     // Hardcoded defaults
     defaultColumn = 60;
@@ -329,6 +331,10 @@ public class Verbatim {
     varString = getVariable(context, "callout.unicode");
     useUnicode = !(varString.equals("0") || varString.equals(""));
 
+    // Use dingbats at all?
+    varString = getVariable(context, "callout.dingbats");
+    useDingbats = !(varString.equals("0") || varString.equals(""));
+
     if (useGraphics) {
       // Get the graphics path
       varString = getVariable(context, "callout.graphics.path");
@@ -378,6 +384,10 @@ public class Verbatim {
                                          unicodeStart,
                                          unicodeMax,
                                          foStylesheet);
+    } else if (useDingbats) {
+      fCallout = new FormatDingbatCallout(namePool,
+                                         dingbatMax,
+                                         foStylesheet);
     } else {
       fCallout = new FormatTextCallout(namePool, foStylesheet);
     }
diff --git a/xsl/extensions/saxon63/com/nwalsh/saxon/FormatDingbatCallout.java b/xsl/extensions/saxon63/com/nwalsh/saxon/FormatDingbatCallout.java
new file mode 100644 (file)
index 0000000..3fea34a
--- /dev/null
@@ -0,0 +1,87 @@
+package com.nwalsh.saxon;
+
+import org.xml.sax.SAXException;
+import org.w3c.dom.*;
+
+import javax.xml.transform.TransformerException;
+
+import com.icl.saxon.om.ElementInfo;
+import com.icl.saxon.om.NamePool;
+import com.icl.saxon.output.Emitter;
+import com.icl.saxon.tree.AttributeCollection;
+
+import com.nwalsh.saxon.Callout;
+
+/**
+ * <p>Utility class for the Verbatim extension (ignore this).</p>
+ *
+ * <p>$Id$</p>
+ *
+ * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
+ *
+ * <p><b>Change Log:</b></p>
+ * <dl>
+ * <dt>1.0</dt>
+ * <dd><p>Initial release.</p></dd>
+ * </dl>
+ *
+ * @author Norman Walsh
+ * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
+ *
+ * @see Verbatim
+ *
+ * @version $Id$
+ **/
+
+public class FormatDingbatCallout extends FormatCallout {
+  int graphicsMax = 0;
+
+  public FormatDingbatCallout(NamePool nPool, int max, boolean fo) {
+    super(nPool, fo);
+    graphicsMax = max;
+  }
+
+  public void formatCallout(Emitter rtfEmitter,
+                           Callout callout) {
+    ElementInfo area = callout.getArea();
+    int num = callout.getCallout();
+    String userLabel = areaLabel(area);
+    String label = "";
+
+    if (userLabel != null) {
+      label = userLabel;
+    }
+
+    try {
+      if (userLabel == null && num <= graphicsMax) {
+       int inName = 0;
+       AttributeCollection inAttr = null;
+       int namespaces[] = new int[1];
+
+       if (foStylesheet) {
+         inName = namePool.allocate("fo", foURI, "inline");
+         inAttr = new AttributeCollection(namePool);
+         inAttr.addAttribute("", "", "font-family", "CDATA", "ZapfDingbats");
+       } else {
+         inName = namePool.allocate("", "", "font");
+         inAttr = new AttributeCollection(namePool);
+         inAttr.addAttribute("", "", "face", "CDATA", "ZapfDingbats");
+       }
+
+       startSpan(rtfEmitter);
+       rtfEmitter.startElement(inName, inAttr, namespaces, 0);
+
+       char chars[] = new char[1];
+       chars[0] = (char) (0x2775 + num);
+       rtfEmitter.characters(chars, 0, 1);
+
+       rtfEmitter.endElement(inName);
+       endSpan(rtfEmitter);
+      } else {
+       formatTextCallout(rtfEmitter, callout);
+      }
+    } catch (TransformerException e) {
+      System.out.println("Transformer Exception in graphic formatCallout");
+    }
+  }
+}
index 8c08809251d83878bbc90649b78047e40e889e3d..9585b89897a58efb8769b25df530896b2c8c05c8 100644 (file)
@@ -295,9 +295,11 @@ public class Verbatim {
 
     boolean useGraphics = false;
     boolean useUnicode = false;
+    boolean useDingbats = false;
 
     int unicodeStart = 49;
     int unicodeMax = 0;
+    int dingbatMax = 10;
 
     // Hardcoded defaults
     defaultColumn = 60;
@@ -331,6 +333,10 @@ public class Verbatim {
     varString = getVariable(context, "callout.unicode");
     useUnicode = !(varString.equals("0") || varString.equals(""));
 
+    // Use dingbats at all?
+    varString = getVariable(context, "callout.dingbats");
+    useDingbats = !(varString.equals("0") || varString.equals(""));
+
     if (useGraphics) {
       // Get the graphics path
       varString = getVariable(context, "callout.graphics.path");
@@ -380,6 +386,10 @@ public class Verbatim {
                                          unicodeStart,
                                          unicodeMax,
                                          foStylesheet);
+    } else if (useDingbats) {
+      fCallout = new FormatDingbatCallout(namePool,
+                                         dingbatMax,
+                                         foStylesheet);
     } else {
       fCallout = new FormatTextCallout(namePool, foStylesheet);
     }