You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2015/05/14 11:45:15 UTC

svn commit: r1679331 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem.java

Author: tilman
Date: Thu May 14 09:45:14 2015
New Revision: 1679331

URL: http://svn.apache.org/r1679331
Log:
PDFBOX-2793: split long method

Modified:
    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/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=1679331&r1=1679330&r2=1679331&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 Thu May 14 09:45:14 2015
@@ -247,27 +247,7 @@ public final class PDOutlineItem extends
         PDPageDestination pageDestination = null;
         if (dest instanceof PDNamedDestination)
         {
-            //if we have a named destination we need to lookup the PDPageDestination
-            PDNamedDestination namedDest = (PDNamedDestination) dest;
-            PDDocumentNameDictionary namesDict = doc.getDocumentCatalog().getNames();
-            if (namesDict != null)
-            {
-                PDDestinationNameTreeNode destsTree = namesDict.getDests();
-                if (destsTree != null)
-                {
-                    pageDestination = (PDPageDestination) destsTree.getValue(namedDest.getNamedDestination());
-                }
-            }
-            if (pageDestination == null)
-            {
-                // Look up /Dests dictionary from catalog
-                PDDocumentNameDestinationDictionary nameDestDict = doc.getDocumentCatalog().getDests();
-                if (nameDestDict != null)
-                {
-                    String name = namedDest.getNamedDestination();
-                    pageDestination = (PDPageDestination) nameDestDict.getDestination(name);
-                }
-            }
+            pageDestination = findNamedDestinationPage((PDNamedDestination) dest, doc);
             if (pageDestination == null)
             {
                 return null;
@@ -293,10 +273,36 @@ public final class PDOutlineItem extends
                 page = doc.getPage(pageNumber);
             }
         }
-
         return page;
     }
 
+    //if we have a named destination we need to lookup the PDPageDestination
+    private PDPageDestination findNamedDestinationPage(PDNamedDestination namedDest, PDDocument doc)
+            throws IOException
+    {
+        PDPageDestination pageDestination = null;
+        PDDocumentNameDictionary namesDict = doc.getDocumentCatalog().getNames();
+        if (namesDict != null)
+        {
+            PDDestinationNameTreeNode destsTree = namesDict.getDests();
+            if (destsTree != null)
+            {
+                pageDestination = destsTree.getValue(namedDest.getNamedDestination());
+            }
+        }
+        if (pageDestination == null)
+        {
+            // Look up /Dests dictionary from catalog
+            PDDocumentNameDestinationDictionary nameDestDict = doc.getDocumentCatalog().getDests();
+            if (nameDestDict != null)
+            {
+                String name = namedDest.getNamedDestination();
+                pageDestination = (PDPageDestination) nameDestDict.getDestination(name);
+            }
+        }
+        return pageDestination;
+    }
+
     /**
      * Get the action of this node.
      *