From: Jeremias Maerki Date: Fri, 30 Nov 2007 09:04:54 +0000 (+0000) Subject: Bugzilla #37993: X-Git-Tag: fop-0_95beta~259 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3215a1e4e3955e9969ce2cf379644f012d1323d3;p=xmlgraphics-fop.git 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 --- 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 { diff --git a/status.xml b/status.xml index 6e165d998..172869f60 100644 --- a/status.xml +++ b/status.xml @@ -28,6 +28,9 @@ + + Bugfix: allow multiple bookmarks to point at the same destination. + Bugfix for border-after painting and element list generation when a forced break is involved. diff --git a/test/layoutengine/standard-testcases/bookmarks_2.xml b/test/layoutengine/standard-testcases/bookmarks_2.xml new file mode 100644 index 000000000..b66b27bcf --- /dev/null +++ b/test/layoutengine/standard-testcases/bookmarks_2.xml @@ -0,0 +1,68 @@ + + + + + +

+ This test checks the handling of duplicate destination in the bookmarks tree. There was a + bug earlier (#37993) which made two bookmarks pointing to the same destination impossible. +

+
+ + + + + + + + + + Chapter 1 + + + Again Chapter 1 + + + + + Chapter 1 + Blah blah bla. + Chapter 2 + Blah blah bla. + Section 1 + Blah blah bla. + Section 2 + Blah blah bla. + + + + + + + + + + + + + + + + +