]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
New class to support named destinations
authorJay Bryant <jbryant@apache.org>
Mon, 2 Apr 2007 14:53:03 +0000 (14:53 +0000)
committerJay Bryant <jbryant@apache.org>
Mon, 2 Apr 2007 14:53:03 +0000 (14:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@524800 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/area/DestinationData.java [new file with mode: 0644]

diff --git a/src/java/org/apache/fop/area/DestinationData.java b/src/java/org/apache/fop/area/DestinationData.java
new file mode 100644 (file)
index 0000000..920cd81
--- /dev/null
@@ -0,0 +1,112 @@
+package org.apache.fop.area;\r
+\r
+import java.util.List;\r
+\r
+import org.apache.fop.fo.extensions.destination.Destination;\r
+import org.apache.fop.area.PageViewport;\r
+/**\r
+ * An instance of this class is named destination from fox:destination\r
+ */\r
+public class DestinationData extends AbstractOffDocumentItem implements Resolvable {\r
+\r
+    // PDFReference (object reference) for this destination\r
+    private String goToReference;\r
+\r
+    // ID Reference for this bookmark\r
+    private String idRef;\r
+\r
+    // String Array to satisfy getIDRefs method\r
+    private String[] idRefs;\r
+\r
+    // PageViewport that the idRef item refers to\r
+    private PageViewport pageRef = null;\r
+\r
+    /**\r
+     * Create a new pdf destination data object.\r
+     * This is used by the destination to create a data object\r
+     * with a idref.  During processing, this idref will be\r
+     * subsequently resolved to a particular PageViewport.\r
+     *\r
+     * @param destination the fo:bookmark object\r
+     */\r
+    public DestinationData(Destination destination) {\r
+        idRef = destination.getInternalDestination();\r
+        idRefs = new String[] {idRef};\r
+    }\r
+\r
+    /**\r
+     * Get the idref for this destination\r
+     *\r
+     * @return the idref for the destination\r
+     */\r
+    public String getIDRef() {\r
+        return idRef;\r
+    }\r
+\r
+    /**\r
+     * @see org.apache.fop.area.Resolvable#getIDRefs()\r
+     */\r
+    public String[] getIDRefs() {\r
+        return idRefs;\r
+    }\r
+\r
+    /**\r
+     * Get the PageViewport object that this destination refers to\r
+     *\r
+     * @return the PageViewport that this destination points to\r
+     */\r
+    public PageViewport getPageViewport() {\r
+        return pageRef;\r
+    }\r
+\r
+    /**\r
+     * Set the GoToReference for this destination\r
+     *\r
+     * @param goToReference the GoToReference to associate with this destination\r
+     */\r
+    public void setGoToReference(String goToReference) {\r
+        this.goToReference = goToReference;\r
+    }\r
+\r
+    /**\r
+     * Get the GoToReference for this destination\r
+     *\r
+     * @return the GoToReference associated with this destination\r
+     */\r
+    public String getGoToReference() {\r
+        return goToReference;\r
+    }\r
+\r
+    /**\r
+     * Check if this resolvable object has been resolved.\r
+     * For now, just return true.\r
+     * To do: Find a way to determine whether the destination has been resolved.\r
+     *\r
+     * @return true if this object has been resolved\r
+     */\r
+    public boolean isResolved() {\r
+        return true;\r
+    }\r
+\r
+    /**\r
+     * Resolves the idref of this object by getting the PageViewport\r
+     * object that corresponds to the IDRef\r
+     *\r
+     * @see org.apache.fop.area.Resolvable#resolveIDRef(String, List)\r
+     * @todo check to make sure it works if multiple bookmark-items\r
+     * have the same idref\r
+     */\r
+    public void resolveIDRef(String id, List pages) {\r
+        pageRef = (PageViewport) pages.get(0);\r
+        // TODO get rect area of id on page\r
+    }\r
+\r
+    /**\r
+     * @see org.apache.fop.area.OffDocumentItem#getName()\r
+     */\r
+    public String getName() {\r
+        return "Destination";\r
+    }\r
+\r
+}\r
+\r