diff options
author | Jeremias Maerki <jeremias@apache.org> | 2007-11-30 09:04:54 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2007-11-30 09:04:54 +0000 |
commit | 3215a1e4e3955e9969ce2cf379644f012d1323d3 (patch) | |
tree | 25658d55817782ff17d210409615eef331769eda /src/java/org/apache/fop/area/BookmarkData.java | |
parent | 06cc9812b1ef6033640d63fbc61561d8f8e0e734 (diff) | |
download | xmlgraphics-fop-3215a1e4e3955e9969ce2cf379644f012d1323d3.tar.gz xmlgraphics-fop-3215a1e4e3955e9969ce2cf379644f012d1323d3.zip |
Bugzilla #37993:
Bugfix: allow multiple bookmarks to point at the same destination.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@599746 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/area/BookmarkData.java')
-rw-r--r-- | src/java/org/apache/fop/area/BookmarkData.java | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/java/org/apache/fop/area/BookmarkData.java b/src/java/org/apache/fop/area/BookmarkData.java index 30bd704b1..07290824e 100644 --- a/src/java/org/apache/fop/area/BookmarkData.java +++ b/src/java/org/apache/fop/area/BookmarkData.java @@ -19,11 +19,13 @@ package org.apache.fop.area; +import java.util.Collection; +import java.util.Iterator; import java.util.List; -import java.util.HashMap; +import java.util.Map; -import org.apache.fop.fo.pagination.bookmarks.BookmarkTree; import org.apache.fop.fo.pagination.bookmarks.Bookmark; +import org.apache.fop.fo.pagination.bookmarks.BookmarkTree; /** * An instance of this class is either a PDF bookmark-tree and @@ -31,6 +33,7 @@ import org.apache.fop.fo.pagination.bookmarks.Bookmark; * child bookmark-items under it. */ public class BookmarkData extends AbstractOffDocumentItem implements Resolvable { + private List subData = new java.util.ArrayList(); // bookmark-title for this fo:bookmark @@ -46,7 +49,7 @@ public class BookmarkData extends AbstractOffDocumentItem implements Resolvable private PageViewport pageRef = null; // unresolved idrefs by this bookmark and child bookmarks below it - private HashMap unresolvedIDRefs = new HashMap(); + private Map unresolvedIDRefs = new java.util.HashMap(); /** * Create a new bookmark data object. @@ -79,9 +82,17 @@ public class BookmarkData extends AbstractOffDocumentItem implements Resolvable bookmarkTitle = bookmark.getBookmarkTitle(); bShow = bookmark.showChildItems(); this.idRef = bookmark.getInternalDestination(); - unresolvedIDRefs.put(idRef, this); } + private void putUnresolved(String id, BookmarkData bd) { + List refs = (List)unresolvedIDRefs.get(id); + if (refs == null) { + refs = new java.util.ArrayList(); + unresolvedIDRefs.put(id, refs); + } + refs.add(bd); + } + /** * Create a new bookmark data root object. * This constructor is called by the AreaTreeParser when the @@ -128,10 +139,10 @@ public class BookmarkData extends AbstractOffDocumentItem implements Resolvable public void addSubData(BookmarkData sub) { subData.add(sub); if (sub.pageRef == null || sub.pageRef.equals("")) { - unresolvedIDRefs.put(sub.getIDRef(), sub); + putUnresolved(sub.getIDRef(), sub); String[] ids = sub.getIDRefs(); for (int count = 0; count < ids.length; count++) { - unresolvedIDRefs.put(ids[count], sub); + putUnresolved(ids[count], sub); } } } @@ -212,9 +223,13 @@ public class BookmarkData extends AbstractOffDocumentItem implements Resolvable */ public void resolveIDRef(String id, List pages) { if (!id.equals(idRef)) { - BookmarkData bd = (BookmarkData) unresolvedIDRefs.get(id); - if (bd != null) { - bd.resolveIDRef(id, pages); + Collection refs = (Collection)unresolvedIDRefs.get(id); + if (refs != null) { + Iterator iter = refs.iterator(); + while (iter.hasNext()) { + BookmarkData bd = (BookmarkData)iter.next(); + bd.resolveIDRef(id, pages); + } unresolvedIDRefs.remove(id); } } else { |