Esempio n. 1
0
 private void closeOpenElements(Emitter rtfEmitter) throws TransformerException {
   // Close all the open elements...
   tempStack = new Stack();
   while (!elementStack.empty()) {
     StartElementInfo elem = (StartElementInfo) elementStack.pop();
     rtfEmitter.endElement(elem.getNameCode());
     tempStack.push(elem);
   }
 }
  public void formatCallout(Emitter rtfEmitter, Callout callout) {
    Element area = callout.getArea();
    int num = callout.getCallout();
    String userLabel = areaLabel(area);
    String label = "(" + num + ")";

    if (userLabel != null) {
      label = userLabel;
    }

    try {
      if (userLabel == null && num <= graphicsMax) {
        int imgName = 0;
        AttributeCollection imgAttr = null;
        int namespaces[] = new int[1];

        if (foStylesheet) {
          imgName = namePool.allocate("fo", foURI, "external-graphic");
          imgAttr = new AttributeCollection(namePool);
          imgAttr.addAttribute("", "", "src", "CDATA", graphicsPath + num + graphicsExt);
        } else {
          imgName = namePool.allocate("", "", "img");
          imgAttr = new AttributeCollection(namePool);
          imgAttr.addAttribute("", "", "src", "CDATA", graphicsPath + num + graphicsExt);
          imgAttr.addAttribute("", "", "alt", "CDATA", label);
        }

        startSpan(rtfEmitter);
        rtfEmitter.startElement(imgName, imgAttr, namespaces, 0);
        rtfEmitter.endElement(imgName);
        endSpan(rtfEmitter);
      } else {
        formatTextCallout(rtfEmitter, callout);
      }
    } catch (TransformerException e) {
      System.out.println("Transformer Exception in graphic formatCallout");
    }
  }