]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla #51836: Throw IFException instead of NPE if navigation target (page referenc...
authorGlenn Adams <gadams@apache.org>
Sat, 7 Apr 2012 04:04:14 +0000 (04:04 +0000)
committerGlenn Adams <gadams@apache.org>
Sat, 7 Apr 2012 04:04:14 +0000 (04:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1310666 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java
status.xml

index 2236778b5ccaf8e4e280d5d95e080589811eeca1..af49fea4ccf68a59268a215b90f28512383bcbc4 100644 (file)
@@ -82,7 +82,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler
         }
     }
 
-    private void renderBookmark(Bookmark bookmark, PDFOutline parent) {
+    private void renderBookmark(Bookmark bookmark, PDFOutline parent) throws IFException {
         if (parent == null) {
             parent = getPDFDoc().getOutlineRoot();
         }
@@ -141,7 +141,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler
         }
     }
 
-    private PDFAction getAction(AbstractAction action) {
+    private PDFAction getAction(AbstractAction action) throws IFException {
         if (action == null) {
             return null;
         }
@@ -181,21 +181,27 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler
         }
     }
 
-    private void updateTargetLocation(PDFGoTo pdfGoTo, GoToXYAction action) {
+    private void updateTargetLocation(PDFGoTo pdfGoTo, GoToXYAction action)
+      throws IFException {
         PageReference pageRef = this.documentHandler.getPageReference(action.getPageIndex());
-        //Convert target location from millipoints to points and adjust for different
-        //page origin
-        Point2D p2d = null;
-        p2d = new Point2D.Double(
-                action.getTargetLocation().x / 1000.0,
-                (pageRef.getPageDimension().height - action.getTargetLocation().y) / 1000.0);
-        String pdfPageRef = pageRef.getPageRef();
-        pdfGoTo.setPageReference(pdfPageRef);
-        pdfGoTo.setPosition(p2d);
-
-        //Queue this object now that it's complete
-        getPDFDoc().addObject(pdfGoTo);
-        this.completeActions.put(action.getID(), pdfGoTo);
+        if ( pageRef == null ) {
+            throw new
+                IFException("Can't resolve page reference @ index: " + action.getPageIndex(), null);
+        } else {
+            //Convert target location from millipoints to points and adjust for different
+            //page origin
+            Point2D p2d = null;
+            p2d = new Point2D.Double(
+                    action.getTargetLocation().x / 1000.0,
+                    (pageRef.getPageDimension().height - action.getTargetLocation().y) / 1000.0);
+            String pdfPageRef = pageRef.getPageRef();
+            pdfGoTo.setPageReference(pdfPageRef);
+            pdfGoTo.setPosition(p2d);
+
+            //Queue this object now that it's complete
+            getPDFDoc().addObject(pdfGoTo);
+            this.completeActions.put(action.getID(), pdfGoTo);
+        }
     }
 
 }
index 0fd5d5a6c6578f0a6bc809cc248bb6ffb5a6cf1a..ef2fcc3deab54a3fe00a6d2175266bae4179a4ed 100644 (file)
@@ -62,6 +62,9 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Code" dev="GA" type="fix" fixes-bug="51836" due-to="Melanie Drake">
+        Throw IFException instead of NPE if navigation target (page reference) doesn't exist.
+      </action>
       <action context="Code" dev="GA" type="fix" fixes-bug="51808" due-to="Sergey Vladimirov">
         Fixed memory waste in traits map.
       </action>