+++ /dev/null
-package com.nwalsh.saxon;
-
-import org.xml.sax.SAXException;
-import org.w3c.dom.*;
-
-import javax.xml.transform.TransformerException;
-
-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) {
- Element 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");
- }
- }
-}
public class FormatUnicodeCallout extends FormatCallout {
int unicodeMax = 0;
int unicodeStart = 0;
+ String unicodeFont = "";
- public FormatUnicodeCallout(NamePool nPool, int start, int max, boolean fo) {
+ public FormatUnicodeCallout(NamePool nPool,
+ String font,
+ int start,
+ int max,
+ boolean fo) {
super(nPool, fo);
+ unicodeFont = font;
unicodeMax = max;
unicodeStart = start;
}
public void formatCallout(Emitter rtfEmitter,
Callout callout) {
-
Element area = callout.getArea();
int num = callout.getCallout();
- String label = areaLabel(area);
+ String userLabel = areaLabel(area);
+ String label = "";
+
+ if (userLabel != null) {
+ label = userLabel;
+ }
try {
- if (label == null && num <= unicodeMax) {
+ if (userLabel == null && num <= unicodeMax) {
+ int inName = 0;
+ AttributeCollection inAttr = null;
+ int namespaces[] = new int[1];
+
+ if (!unicodeFont.equals("")) {
+ if (foStylesheet) {
+ inName = namePool.allocate("fo", foURI, "inline");
+ inAttr = new AttributeCollection(namePool);
+ inAttr.addAttribute("", "", "font-family", "CDATA", unicodeFont);
+ } else {
+ inName = namePool.allocate("", "", "font");
+ inAttr = new AttributeCollection(namePool);
+ inAttr.addAttribute("", "", "face", "CDATA", unicodeFont);
+ }
+
+ startSpan(rtfEmitter);
+ rtfEmitter.startElement(inName, inAttr, namespaces, 0);
+ }
+
char chars[] = new char[1];
chars[0] = (char) (unicodeStart + num - 1);
-
- startSpan(rtfEmitter);
rtfEmitter.characters(chars, 0, 1);
- endSpan(rtfEmitter);
+
+ if (!unicodeFont.equals("")) {
+ rtfEmitter.endElement(inName);
+ endSpan(rtfEmitter);
+ }
} else {
formatTextCallout(rtfEmitter, callout);
}
boolean useGraphics = false;
boolean useUnicode = false;
- boolean useDingbats = false;
int unicodeStart = 49;
int unicodeMax = 0;
- int dingbatMax = 10;
+
+ String unicodeFont = "";
// Hardcoded defaults
defaultColumn = 60;
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");
unicodeStart = 0;
}
+ // Get the font
+ unicodeFont = getVariable(context, "callout.unicode.font");
+ if (unicodeFont == null) {
+ unicodeFont = "";
+ }
+
fCallout = new FormatUnicodeCallout(namePool,
+ unicodeFont,
unicodeStart,
unicodeMax,
foStylesheet);
- } else if (useDingbats) {
- fCallout = new FormatDingbatCallout(namePool,
- dingbatMax,
- foStylesheet);
} else {
fCallout = new FormatTextCallout(namePool, foStylesheet);
}
+++ /dev/null
-package com.nwalsh.saxon;
-
-import org.xml.sax.SAXException;
-import org.w3c.dom.*;
-
-import javax.xml.transform.TransformerException;
-
-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) {
- Element 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");
- }
- }
-}
public class FormatUnicodeCallout extends FormatCallout {
int unicodeMax = 0;
int unicodeStart = 0;
+ String unicodeFont = "";
- public FormatUnicodeCallout(NamePool nPool, int start, int max, boolean fo) {
+ public FormatUnicodeCallout(NamePool nPool,
+ String font,
+ int start,
+ int max,
+ boolean fo) {
super(nPool, fo);
+ unicodeFont = font;
unicodeMax = max;
unicodeStart = start;
}
public void formatCallout(Emitter rtfEmitter,
Callout callout) {
-
Element area = callout.getArea();
int num = callout.getCallout();
- String label = areaLabel(area);
+ String userLabel = areaLabel(area);
+ String label = "";
+
+ if (userLabel != null) {
+ label = userLabel;
+ }
try {
- if (label == null && num <= unicodeMax) {
+ if (userLabel == null && num <= unicodeMax) {
+ int inName = 0;
+ AttributeCollection inAttr = null;
+ int namespaces[] = new int[1];
+
+ if (!unicodeFont.equals("")) {
+ if (foStylesheet) {
+ inName = namePool.allocate("fo", foURI, "inline");
+ inAttr = new AttributeCollection(namePool);
+ inAttr.addAttribute("", "", "font-family", "CDATA", unicodeFont);
+ } else {
+ inName = namePool.allocate("", "", "font");
+ inAttr = new AttributeCollection(namePool);
+ inAttr.addAttribute("", "", "face", "CDATA", unicodeFont);
+ }
+
+ startSpan(rtfEmitter);
+ rtfEmitter.startElement(inName, inAttr, namespaces, 0);
+ }
+
char chars[] = new char[1];
chars[0] = (char) (unicodeStart + num - 1);
-
- startSpan(rtfEmitter);
rtfEmitter.characters(chars, 0, 1);
- endSpan(rtfEmitter);
+
+ if (!unicodeFont.equals("")) {
+ rtfEmitter.endElement(inName);
+ endSpan(rtfEmitter);
+ }
} else {
formatTextCallout(rtfEmitter, callout);
}
boolean useGraphics = false;
boolean useUnicode = false;
- boolean useDingbats = false;
int unicodeStart = 49;
int unicodeMax = 0;
- int dingbatMax = 10;
+
+ String unicodeFont = "";
// Hardcoded defaults
defaultColumn = 60;
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");
unicodeStart = 0;
}
+ // Get the font
+ unicodeFont = getVariable(context, "callout.unicode.font");
+ if (unicodeFont == null) {
+ unicodeFont = "";
+ }
+
fCallout = new FormatUnicodeCallout(namePool,
+ unicodeFont,
unicodeStart,
unicodeMax,
foStylesheet);
- } else if (useDingbats) {
- fCallout = new FormatDingbatCallout(namePool,
- dingbatMax,
- foStylesheet);
} else {
fCallout = new FormatTextCallout(namePool, foStylesheet);
}
<xsl:when test="$callout.unicode != 0
and $conum <= $callout.unicode.number.limit">
- <xsl:choose>
- <xsl:when test="$callout.unicode.start.character = 10102">
- <xsl:choose>
- <xsl:when test="$conum = 1">❶</xsl:when>
- <xsl:when test="$conum = 2">❷</xsl:when>
- <xsl:when test="$conum = 3">❸</xsl:when>
- <xsl:when test="$conum = 4">❹</xsl:when>
- <xsl:when test="$conum = 5">❺</xsl:when>
- <xsl:when test="$conum = 6">❻</xsl:when>
- <xsl:when test="$conum = 7">❼</xsl:when>
- <xsl:when test="$conum = 8">❽</xsl:when>
- <xsl:when test="$conum = 9">❾</xsl:when>
- <xsl:when test="$conum = 10">❿</xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message>
- <xsl:text>Don't know how to generate Unicode callouts </xsl:text>
- <xsl:text>when $callout.unicode.start.character is </xsl:text>
- <xsl:value-of select="$callout.unicode.start.character"/>
- </xsl:message>
- <fo:inline background-color="#404040"
- color="white"
- padding-top="0.1em"
- padding-bottom="0.1em"
- padding-start="0.2em"
- padding-end="0.2em"
- baseline-shift="0.1em"
- font-family="{$body.font.family}"
- font-weight="bold"
- font-size="75%">
- <xsl:value-of select="$conum"/>
- </fo:inline>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
-
- <!-- Pick callouts from Zapf Dingbats - max 10 -->
- <xsl:when test="$callout.dingbats != '0' and $conum <= 10">
- <fo:inline font-family="ZapfDingbats">
+ <xsl:variable name="comarkup">
<xsl:choose>
- <xsl:when test="$conum=1">❶</xsl:when>
- <xsl:when test="$conum=2">❷</xsl:when>
- <xsl:when test="$conum=3">❸</xsl:when>
- <xsl:when test="$conum=4">❹</xsl:when>
- <xsl:when test="$conum=5">❺</xsl:when>
- <xsl:when test="$conum=6">❻</xsl:when>
- <xsl:when test="$conum=7">❼</xsl:when>
- <xsl:when test="$conum=8">❽</xsl:when>
- <xsl:when test="$conum=9">❾</xsl:when>
- <xsl:when test="$conum=10">❿</xsl:when>
- <xsl:otherwise><!-- overflow -->
- <xsl:attribute name="color">red</xsl:attribute>
- <xsl:text>●</xsl:text>
+ <xsl:when test="$callout.unicode.start.character = 10102">
+ <xsl:choose>
+ <xsl:when test="$conum = 1">❶</xsl:when>
+ <xsl:when test="$conum = 2">❷</xsl:when>
+ <xsl:when test="$conum = 3">❸</xsl:when>
+ <xsl:when test="$conum = 4">❹</xsl:when>
+ <xsl:when test="$conum = 5">❺</xsl:when>
+ <xsl:when test="$conum = 6">❻</xsl:when>
+ <xsl:when test="$conum = 7">❼</xsl:when>
+ <xsl:when test="$conum = 8">❽</xsl:when>
+ <xsl:when test="$conum = 9">❾</xsl:when>
+ <xsl:when test="$conum = 10">❿</xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
<xsl:message>
- <xsl:text>A callout list contains more than 10 callouts;</xsl:text>
- <xsl:text> callout numbering truncated.</xsl:text>
+ <xsl:text>Don't know how to generate Unicode callouts </xsl:text>
+ <xsl:text>when $callout.unicode.start.character is </xsl:text>
+ <xsl:value-of select="$callout.unicode.start.character"/>
</xsl:message>
+ <fo:inline background-color="#404040"
+ color="white"
+ padding-top="0.1em"
+ padding-bottom="0.1em"
+ padding-start="0.2em"
+ padding-end="0.2em"
+ baseline-shift="0.1em"
+ font-family="{$body.font.family}"
+ font-weight="bold"
+ font-size="75%">
+ <xsl:value-of select="$conum"/>
+ </fo:inline>
</xsl:otherwise>
</xsl:choose>
- </fo:inline>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$callout.unicode.font != ''">
+ <fo:inline font-family="{$callout.unicode.font}">
+ <xsl:copy-of select="$comarkup"/>
+ </fo:inline>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$comarkup"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:when>
<!-- Most safe: draw a dark gray square with a white number inside -->
baseline-shift="0.1em"
font-family="{$body.font.family}"
font-weight="bold"
- font-size="75%"><xsl:value-of select="$conum"/></fo:inline>
+ font-size="75%">
+ <xsl:value-of select="$conum"/>
+ </fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</doc:param>
<!-- ==================================================================== -->
-<xsl:param name="callout.dingbats" select="'0'"/>
+<xsl:param name="callout.unicode.font" select="'ZapfDingbats'"/>
-<doc:param name="callout.dingbats" xmlns="">
-<refpurpose>Use Zapf Dingbats for callouts?</refpurpose>
+<doc:param name="callout.unicode.font" xmlns="">
+<refpurpose>Font to use for Unicode dingbats</refpurpose>
<refdescription>
-<para>If non-zero, callouts are presented with Zapf Dingbats.
+<para>The name of the font to specify around Unicode callout glyphs.
+If set to the empty string, no font change will occur.
</para>
</refdescription>
</doc:param>
</doc:param>
<!-- ==================================================================== -->
-<xsl:param name="callout.dingbats" select="'0'"/>
+<xsl:param name="callout.unicode.font" select="'ZapfDingbats'"/>
-<doc:param name="callout.dingbats" xmlns="">
-<refpurpose>Use Zapf Dingbats for callouts?</refpurpose>
+<doc:param name="callout.unicode.font" xmlns="">
+<refpurpose>Font to use for Unicode dingbats</refpurpose>
<refdescription>
-<para>If non-zero, callouts are presented with Zapf Dingbats.
+<para>The name of the font to specify around Unicode callout glyphs.
+If set to the empty string, no font change will occur.
</para>
</refdescription>
</doc:param>