]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Merge from 0_95 branch:
authorJeremias Maerki <jeremias@apache.org>
Sun, 10 Aug 2008 19:18:22 +0000 (19:18 +0000)
committerJeremias Maerki <jeremias@apache.org>
Sun, 10 Aug 2008 19:18:22 +0000 (19:18 +0000)
Fixed ID resolution for nested bookmarks with duplicated IDs.

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

src/java/org/apache/fop/area/BookmarkData.java
status.xml
test/layoutengine/standard-testcases/bookmarks_2.xml

index d009cb4251336aeaa062236483d7c36dd18047af..28ee2c23e0078f8687d03280fb6ae4b7e89373d7 100644 (file)
@@ -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);
     }
 
     /**
index 6686349f9ae483a1ed9f61d9b3f7e63f36988fb7..cfdccb72ebd529dc10ec7a7be5b4eec3aa3cc495 100644 (file)
@@ -53,6 +53,9 @@
 
   <changes>
     <release version="FOP Trunk" date="TBD">
+      <action context="Layout" dev="JM" type="fix">
+        Fixed ID resolution for nested bookmarks with duplicated IDs.
+      </action>
       <action context="Code" dev="AD" type="fix" fixes-bug="45490" due-to="Thomas Stieler">
         Fixed a slight error when resolving non-file URLs: avoid
         altering the original 'href' if the protocol is other than 'file:'
index b66b27bcff56ab7832ac90ec5144f25f554c5062..90a801412f6816c934d12945c7122ef79ab78425 100644 (file)
       <fo:bookmark-tree>
         <fo:bookmark internal-destination="chapter1">
           <fo:bookmark-title>Chapter 1</fo:bookmark-title>
+          <fo:bookmark internal-destination="chapter1">
+            <fo:bookmark-title>Nested Chapter 1</fo:bookmark-title>
+          </fo:bookmark>
         </fo:bookmark>
         <fo:bookmark internal-destination="chapter1" starting-state="hide">
           <fo:bookmark-title>Again Chapter 1</fo:bookmark-title>
         </fo:bookmark>
+        <fo:bookmark internal-destination="chapter2">
+          <fo:bookmark-title>Chapter 2</fo:bookmark-title>
+        </fo:bookmark>
       </fo:bookmark-tree>
       <fo:page-sequence id="page-sequence" master-reference="normal">
         <fo:flow flow-name="xsl-region-body">
     
     <eval expected="Chapter 1" xpath="//bookmarkTree/bookmark[1]/@title"/>
     <eval expected="true" xpath="//bookmarkTree/bookmark[1]/@show-children"/>
+    <eval expected="Nested Chapter 1" xpath="//bookmarkTree/bookmark[1]/bookmark[1]/@title"/>
+    <eval expected="true" xpath="//bookmarkTree/bookmark[1]/bookmark[1]/@show-children"/>
     <eval expected="Again Chapter 1" xpath="//bookmarkTree/bookmark[2]/@title"/>
     <eval expected="false" xpath="//bookmarkTree/bookmark[2]/@show-children"/>
 
     <eval expected="(P1,chapter1)" xpath="//bookmarkTree/bookmark[1]/@internal-link"/>
+    <eval expected="(P1,chapter1)" xpath="//bookmarkTree/bookmark[1]/bookmark[1]/@internal-link"/>
     <eval expected="(P1,chapter1)" xpath="//bookmarkTree/bookmark[2]/@internal-link"/>
     
   </checks>