return label;
}
- public void startSpan(Emitter rtf)
+ // Get ID (used for xrefs)
+ public String areaID(Element area) {
+ String id = null;
+
+ if (area.hasAttribute("id")) {
+ id = area.getAttribute("id");
+ }
+
+ else {
+ if (area.hasAttribute("xml:id")) {
+ id = area.getAttribute("xml:id");
+ }
+
+ else {
+ id = "";
+ }
+ }
+ //System.out.println(id);
+ return id;
+ }
+
+
+ public void startSpan(Emitter rtf, String id)
throws TransformerException {
- // no point in doing this for FO, right?
+
if (!foStylesheet && namePool != null) {
int spanName = namePool.allocate("", "", "span");
AttributeCollection spanAttr = new AttributeCollection(namePool);
int namespaces[] = new int[1];
spanAttr.addAttribute("", "", "class", "CDATA", "co");
+ spanAttr.addAttribute("", "", "id", "CDATA", id);
rtf.startElement(spanName, spanAttr, namespaces, 0);
}
+
}
public void endSpan(Emitter rtf)
throws TransformerException {
- // no point in doing this for FO, right?
+
if (!foStylesheet && namePool != null) {
int spanName = namePool.allocate("", "", "span");
rtf.endElement(spanName);
Element area = callout.getArea();
int num = callout.getCallout();
String userLabel = areaLabel(area);
+ String id = areaID(area);
String label = "(" + num + ")";
if (userLabel != null) {
char chars[] = label.toCharArray();
try {
- startSpan(rtfEmitter);
+ startSpan(rtfEmitter, id);
+
+ if (foStylesheet) {
+ int inlineName = namePool.allocate("fo", foURI, "inline");
+ AttributeCollection inlineAttr = new AttributeCollection(namePool);
+ int namespaces[] = new int[1];
+ inlineAttr.addAttribute("", "", "id", "CDATA", id);
+ rtfEmitter.startElement(inlineName, inlineAttr, namespaces, 0);
+ }
rtfEmitter.characters(chars, 0, label.length());
endSpan(rtfEmitter);
+
+ if (foStylesheet) {
+ int inlineName = namePool.allocate("fo", foURI, "inline");
+ rtfEmitter.endElement(inlineName);
+ }
+
} catch (TransformerException e) {
System.out.println("Transformer Exception in formatTextCallout");
}
}
-
+
public abstract void formatCallout(Emitter rtfEmitter,
Callout callout);
}
int num = callout.getCallout();
String userLabel = areaLabel(area);
String label = "(" + num + ")";
+ String id = areaID(area);
if (userLabel != null) {
label = userLabel;
imgAttr = new AttributeCollection(namePool);
imgAttr.addAttribute("", "", "src", "CDATA", "url(" +
graphicsPath + num + graphicsExt + ")");
+ imgAttr.addAttribute("", "", "id", "CDATA", id);
+ // HTML
} else {
imgName = namePool.allocate("", "", "img");
imgAttr = new AttributeCollection(namePool);
imgAttr.addAttribute("", "", "src", "CDATA",
graphicsPath + num + graphicsExt);
imgAttr.addAttribute("", "", "alt", "CDATA", label);
+
}
- startSpan(rtfEmitter);
+ startSpan(rtfEmitter, id);
rtfEmitter.startElement(imgName, imgAttr, namespaces, 0);
rtfEmitter.endElement(imgName);
endSpan(rtfEmitter);
int num = callout.getCallout();
String userLabel = areaLabel(area);
String label = "";
-
+ String id = areaID(area);
+
if (userLabel != null) {
label = userLabel;
}
inName = namePool.allocate("fo", foURI, "inline");
inAttr = new AttributeCollection(namePool);
inAttr.addAttribute("", "", "font-family", "CDATA", unicodeFont);
+ inAttr.addAttribute("", "", "id", "ID", id);
+
} else {
inName = namePool.allocate("", "", "font");
inAttr = new AttributeCollection(namePool);
inAttr.addAttribute("", "", "face", "CDATA", unicodeFont);
+ inAttr.addAttribute("", "", "id", "ID", id);
}
- startSpan(rtfEmitter);
+ startSpan(rtfEmitter, id);
rtfEmitter.startElement(inName, inAttr, namespaces, 0);
}
return label;
}
- public void startSpan(DOMBuilder rtf)
+
+// Get area ID (used for xrefs to callouts)
+ public String areaID(Element area) {
+ String id = null;
+
+ if (area.hasAttribute("id")) {
+ id = area.getAttribute("id");
+ }
+
+ else {
+ if (area.hasAttribute("xml:id")) {
+ id = area.getAttribute("xml:id");
+ }
+
+ else {
+ id = "";
+ }
+ }
+ //System.out.println(id);
+ return id;
+ }
+
+
+ public void startSpan(DOMBuilder rtf, String id)
throws SAXException {
- // no point in doing this for FO, right?
+
if (!stylesheetFO) {
AttributesImpl spanAttr = new AttributesImpl();
spanAttr.addAttribute("", "class", "class", "CDATA", "co");
+ spanAttr.addAttribute("", "id", "id", "ID", id);
rtf.startElement("", "span", "span", spanAttr);
}
}
-
+
public void endSpan(DOMBuilder rtf)
throws SAXException {
- // no point in doing this for FO, right?
+
if (!stylesheetFO) {
rtf.endElement("", "span", "span");
}
label = userLabel;
}
+ String id = areaID(area);
char chars[] = label.toCharArray();
try {
- startSpan(rtf);
+ startSpan(rtf, id);
+ if (stylesheetFO) {
+ AttributesImpl spanAttr = new AttributesImpl();
+ spanAttr.addAttribute("", "id", "id", "ID", id);
+ rtf.startElement(foURI, "inline", "fo:inline", spanAttr);
+ }
+
rtf.characters(chars, 0, label.length());
+ if (stylesheetFO) {
+ rtf.endElement(foURI, "inline", "fo:inline");
+ }
endSpan(rtf);
} catch (SAXException e) {
System.out.println("SAX Exception in text formatCallout");
"ZapfDingbats");
}
- startSpan(rtf);
+ startSpan(rtf, ""); // empty dummy id
rtf.startElement(ns, imgName, prefix+imgName, imgAttr);
char chars[] = new char[1];
Element area = callout.getArea();
int num = callout.getCallout();
String label = areaLabel(area);
+ String id = areaID(area);
try {
if (label == null && num <= graphicsMax) {
imgName = "external-graphic";
imgAttr.addAttribute("", "src", "src", "CDATA", "url(" +
graphicsPath + num + graphicsExt + ")");
+ imgAttr.addAttribute("", "id", "id", "ID", id);
} else {
ns = "";
imgAttr.addAttribute("", "src", "src", "CDATA",
graphicsPath + num + graphicsExt);
imgAttr.addAttribute("", "alt", "alt", "CDATA", label);
+ imgAttr.addAttribute("", "id", "id", "ID", id);
}
- startSpan(rtf);
+ startSpan(rtf, id);
rtf.startElement(ns, imgName, prefix+imgName, imgAttr);
rtf.endElement(ns, imgName, prefix+imgName);
endSpan(rtf);
Element area = callout.getArea();
int num = callout.getCallout();
String label = areaLabel(area);
+ String id = areaID(area);
try {
if (label == null && num <= unicodeMax) {
prefix = "fo:";
inName = "inline";
inAttr.addAttribute("", "", "font-family", "CDATA", unicodeFont);
+ inAttr.addAttribute("", "", "id", "ID", id);
} else {
inName = "font";
inAttr.addAttribute("", "", "face", "CDATA", unicodeFont);
+ inAttr.addAttribute("", "", "id", "ID", id);
}
}
char chars[] = new char[1];
chars[0] = (char) (unicodeStart + num - 1);
- startSpan(rtf);
+ startSpan(rtf, id);
if (!unicodeFont.equals("")) {
rtf.startElement(ns, inName, prefix+inName, inAttr);
}