pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1679010 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation: destination/PDPageDestination.java outline/PDOutlineItem.java
Date Tue, 12 May 2015 17:21:48 GMT
Author: tilman
Date: Tue May 12 17:21:48 2015
New Revision: 1679010

URL: http://svn.apache.org/r1679010
Log:
PDFBOX-2793: improve javadoc, comment; reformat one method

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java?rev=1679010&r1=1679009&r2=1679010&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java
Tue May 12 17:21:48 2015
@@ -93,7 +93,7 @@ public abstract class PDPageDestination
      * PDF). If this object is referencing by page number then this method will return that
number,
      * otherwise -1 will be returned.
      *
-     * @return The page number for this destination.
+     * @return The zero-based page number for this destination.
      */
     public int getPageNumber()
     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem.java?rev=1679010&r1=1679009&r2=1679010&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem.java
Tue May 12 17:21:48 2015
@@ -219,23 +219,24 @@ public final class PDOutlineItem extends
 
     /**
      * This method will attempt to find the page in this PDF document that this outline points
to.
-     * If the outline does not point to anything then this method will return null.  If the
outline
-     * is an action that is not a GoTo action then this methods will throw the OutlineNotLocationException
+     * If the outline does not point to anything then this method will return null. If the
outline
+     * is an action that is not a GoTo action then this method will also return null.
      *
      * @param doc The document to get the page from.
      *
-     * @return The page that this outline will go to when activated or null if it does not
point to anything.
+     * @return The page that this outline will go to when activated or null if it does not
point to
+     * anything.
      * @throws IOException If there is an error when trying to find the page.
      */
-    public PDPage findDestinationPage( PDDocument doc ) throws IOException
+    public PDPage findDestinationPage(PDDocument doc) throws IOException
     {
         PDDestination dest = getDestination();
-        if( dest == null )
+        if (dest == null)
         {
             PDAction outlineAction = getAction();
-            if( outlineAction instanceof PDActionGoTo )
+            if (outlineAction instanceof PDActionGoTo)
             {
-                dest = ((PDActionGoTo)outlineAction).getDestination();
+                dest = ((PDActionGoTo) outlineAction).getDestination();
             }
         }
         if (dest == null)
@@ -244,17 +245,17 @@ public final class PDOutlineItem extends
         }
 
         PDPageDestination pageDestination = null;
-        if( dest instanceof PDNamedDestination )
+        if (dest instanceof PDNamedDestination)
         {
             //if we have a named destination we need to lookup the PDPageDestination
-            PDNamedDestination namedDest = (PDNamedDestination)dest;
+            PDNamedDestination namedDest = (PDNamedDestination) dest;
             PDDocumentNameDictionary namesDict = doc.getDocumentCatalog().getNames();
-            if( namesDict != null )
+            if (namesDict != null)
             {
                 PDDestinationNameTreeNode destsTree = namesDict.getDests();
-                if( destsTree != null )
+                if (destsTree != null)
                 {
-                    pageDestination = (PDPageDestination)destsTree.getValue( namedDest.getNamedDestination()
);
+                    pageDestination = (PDPageDestination) destsTree.getValue(namedDest.getNamedDestination());
                 }
             }
             if (pageDestination == null)
@@ -272,20 +273,22 @@ public final class PDOutlineItem extends
                 return null;
             }
         }
-        else if( dest instanceof PDPageDestination)
+        else if (dest instanceof PDPageDestination)
         {
             pageDestination = (PDPageDestination) dest;
         }
         else
         {
-            throw new IOException( "Error: Unknown destination type " + dest );
+            throw new IOException("Error: Unknown destination type " + dest);
         }
 
         PDPage page = pageDestination.getPage();
-        if( page == null )
+        if (page == null)
         {
+            // Malformed PDF: local destinations must have a page object,
+            // not a page number, these are meant for remote destinations.
             int pageNumber = pageDestination.getPageNumber();
-            if( pageNumber != -1 )
+            if (pageNumber != -1)
             {
                 page = doc.getPage(pageNumber);
             }



Mime
View raw message