Browse Source

Bugfix: basic-links with internal destinations in documents with multiple page-sequences sometimes pointed at the wrong page.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@396640 13f79535-47bb-0310-9956-ffa450edef68
pull/25/head
Jeremias Maerki 18 years ago
parent
commit
92d9cffdbb

+ 14
- 2
src/java/org/apache/fop/area/AreaTreeHandler.java View 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;
}
}


+ 2
- 0
src/java/org/apache/fop/area/AreaTreeParser.java View 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);
}

}

+ 19
- 1
src/java/org/apache/fop/area/PageViewport.java View 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;
}

/**

+ 2
- 0
src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java View 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) {

+ 1
- 0
src/java/org/apache/fop/render/xml/XMLRenderer.java View 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());

+ 4
- 0
status.xml View File

@@ -27,6 +27,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

Loading…
Cancel
Save