Beispiel #1
0
  private void openClosedElements(Emitter rtfEmitter) throws TransformerException {
    // Now "reopen" the elements that we closed...
    while (!tempStack.empty()) {
      StartElementInfo elem = (StartElementInfo) tempStack.pop();
      AttributeCollection attr = (AttributeCollection) elem.getAttributes();
      AttributeCollection newAttr = new AttributeCollection(namePool);

      for (int acount = 0; acount < attr.getLength(); acount++) {
        String localName = attr.getLocalName(acount);
        int nameCode = attr.getNameCode(acount);
        String type = attr.getType(acount);
        String value = attr.getValue(acount);
        String uri = attr.getURI(acount);
        String prefix = "";

        if (localName.indexOf(':') > 0) {
          prefix = localName.substring(0, localName.indexOf(':'));
          localName = localName.substring(localName.indexOf(':') + 1);
        }

        if (uri.equals("")
            && ((foStylesheet && localName.equals("id"))
                || (!foStylesheet && (localName.equals("id") || localName.equals("name"))))) {
          // skip this attribute
        } else {
          newAttr.addAttribute(prefix, uri, localName, type, value);
        }
      }

      rtfEmitter.startElement(elem.getNameCode(), newAttr, elem.getNamespaces(), elem.getNSCount());

      elementStack.push(elem);
    }
  }
Beispiel #2
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");
    }
  }