From: Norman Walsh Date: Sat, 7 Jul 2001 22:10:38 +0000 (+0000) Subject: Dingbat hackery; this may all get pulled out X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e5aa0eb0be7cf8ab7d51a4c8eda38af38805d202;p=docbook-dsssl Dingbat hackery; this may all get pulled out --- diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/FormatDingbatCallout.java b/xsl/extensions/saxon551/com/nwalsh/saxon/FormatDingbatCallout.java new file mode 100644 index 000000000..25adaa39c --- /dev/null +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/FormatDingbatCallout.java @@ -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; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @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"); + } + } +} diff --git a/xsl/extensions/saxon551/com/nwalsh/saxon/Verbatim.java b/xsl/extensions/saxon551/com/nwalsh/saxon/Verbatim.java index 91ae39c27..61e503cd7 100644 --- a/xsl/extensions/saxon551/com/nwalsh/saxon/Verbatim.java +++ b/xsl/extensions/saxon551/com/nwalsh/saxon/Verbatim.java @@ -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 index 000000000..e69b25a83 --- /dev/null +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/FormatDingbatCallout.java @@ -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; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @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"); + } + } +} diff --git a/xsl/extensions/saxon6/com/nwalsh/saxon/Verbatim.java b/xsl/extensions/saxon6/com/nwalsh/saxon/Verbatim.java index 6e63dda52..fe46553f3 100644 --- a/xsl/extensions/saxon6/com/nwalsh/saxon/Verbatim.java +++ b/xsl/extensions/saxon6/com/nwalsh/saxon/Verbatim.java @@ -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 index 000000000..fa85977ec --- /dev/null +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/FormatDingbatCallout.java @@ -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; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @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"); + } + } +} + diff --git a/xsl/extensions/saxon61/com/nwalsh/saxon/Verbatim.java b/xsl/extensions/saxon61/com/nwalsh/saxon/Verbatim.java index 2f608e12f..87f47e43b 100644 --- a/xsl/extensions/saxon61/com/nwalsh/saxon/Verbatim.java +++ b/xsl/extensions/saxon61/com/nwalsh/saxon/Verbatim.java @@ -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 index 000000000..3fea34a18 --- /dev/null +++ b/xsl/extensions/saxon63/com/nwalsh/saxon/FormatDingbatCallout.java @@ -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; + +/** + *

Utility class for the Verbatim extension (ignore this).

+ * + *

$Id$

+ * + *

Copyright (C) 2000, 2001 Norman Walsh.

+ * + *

Change Log:

+ *
+ *
1.0
+ *

Initial release.

+ *
+ * + * @author Norman Walsh + * ndw@nwalsh.com + * + * @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"); + } + } +} diff --git a/xsl/extensions/saxon63/com/nwalsh/saxon/Verbatim.java b/xsl/extensions/saxon63/com/nwalsh/saxon/Verbatim.java index 8c0880925..9585b8989 100644 --- a/xsl/extensions/saxon63/com/nwalsh/saxon/Verbatim.java +++ b/xsl/extensions/saxon63/com/nwalsh/saxon/Verbatim.java @@ -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); }