diff options
Diffstat (limited to 'src/java/org/apache')
7 files changed, 78 insertions, 35 deletions
diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java index aa499338b..b4a804712 100644 --- a/src/java/org/apache/fop/area/AreaTreeParser.java +++ b/src/java/org/apache/fop/area/AreaTreeParser.java @@ -36,16 +36,25 @@ import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; + +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.area.Trait.InternalLink; import org.apache.fop.area.Trait.Background; -import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.area.Trait.InternalLink; import org.apache.fop.area.inline.AbstractTextArea; import org.apache.fop.area.inline.Character; import org.apache.fop.area.inline.ForeignObject; import org.apache.fop.area.inline.Image; +import org.apache.fop.area.inline.InlineArea; import org.apache.fop.area.inline.InlineBlockParent; import org.apache.fop.area.inline.InlineParent; import org.apache.fop.area.inline.Leader; @@ -68,12 +77,6 @@ import org.apache.fop.util.ContentHandlerFactory; import org.apache.fop.util.ContentHandlerFactoryRegistry; import org.apache.fop.util.DefaultErrorListener; import org.apache.fop.util.QName; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; /** * This is a parser for the area tree XML (intermediate format) which is used to reread an area @@ -179,6 +182,7 @@ public class AreaTreeParser { makers.put("foreignObject", new ForeignObjectMaker()); makers.put("bookmarkTree", new BookmarkTreeMaker()); makers.put("bookmark", new BookmarkMaker()); + makers.put("destination", new DestinationMaker()); } private static Rectangle2D parseRect(String rect) { @@ -922,6 +926,26 @@ public class AreaTreeParser { } } + private class DestinationMaker extends AbstractMaker { + + public void startElement(Attributes attributes) { + String[] linkdata + = InternalLink.parseXMLAttribute(lastAttributes.getValue("internal-link")); + PageViewport pv = (PageViewport) pageViewportsByKey.get(linkdata[0]); + DestinationData dest = new DestinationData(linkdata[1]); + List pages = new java.util.ArrayList(); + pages.add(pv); + dest.resolveIDRef(linkdata[1], pages); + areaStack.push(dest); + } + + public void endElement() { + Object tos = areaStack.pop(); + assertObjectOfClass(tos, DestinationData.class); + treeModel.handleOffDocumentItem((DestinationData) tos); + } + } + // ==================================================================== diff --git a/src/java/org/apache/fop/area/DestinationData.java b/src/java/org/apache/fop/area/DestinationData.java index b23605972..2cff02ef4 100644 --- a/src/java/org/apache/fop/area/DestinationData.java +++ b/src/java/org/apache/fop/area/DestinationData.java @@ -22,7 +22,6 @@ package org.apache.fop.area; import java.util.List; import org.apache.fop.fo.extensions.destination.Destination; -import org.apache.fop.area.PageViewport; /** * An instance of this class is named destination from fox:destination */ @@ -46,11 +45,19 @@ public class DestinationData extends AbstractOffDocumentItem implements Resolvab * @param destination the fo:bookmark object */ public DestinationData(Destination destination) { - idRef = destination.getInternalDestination(); - idRefs = new String[] {idRef}; + this(destination.getInternalDestination()); } /** + * Create a new named destination. + * @param idRef the id reference of the destination + */ + public DestinationData(String idRef) { + this.idRef = idRef; + this.idRefs = new String[] {idRef}; + } + + /** * Get the idref for this destination * * @return the idref for the destination @@ -99,9 +106,7 @@ public class DestinationData extends AbstractOffDocumentItem implements Resolvab // TODO get rect area of id on page } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String getName() { return "Destination"; } diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java index ca568028e..91ab2dfa5 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java @@ -21,12 +21,14 @@ package org.apache.fop.render.afp.extensions; import java.io.Serializable; -import org.apache.fop.fo.extensions.ExtensionAttachment; -import org.apache.fop.util.XMLizable; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; +import org.apache.xmlgraphics.util.XMLizable; + +import org.apache.fop.fo.extensions.ExtensionAttachment; + /** * This is the pass-through value object for the PostScript extension. */ diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java index 0fb623bdc..80a2aeee3 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java @@ -19,12 +19,14 @@ package org.apache.fop.render.ps.extensions;
-import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.apache.fop.util.XMLizable;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
+import org.apache.xmlgraphics.util.XMLizable;
+
+import org.apache.fop.fo.extensions.ExtensionAttachment;
+
/**
* This is the pass-through value object for the PostScript extension.
*/
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java index 5684ba6a3..da84f97a2 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java @@ -96,7 +96,7 @@ public class PSSetPageDevice extends PSExtensionAttachment { * Generates SAX events representing the object's state.
* @param handler ContentHandler instance to send the SAX events to
* @throws SAXException if there's a problem generating the SAX events
- * @see org.apache.fop.util.XMLizable#toSAX(org.xml.sax.ContentHandler)
+ * @see org.apache.xmlgraphics.util.XMLizable#toSAX(org.xml.sax.ContentHandler)
*/
public void toSAX(ContentHandler handler) throws SAXException {
AttributesImpl atts = new AttributesImpl();
diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index b969afac1..213cba58d 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -41,7 +41,8 @@ import org.xml.sax.SAXException; import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.AttributesImpl; -import org.apache.fop.util.QName; +import org.apache.xmlgraphics.util.XMLizable; + import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; @@ -51,21 +52,22 @@ import org.apache.fop.area.BeforeFloat; import org.apache.fop.area.Block; import org.apache.fop.area.BlockViewport; import org.apache.fop.area.BodyRegion; +import org.apache.fop.area.BookmarkData; import org.apache.fop.area.CTM; +import org.apache.fop.area.DestinationData; import org.apache.fop.area.Footnote; import org.apache.fop.area.LineArea; import org.apache.fop.area.MainReference; import org.apache.fop.area.NormalFlow; import org.apache.fop.area.OffDocumentExtensionAttachment; import org.apache.fop.area.OffDocumentItem; -import org.apache.fop.area.BookmarkData; import org.apache.fop.area.PageViewport; import org.apache.fop.area.RegionReference; import org.apache.fop.area.RegionViewport; import org.apache.fop.area.Span; import org.apache.fop.area.Trait; -import org.apache.fop.area.Trait.InternalLink; import org.apache.fop.area.Trait.Background; +import org.apache.fop.area.Trait.InternalLink; import org.apache.fop.area.inline.Container; import org.apache.fop.area.inline.ForeignObject; import org.apache.fop.area.inline.Image; @@ -87,7 +89,7 @@ import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; import org.apache.fop.render.XMLHandler; import org.apache.fop.util.ColorUtil; -import org.apache.fop.util.XMLizable; +import org.apache.fop.util.QName; /** * Renderer that renders areas to XML for debugging purposes. @@ -419,6 +421,8 @@ public class XMLRenderer extends PrintRenderer { public void processOffDocumentItem(OffDocumentItem oDI) { if (oDI instanceof BookmarkData) { renderBookmarkTree((BookmarkData) oDI); + } else if (oDI instanceof DestinationData) { + renderDestination((DestinationData) oDI); } else if (oDI instanceof OffDocumentExtensionAttachment) { ExtensionAttachment attachment = ((OffDocumentExtensionAttachment)oDI).getAttachment(); if (extensionAttachments == null) { @@ -466,8 +470,23 @@ public class XMLRenderer extends PrintRenderer { } /** - * {@inheritDoc} + * Renders a DestinationData object (named destination) + * @param destination the destination object */ + protected void renderDestination(DestinationData destination) { + if (destination.getWhenToProcess() == OffDocumentItem.END_OF_DOC) { + endPageSequence(); + } + atts.clear(); + PageViewport pv = destination.getPageViewport(); + String pvKey = pv == null ? null : pv.getKey(); + addAttribute("internal-link", + InternalLink.makeXMLAttribute(pvKey, destination.getIDRef())); + startElement("destination", atts); + endElement("destination"); + } + + /** {@inheritDoc} */ public void startRenderer(OutputStream outputStream) throws IOException { log.debug("Rendering areas to Area Tree XML"); diff --git a/src/java/org/apache/fop/util/XMLizable.java b/src/java/org/apache/fop/util/XMLizable.java index c1213638b..a16131989 100644 --- a/src/java/org/apache/fop/util/XMLizable.java +++ b/src/java/org/apache/fop/util/XMLizable.java @@ -25,20 +25,11 @@ package org.apache.fop.util; * src/java/org/apache/excalibur/xml/sax/XMLizable.java */ -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - /** * This interface can be implemented by classes willing to provide an XML representation * of their current state as SAX events. + * @deprecated Use the interface in Apache XML Graphics Commons instead. */ -public interface XMLizable { - - /** - * Generates SAX events representing the object's state. - * @param handler ContentHandler instance to send the SAX events to - * @throws SAXException if there's a problem generating the SAX events - */ - void toSAX(ContentHandler handler) throws SAXException; +public interface XMLizable extends org.apache.xmlgraphics.util.XMLizable { } |