*/
public class AreaTreeHandler extends FOEventHandler {
+ private static Log log = LogFactory.getLog(AreaTreeHandler.class);
+
// show statistics after document complete?
private boolean outputStatistics;
private PageSequenceLayoutManager prevPageSeqLM;
- private static Log log = LogFactory.getLog(AreaTreeHandler.class);
-
+ private int idGen = 0;
+
/**
* Constructor.
* @param userAgent FOUserAgent object for process
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;
+ }
+
}
}
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);
}
}
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
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
* @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;
}
/**
+ "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) {
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());
<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