diff options
-rw-r--r-- | src/java/org/apache/fop/area/AreaTreeHandler.java | 16 | ||||
-rw-r--r-- | src/java/org/apache/fop/area/AreaTreeParser.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/area/PageViewport.java | 20 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/render/xml/XMLRenderer.java | 1 | ||||
-rw-r--r-- | status.xml | 4 |
6 files changed, 42 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java index 8e165a99e..6b68a9f7d 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.java @@ -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; + } + } diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java index 251b4a687..d63d31a38 100644 --- a/src/java/org/apache/fop/area/AreaTreeParser.java +++ b/src/java/org/apache/fop/area/AreaTreeParser.java @@ -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); } } diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java index f2fbd0555..c4cbc768e 100644 --- a/src/java/org/apache/fop/area/PageViewport.java +++ b/src/java/org/apache/fop/area/PageViewport.java @@ -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 @@ -206,6 +213,14 @@ public class PageViewport implements Resolvable, Cloneable { } /** + * 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 * lookup the page or some other reference. @@ -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; } /** diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index 9c1693a59..a047d4820 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -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) { diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index 49df7b1b3..00b204ee0 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -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()); diff --git a/status.xml b/status.xml index 795b17582..d99cb10e5 100644 --- a/status.xml +++ b/status.xml @@ -28,6 +28,10 @@ <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 removed. |