Author: gadams
Date: Sat Apr  7 04:04:14 2012
New Revision: 1310666

URL: http://svn.apache.org/viewvc?rev=1310666&view=rev
Log:
Bugzilla #51836: Throw IFException instead of NPE if navigation target (page 
reference) doesn't exist.

Modified:
    
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java
    xmlgraphics/fop/trunk/status.xml

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java?rev=1310666&r1=1310665&r2=1310666&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java
 (original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java
 Sat Apr  7 04:04:14 2012
@@ -82,7 +82,7 @@ public class PDFDocumentNavigationHandle
         }
     }
 
-    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 PDFDocumentNavigationHandle
         }
     }
 
-    private PDFAction getAction(AbstractAction action) {
+    private PDFAction getAction(AbstractAction action) throws IFException {
         if (action == null) {
             return null;
         }
@@ -181,21 +181,27 @@ public class PDFDocumentNavigationHandle
         }
     }
 
-    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);
+        }
     }
 
 }

Modified: xmlgraphics/fop/trunk/status.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1310666&r1=1310665&r2=1310666&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Sat Apr  7 04:04:14 2012
@@ -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>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to