]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
fixed npe when a page has several forward links
authorKeiron Liddle <keiron@apache.org>
Mon, 16 Sep 2002 07:35:46 +0000 (07:35 +0000)
committerKeiron Liddle <keiron@apache.org>
Mon, 16 Sep 2002 07:35:46 +0000 (07:35 +0000)
Submitted by: Rainer Garus <rainer.garus@arcor.de>

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195202 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/area/AreaTree.java
src/org/apache/fop/area/PageViewport.java

index 4046c6afd8f12c85af6bf7e4c9014d9adfba5191..de097f7feb789d5762f6abc9b20d629eac2ac8f0 100644 (file)
@@ -12,6 +12,7 @@ import org.apache.fop.render.Renderer;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 
 /**
@@ -99,10 +100,10 @@ public class AreaTree {
         }
         list.add(pv);
 
-        List todo = (List)resolve.get(id);
+        HashSet todo = (HashSet)resolve.get(id);
         if (todo != null) {
-            for (int count = 0; count < todo.size(); count++) {
-                Resolveable res = (Resolveable)todo.get(count);
+            for (Iterator iter = todo.iterator(); iter.hasNext();) {
+                Resolveable res = (Resolveable)iter.next();
                 res.resolve(id, list);
             }
             resolve.remove(id);
@@ -124,9 +125,9 @@ public class AreaTree {
      * @param res the Resolveable object to resolve
      */
     public void addUnresolvedID(String id, Resolveable res) {
-        ArrayList todo = (ArrayList)resolve.get(id);
+        HashSet todo = (HashSet)resolve.get(id);
         if (todo == null) {
-            todo = new ArrayList();
+            todo = new HashSet();
             resolve.put(id, todo);
         }
         todo.add(res);
@@ -147,9 +148,9 @@ public class AreaTree {
                 if (idLocations.containsKey(ids[count])) {
                     res.resolve(ids[count], (ArrayList)idLocations.get(ids[count]));
                 } else {
-                    ArrayList todo = (ArrayList)resolve.get(ids[count]);
+                    HashSet todo = (HashSet)resolve.get(ids[count]);
                     if (todo == null) {
-                        todo = new ArrayList();
+                        todo = new HashSet();
                         resolve.put(ids[count], todo);
                     }
                     todo.add(ext);
@@ -179,9 +180,9 @@ public class AreaTree {
     public void endDocument() {
         for (Iterator iter = resolve.keySet().iterator(); iter.hasNext();) {
             String id = (String)iter.next();
-            ArrayList list = (ArrayList)resolve.get(id);
-            for (int count = 0; count < list.size(); count++) {
-                Resolveable res = (Resolveable)list.get(count);
+            HashSet list = (HashSet)resolve.get(id);
+            for (Iterator resIter = list.iterator(); resIter.hasNext();) {
+                Resolveable res = (Resolveable)resIter.next();
                 if (!res.isResolved()) {
                     res.resolve(id, null);
                 }
index e5422658b6fcc375c6720817c3cb42efe3c837da..e1e15dba067e3570e8c8018a39c3113e2f5631a8 100644 (file)
@@ -139,17 +139,21 @@ public class PageViewport implements Resolveable, Cloneable {
             }
             pendingResolved.put(id, pages);
         } else {
-            List todo = (List)unresolved.get(id);
-            if (todo != null) {
-                for (int count = 0; count < todo.size(); count++) {
-                    Resolveable res = (Resolveable)todo.get(count);
-                    res.resolve(id, pages);
+            if (unresolved != null) {
+                List todo = (List)unresolved.get(id);
+                if (todo != null) {
+                    for (int count = 0; count < todo.size(); count++) {
+                        Resolveable res = (Resolveable)todo.get(count);
+                        res.resolve(id, pages);
+                    }
                 }
             }
         }
-        unresolved.remove(id);
-        if (unresolved.isEmpty()) {
-            unresolved = null;
+        if (unresolved != null) {
+            unresolved.remove(id);
+            if (unresolved.isEmpty()) {
+                unresolved = null;
+            }
         }
     }