You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2008/08/12 17:30:55 UTC

svn commit: r685181 - in /xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java: META-INF/services/ org/apache/fop/render/intermediate/ org/apache/fop/render/intermediate/extensions/

Author: jeremias
Date: Tue Aug 12 08:30:54 2008
New Revision: 685181

URL: http://svn.apache.org/viewvc?rev=685181&view=rev
Log:
Widened "bookmarks" to "document-navigation" to fit named destination into this namespace as both bookmarks and named destinations share some action types.
Added support for named destinations (no implementation for PDF and no tests, yet).

Added:
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionConstants.java   (contents, props changed)
      - copied, changed from r685170, xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkExtensionConstants.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionHandlerFactory.java   (contents, props changed)
      - copied, changed from r685170, xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkExtensionHandlerFactory.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java   (with props)
Removed:
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkExtensionConstants.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkExtensionHandlerFactory.java
Modified:
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/META-INF/services/org.apache.fop.util.ContentHandlerFactory
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/Bookmark.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkTree.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/META-INF/services/org.apache.fop.util.ContentHandlerFactory
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/META-INF/services/org.apache.fop.util.ContentHandlerFactory?rev=685181&r1=685180&r2=685181&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/META-INF/services/org.apache.fop.util.ContentHandlerFactory (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/META-INF/services/org.apache.fop.util.ContentHandlerFactory Tue Aug 12 08:30:54 2008
@@ -1,4 +1,4 @@
 org.apache.fop.render.afp.extensions.AFPExtensionHandlerFactory
 org.apache.fop.render.ps.extensions.PSExtensionHandlerFactory
 org.apache.fop.fo.extensions.xmp.XMPContentHandlerFactory
-org.apache.fop.render.intermediate.extensions.BookmarkExtensionHandlerFactory
+org.apache.fop.render.intermediate.extensions.DocumentNavigationExtensionHandlerFactory

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java?rev=685181&r1=685180&r2=685181&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java Tue Aug 12 08:30:54 2008
@@ -83,6 +83,7 @@
 import org.apache.fop.render.intermediate.extensions.Bookmark;
 import org.apache.fop.render.intermediate.extensions.BookmarkTree;
 import org.apache.fop.render.intermediate.extensions.GoToXYAction;
+import org.apache.fop.render.intermediate.extensions.NamedDestination;
 import org.apache.fop.render.pdf.PDFEventProducer;
 
 /**
@@ -269,10 +270,12 @@
         PageViewport pv = dd.getPageViewport();
         if (pv != null) {
             GoToXYAction action = getGoToActionForID(targetID, pv.getPageIndex());
-            /*
-            pdfDoc.getFactory().makeDestination(
-                    dd.getIDRef(), gt.makeReference());
-                    */
+            NamedDestination namedDestination = new NamedDestination(targetID, action);
+            try {
+                painter.handleExtensionObject(namedDestination);
+            } catch (IFException ife) {
+                handleIFException(ife);
+            }
         } else {
             //Warning already issued by AreaTreeHandler (debug level is sufficient)
             log.debug("Unresolved destination item received: " + dd.getIDRef());

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/Bookmark.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/Bookmark.java?rev=685181&r1=685180&r2=685181&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/Bookmark.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/Bookmark.java Tue Aug 12 08:30:54 2008
@@ -34,7 +34,7 @@
 /**
  * This class is a bookmark element for use in the intermediate format.
  */
-public class Bookmark implements XMLizable, BookmarkExtensionConstants {
+public class Bookmark implements XMLizable, DocumentNavigationExtensionConstants {
 
     private String title;
     private boolean show;

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkTree.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkTree.java?rev=685181&r1=685180&r2=685181&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkTree.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkTree.java Tue Aug 12 08:30:54 2008
@@ -32,7 +32,7 @@
 /**
  * This class is the root of the bookmark tree for use in the intermediate format.
  */
-public class BookmarkTree implements XMLizable, BookmarkExtensionConstants {
+public class BookmarkTree implements XMLizable, DocumentNavigationExtensionConstants {
 
     private List bookmarks = new java.util.ArrayList();
 

Copied: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionConstants.java (from r685170, xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkExtensionConstants.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionConstants.java?p2=xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionConstants.java&p1=xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkExtensionConstants.java&r1=685170&r2=685181&rev=685181&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkExtensionConstants.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionConstants.java Tue Aug 12 08:30:54 2008
@@ -24,17 +24,21 @@
 import org.apache.fop.render.intermediate.IFConstants;
 
 /**
- * Constants for the IF bookmark extension.
+ * Constants for the IF document-level navigation extension.
  */
-public interface BookmarkExtensionConstants {
+public interface DocumentNavigationExtensionConstants {
 
     /** Namespace URI for the bookmark extension */
-    String NAMESPACE = IFConstants.NAMESPACE + "/bookmarks";
+    String NAMESPACE = IFConstants.NAMESPACE + "/document-navigation";
 
     /** the bookmark-tree element */
     QName BOOKMARK_TREE = new QName(NAMESPACE, "bookmark-tree");
     /** the bookmark element */
     QName BOOKMARK = new QName(NAMESPACE, "bookmark");
+
+    /** the named-destination element */
+    QName NAMED_DESTINATION = new QName(NAMESPACE, "named-destination");
+
     /** the goto-xy element */
     QName GOTO_XY = new QName(NAMESPACE, "goto-xy");
     /** the goto-uri element */

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionConstants.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionConstants.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionHandlerFactory.java (from r685170, xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkExtensionHandlerFactory.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionHandlerFactory.java?p2=xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionHandlerFactory.java&p1=xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkExtensionHandlerFactory.java&r1=685170&r2=685181&rev=685181&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/BookmarkExtensionHandlerFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionHandlerFactory.java Tue Aug 12 08:30:54 2008
@@ -35,13 +35,13 @@
 import org.apache.fop.util.XMLUtil;
 
 /**
- * Factory for the ContentHandler that handles the IF bookmarks namespace.
+ * Factory for the ContentHandler that handles the IF document navigation namespace.
  */
-public class BookmarkExtensionHandlerFactory
-        implements ContentHandlerFactory, BookmarkExtensionConstants {
+public class DocumentNavigationExtensionHandlerFactory
+        implements ContentHandlerFactory, DocumentNavigationExtensionConstants {
 
     /** Logger instance */
-    protected static Log log = LogFactory.getLog(BookmarkExtensionHandlerFactory.class);
+    protected static Log log = LogFactory.getLog(DocumentNavigationExtensionHandlerFactory.class);
 
     /** {@inheritDoc} */
     public String[] getSupportedNamespaces() {
@@ -50,17 +50,16 @@
 
     /** {@inheritDoc} */
     public ContentHandler createContentHandler() {
-        return new BookmarkExtensionHandler();
+        return new Handler();
     }
 
-    private static class BookmarkExtensionHandler extends DefaultHandler
+    private static class Handler extends DefaultHandler
                 implements ContentHandlerFactory.ObjectSource {
 
         private StringBuffer content = new StringBuffer();
-        //private Attributes lastAttributes;
         private Stack objectStack = new Stack();
-        private BookmarkTree bookmarkTree;
 
+        private Object objectBuilt;
         private ObjectBuiltListener listener;
 
         /** {@inheritDoc} */
@@ -69,10 +68,10 @@
             boolean handled = false;
             if (NAMESPACE.equals(uri)) {
                 if (BOOKMARK_TREE.getLocalName().equals(localName)) {
-                    if (bookmarkTree != null) {
+                    if (!objectStack.isEmpty()) {
                         throw new SAXException(localName + " must be the root element!");
                     }
-                    bookmarkTree = new BookmarkTree();
+                    BookmarkTree bookmarkTree = new BookmarkTree();
                     objectStack.push(bookmarkTree);
                 } else if (BOOKMARK.getLocalName().equals(localName)) {
                     String title = attributes.getValue("title");
@@ -91,6 +90,13 @@
                         ((Bookmark)o).addChildBookmark(b);
                     }
                     objectStack.push(b);
+                } else if (NAMED_DESTINATION.getLocalName().equals(localName)) {
+                    if (!objectStack.isEmpty()) {
+                        throw new SAXException(localName + " must be the root element!");
+                    }
+                    String name = attributes.getValue("name");
+                    NamedDestination dest = new NamedDestination(name, null);
+                    objectStack.push(dest);
                 } else if (GOTO_XY.getLocalName().equals(localName)) {
                     int pageIndex = XMLUtil.getAttributeAsInt(attributes, "page-index");
                     int x = XMLUtil.getAttributeAsInt(attributes, "x");
@@ -130,6 +136,10 @@
                     } else {
                         objectStack.pop();
                     }
+                } else if (NAMED_DESTINATION.getLocalName().equals(localName)) {
+                    AbstractAction action = (AbstractAction)objectStack.pop();
+                    NamedDestination dest = (NamedDestination)objectStack.peek();
+                    dest.setAction(action);
                 }
             }
             content.setLength(0); // Reset text buffer (see characters())
@@ -142,14 +152,16 @@
 
         /** {@inheritDoc} */
         public void endDocument() throws SAXException {
+            this.objectBuilt = objectStack.pop();
+            assert objectStack.isEmpty();
             if (listener != null) {
-                listener.notifyObjectBuilt(getObject());
+                listener.notifyObjectBuilt(this.objectBuilt);
             }
         }
 
         /** {@inheritDoc} */
         public Object getObject() {
-            return bookmarkTree;
+            return objectBuilt;
         }
 
         /** {@inheritDoc} */

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionHandlerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionHandlerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationExtensionHandlerFactory.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java?rev=685181&r1=685180&r2=685181&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java Tue Aug 12 08:30:54 2008
@@ -30,7 +30,7 @@
 /**
  * Action class which represents a "go-to" action to an absolute coordinate on a page.
  */
-public class GoToXYAction extends AbstractAction implements BookmarkExtensionConstants {
+public class GoToXYAction extends AbstractAction implements DocumentNavigationExtensionConstants {
 
     private int pageIndex;
     private Point targetLocation;

Added: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java?rev=685181&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java (added)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java Tue Aug 12 08:30:54 2008
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.intermediate.extensions;
+
+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.util.XMLConstants;
+
+/**
+ * This class is a named destination element for use in the intermediate format.
+ */
+public class NamedDestination implements XMLizable, DocumentNavigationExtensionConstants {
+
+    private String name;
+    private AbstractAction action;
+
+    /**
+     * Creates a new named destination.
+     * @param name the destination's name
+     * @param action the action performed when the destination is selected
+     */
+    public NamedDestination(String name, AbstractAction action) {
+        this.name = name;
+        this.action = action;
+    }
+
+    /**
+     * Returns the destination's name.
+     * @return the name
+     */
+    public String getName() {
+        return this.name;
+    }
+
+    /**
+     * Returns the action performed when the destination is selected.
+     * @return the action
+     */
+    public AbstractAction getAction() {
+        return this.action;
+    }
+
+    /**
+     * Sets the action performed when the destination is selected.
+     * @param action the action
+     */
+    public void setAction(AbstractAction action) {
+        this.action = action;
+    }
+
+    /** {@inheritDoc} */
+    public void toSAX(ContentHandler handler) throws SAXException {
+        AttributesImpl atts = new AttributesImpl();
+        atts.addAttribute(null, "name", "name", XMLConstants.CDATA, getName());
+        handler.startElement(NAMED_DESTINATION.getNamespaceURI(),
+                NAMED_DESTINATION.getLocalName(), NAMED_DESTINATION.getQName(), atts);
+        if (getAction() != null) {
+            getAction().toSAX(handler);
+        }
+        handler.endElement(NAMED_DESTINATION.getNamespaceURI(),
+                NAMED_DESTINATION.getLocalName(), NAMED_DESTINATION.getQName());
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java?rev=685181&r1=685180&r2=685181&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/extensions/URIAction.java Tue Aug 12 08:30:54 2008
@@ -29,7 +29,7 @@
  * Action class which represents a "URI" action, i.e. an action that will call up an external
  * resource identified by a URI.
  */
-public class URIAction extends AbstractAction implements BookmarkExtensionConstants {
+public class URIAction extends AbstractAction implements DocumentNavigationExtensionConstants {
 
     private String uri;
 



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org