summaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
authorMatthias Reischenbacher <matthias@apache.org>2015-06-12 20:54:50 +0000
committerMatthias Reischenbacher <matthias@apache.org>2015-06-12 20:54:50 +0000
commit6d1a86e19180438eb3b01b6c7616fdc33901eb06 (patch)
treea3b8fe25c1c6fc5c55ba80c4d5d6cd62bed61e43 /src/java/org
parentf238bd0aa5085b8fbd10a73a156893fd7e13ce55 (diff)
downloadxmlgraphics-fop-6d1a86e19180438eb3b01b6c7616fdc33901eb06.tar.gz
xmlgraphics-fop-6d1a86e19180438eb3b01b6c7616fdc33901eb06.zip
FOP-2465: Fix links to/from 'last' page
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1685165 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/area/IDTracker.java18
-rw-r--r--src/java/org/apache/fop/area/PageViewport.java13
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageProvider.java5
3 files changed, 36 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/area/IDTracker.java b/src/java/org/apache/fop/area/IDTracker.java
index 0986891f8..58d6a2e43 100644
--- a/src/java/org/apache/fop/area/IDTracker.java
+++ b/src/java/org/apache/fop/area/IDTracker.java
@@ -238,4 +238,22 @@ public class IDTracker {
// add Resolvable object to this HashSet
todo.add(res);
}
+
+ /**
+ * Replace all id locations pointing to the old page view port with a new one. This is
+ * necessary when a layouted page is replaced with a new one (e.g. last page handling).
+ * @param oldPageViewPort old page view port
+ * @param newPageViewPort new page view port
+ */
+ public void replacePageViewPort(PageViewport oldPageViewPort, PageViewport newPageViewPort) {
+
+ for (List<PageViewport> viewPortList : idLocations.values()) {
+ for (int i = 0, len = viewPortList.size(); i < len; i++) {
+ PageViewport currPV = viewPortList.get(i);
+ if (currPV == oldPageViewPort) {
+ viewPortList.set(i, newPageViewPort);
+ }
+ }
+ }
+ }
}
diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java
index dd5c387ee..f1cd95721 100644
--- a/src/java/org/apache/fop/area/PageViewport.java
+++ b/src/java/org/apache/fop/area/PageViewport.java
@@ -278,6 +278,19 @@ public class PageViewport extends AreaTreeObject implements Resolvable {
}
/**
+ * Replace the old view port. This copies all ID related fields from the old view port
+ * to the current one.
+ * @param oldViewPort old view port
+ */
+ public void replace(PageViewport oldViewPort) {
+ this.idFirsts.addAll(oldViewPort.idFirsts);
+ this.unresolvedIDRefs.putAll(oldViewPort.unresolvedIDRefs);
+ if (oldViewPort.pendingResolved != null) {
+ this.pendingResolved.putAll(oldViewPort.pendingResolved);
+ }
+ }
+
+ /**
* Add an idref to this page.
* All idrefs found for child areas of this {@link PageViewport} are added
* to unresolvedIDRefs, for subsequent resolution by {@link AreaTreeHandler}
diff --git a/src/java/org/apache/fop/layoutmgr/PageProvider.java b/src/java/org/apache/fop/layoutmgr/PageProvider.java
index 1cb6251d9..ba35ecb11 100644
--- a/src/java/org/apache/fop/layoutmgr/PageProvider.java
+++ b/src/java/org/apache/fop/layoutmgr/PageProvider.java
@@ -25,6 +25,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.area.AreaTreeHandler;
+import org.apache.fop.area.PageViewport;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.SimplePageMaster;
@@ -311,7 +312,11 @@ public class PageProvider implements Constants {
}
if (replace) {
discardCacheStartingWith(intIndex);
+ PageViewport oldPageVP = page.getPageViewport();
page = cacheNextPage(index, isBlank, isLastPage, this.spanAllForCurrentElementList);
+ PageViewport newPageVP = page.getPageViewport();
+ newPageVP.replace(oldPageVP);
+ this.areaTreeHandler.getIDTracker().replacePageViewPort(oldPageVP, newPageVP);
}
return page;
}