]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugfix: basic-links with internal destinations in documents with multiple page-sequen...
authorJeremias Maerki <jeremias@apache.org>
Mon, 24 Apr 2006 18:39:05 +0000 (18:39 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 24 Apr 2006 18:39:05 +0000 (18:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@396640 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/area/AreaTreeHandler.java
src/java/org/apache/fop/area/AreaTreeParser.java
src/java/org/apache/fop/area/PageViewport.java
src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
src/java/org/apache/fop/render/xml/XMLRenderer.java
status.xml

index 8e165a99eb4a76f989a2a34a7563b7ce8015a7c9..6b68a9f7df0287013f1cca769aca90c053294a42 100644 (file)
@@ -66,6 +66,8 @@ import org.apache.fop.layoutmgr.LayoutManagerMapping;
  */
 public class AreaTreeHandler extends FOEventHandler {
 
+    private static Log log = LogFactory.getLog(AreaTreeHandler.class);
+
     // show statistics after document complete?
     private boolean outputStatistics;
 
@@ -104,8 +106,8 @@ public class AreaTreeHandler extends FOEventHandler {
 
     private PageSequenceLayoutManager prevPageSeqLM;
 
-    private static Log log = LogFactory.getLog(AreaTreeHandler.class);
-
+    private int idGen = 0;
+    
     /**
      * Constructor.
      * @param userAgent FOUserAgent object for process
@@ -460,5 +462,15 @@ public class AreaTreeHandler extends FOEventHandler {
             model.handleOffDocumentItem(odi);
         }
     }
+    
+    /**
+     * Generates and returns a unique key for a page viewport.
+     * @return the generated key.
+     */
+    public String generatePageViewportKey() {
+        this.idGen++;
+        return "P" + this.idGen;
+    }
+    
 }
 
index 251b4a687a7b5c007c92afa2b44d110c171ce18f..d63d31a38086a91f96c6a16bd5a0c1c09f2fefaa 100644 (file)
@@ -360,12 +360,14 @@ public class AreaTreeParser {
                 }
                 Rectangle2D viewArea = parseRect(attributes.getValue("bounds"));
                 int pageNumber = getAttributeAsInteger(attributes, "nr", -1);
+                String key = attributes.getValue("key");
                 String pageNumberString = attributes.getValue("formatted-nr");
                 String pageMaster = attributes.getValue("simple-page-master-name");
                 boolean blank = getAttributeAsBoolean(attributes, "blank", false);
                 currentPageViewport = new PageViewport(viewArea, 
                         pageNumber, pageNumberString,
                         pageMaster, blank);
+                currentPageViewport.setKey(key);
             }
 
         }
index f2fbd0555a91c34fb4a91b77d51c38111c49fbf5..c4cbc768e51f534c950f2292f5c6cc4ce4455493 100644 (file)
@@ -48,6 +48,13 @@ public class PageViewport implements Resolvable, Cloneable {
     private Page page;
     private Rectangle2D viewArea;
     private String simplePageMasterName;
+    
+    /**
+     * Unique key to identify the page. pageNumberString and pageIndex are both no option 
+     * for this.
+     */
+    private String pageKey;
+    
     private int pageNumber = -1;
     private String pageNumberString = null;
     private int pageIndex = -1; //-1 = undetermined
@@ -205,6 +212,14 @@ public class PageViewport implements Resolvable, Cloneable {
         return this.pageIndex;
     }
     
+    /**
+     * Sets the unique key for this PageViewport that will be used to reference this page.
+     * @param key the unique key.
+     */
+    public void setKey(String key) {
+        this.pageKey = key;
+    }
+    
     /**
      * Get the key for this page viewport.
      * This is used so that a serializable key can be used to
@@ -213,7 +228,10 @@ public class PageViewport implements Resolvable, Cloneable {
      * @return a unique page viewport key for this area tree
      */
     public String getKey() {
-        return toString();
+        if (this.pageKey == null) {
+            throw new IllegalStateException("No page key set on the PageViewport: " + toString());
+        }
+        return this.pageKey;
     }
 
     /**
index 9c1693a59446886aa6df4f5755a469091f8b8e11..a047d4820e36e484ef8cf4d3579465e0870fbaed 100644 (file)
@@ -1042,6 +1042,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
                         + "does not support this.");
                 }
                 Page page = new Page(spm, index, pageNumberString, isBlank);
+                //Set unique key obtained from the AreaTreeHandler
+                page.getPageViewport().setKey(areaTreeHandler.generatePageViewportKey());
                 cachedPages.add(page);
                 return page;
             } catch (FOPException e) {
index 49df7b1b3627c5f83724507f669e5eef69f58dc8..00b204ee00c6357a8cfe4ec57cfdb866e61d9152 100644 (file)
@@ -462,6 +462,7 @@ public class XMLRenderer extends PrintRenderer {
     public void renderPage(PageViewport page) throws IOException, FOPException {
         atts.clear();
         addAttribute("bounds", page.getViewArea());
+        addAttribute("key", page.getKey());
         addAttribute("nr", page.getPageNumber());
         addAttribute("formatted-nr", page.getPageNumberString());
         addAttribute("simple-page-master-name", page.getSimplePageMasterName());
index 795b175828a1a8fe4f3c72afd8c09c2b27af0193..d99cb10e562ce37f723cab0966924f2a318f3c81 100644 (file)
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="fix">
+        Bugfix: basic-links with internal destinations in documents with multiple 
+        page-sequences sometimes pointed at the wrong page.
+      </action>
       <action context="Code" dev="JM" type="fix">
         Bugfix: Fixed ClassCastException when retrieve-marker is used as a direct child
         if static-content in which case leading and trailing white space is not properly