From: Jeremias Maerki Date: Sun, 10 Aug 2008 19:01:59 +0000 (+0000) Subject: Fixed ID resolution for nested bookmarks with duplicated IDs. X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b003ff96edf1055bace1d8eb468b530253790e84;p=xmlgraphics-fop.git Fixed ID resolution for nested bookmarks with duplicated IDs. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_95@684572 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 07290824e..28ee2c23e 100644 --- a/src/java/org/apache/fop/area/BookmarkData.java +++ b/src/java/org/apache/fop/area/BookmarkData.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.area; import java.util.Collection; @@ -33,7 +33,7 @@ import org.apache.fop.fo.pagination.bookmarks.BookmarkTree; * 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 @@ -92,7 +92,7 @@ public class BookmarkData extends AbstractOffDocumentItem implements Resolvable } refs.add(bd); } - + /** * Create a new bookmark data root object. * This constructor is called by the AreaTreeParser when the @@ -218,25 +218,24 @@ public class BookmarkData extends AbstractOffDocumentItem implements Resolvable * id reference. * * {@inheritDoc} List) - * @todo check to make sure it works if multiple bookmark-items - * have the same idref */ public void resolveIDRef(String id, List pages) { - if (!id.equals(idRef)) { - 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 { + if (id.equals(idRef)) { + //Own ID has been resolved, so note the page pageRef = (PageViewport) pages.get(0); - // TODO get rect area of id on page - unresolvedIDRefs.remove(idRef); + //Note: Determining the placement inside the page is the renderer's job. + } + + //Notify all child bookmarks + 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); } /** diff --git a/status.xml b/status.xml index 495f0a545..68575fe81 100644 --- a/status.xml +++ b/status.xml @@ -52,14 +52,12 @@ - - - - + + + Fixed ID resolution for nested bookmarks with duplicated IDs. + + +
Notes diff --git a/test/layoutengine/standard-testcases/bookmarks_2.xml b/test/layoutengine/standard-testcases/bookmarks_2.xml index b66b27bcf..90a801412 100644 --- a/test/layoutengine/standard-testcases/bookmarks_2.xml +++ b/test/layoutengine/standard-testcases/bookmarks_2.xml @@ -34,10 +34,16 @@ Chapter 1 + + Nested Chapter 1 + Again Chapter 1 + + Chapter 2 + @@ -58,10 +64,13 @@ + + +