/** * We only alter the handling of some endtags. * * @param uri * the uri of the namespace * @param lname * the local name of the tag * @param name * the name of the tag */ public void endElement(String uri, String lname, String name) { if (myTags.containsKey(name)) { XmlPeer peer = (XmlPeer) myTags.get(name); // we don't want the document to be close // because we are going to add a page after the xml is parsed if (isDocumentRoot(peer.getTag())) { return; } handleEndingTags(peer.getTag()); // we want to add a paragraph after the speaker chunk if ("SPEAKER".equals(name)) { try { TextElementArray previous = (TextElementArray) stack .pop(); previous.add(new Paragraph(16)); stack.push(previous); } catch (EmptyStackException ese) { } } } else { handleEndingTags(name); } }
/** * We only alter the handling of some endtags. * * @param uri * the uri of the namespace * @param lname * the local name of the tag * @param name * the name of the tag */ public void endElement(String uri, String lname, String name) { if (myTags.containsKey(name)) { XmlPeer peer = (XmlPeer) myTags.get(name); // we don't want the document to be close // because we are going to add a page after the xml is parsed if (isDocumentRoot(peer.getTag())) { return; } handleEndingTags(peer.getTag()); // we want to add a paragraph after the speaker chunk if ("SPEAKER".equals(name)) { try { TextElementArray previous = (TextElementArray) stack.pop(); previous.add(new Paragraph(16)); stack.push(previous); } catch (EmptyStackException ese) { } } } else { handleEndingTags(name); } }
protected void addImage(Image img) throws EmptyStackException { // if there is an element on the stack... Object current = stack.pop(); // ...and it's a Chapter or a Section, the Image can be // added directly if (current instanceof Chapter || current instanceof Section || current instanceof Cell) { ((TextElementArray) current).add(img); stack.push(current); return; } // ...if not, we need to to a lot of stuff else { Stack newStack = new Stack(); while (!(current instanceof Chapter || current instanceof Section || current instanceof Cell)) { newStack.push(current); if (current instanceof Anchor) { img.setAnnotation(new Annotation(0, 0, 0, 0, ((Anchor) current).getReference())); } current = stack.pop(); } ((TextElementArray) current).add(img); stack.push(current); while (!newStack.empty()) { stack.push(newStack.pop()); } return; } }