From: Glenn Adams Date: Sat, 7 Apr 2012 04:04:14 +0000 (+0000) Subject: Bugzilla #51836: Throw IFException instead of NPE if navigation target (page referenc... X-Git-Tag: fop-1_1rc1old~77 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=82712c6d2d8fca7b78296be29dedf7627ca2ed50;p=xmlgraphics-fop.git Bugzilla #51836: Throw IFException instead of NPE if navigation target (page reference) doesn't exist. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1310666 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java b/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java index 2236778b5..af49fea4c 100644 --- a/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java @@ -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); + } } } diff --git a/status.xml b/status.xml index 0fd5d5a6c..ef2fcc3de 100644 --- a/status.xml +++ b/status.xml @@ -62,6 +62,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Throw IFException instead of NPE if navigation target (page reference) doesn't exist. + Fixed memory waste in traits map.