aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/area
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/area')
-rw-r--r--src/java/org/apache/fop/area/AreaTreeParser.java40
-rw-r--r--src/java/org/apache/fop/area/DestinationData.java17
2 files changed, 43 insertions, 14 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";
}