aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorGlenn Adams <gadams@apache.org>2012-04-07 04:04:14 +0000
committerGlenn Adams <gadams@apache.org>2012-04-07 04:04:14 +0000
commit82712c6d2d8fca7b78296be29dedf7627ca2ed50 (patch)
tree1deb145cec64b17eb1e83cc6cb1da9e380c3097d /src/java
parent6221c9e6f83a528760a4e2769190089de5ab7226 (diff)
downloadxmlgraphics-fop-82712c6d2d8fca7b78296be29dedf7627ca2ed50.tar.gz
xmlgraphics-fop-82712c6d2d8fca7b78296be29dedf7627ca2ed50.zip
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
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java38
1 files changed, 22 insertions, 16 deletions
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);
+ }
}
}