From 18558ad78b40fecd78d444ad3196ec8c7879a536 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Mon, 16 Sep 2002 07:35:46 +0000 Subject: [PATCH] fixed npe when a page has several forward links Submitted by: Rainer Garus 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 | 21 +++++++++++---------- src/org/apache/fop/area/PageViewport.java | 20 ++++++++++++-------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/org/apache/fop/area/AreaTree.java b/src/org/apache/fop/area/AreaTree.java index 4046c6afd..de097f7fe 100644 --- a/src/org/apache/fop/area/AreaTree.java +++ b/src/org/apache/fop/area/AreaTree.java @@ -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); } diff --git a/src/org/apache/fop/area/PageViewport.java b/src/org/apache/fop/area/PageViewport.java index e5422658b..e1e15dba0 100644 --- a/src/org/apache/fop/area/PageViewport.java +++ b/src/org/apache/fop/area/PageViewport.java @@ -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; + } } } -- 2.39.5