aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2021-02-25 13:12:16 +0000
committerSimon Steiner <ssteiner@apache.org>2021-02-25 13:12:16 +0000
commitaa0f7734e3832439e505479ae60e6aff2173db31 (patch)
tree07964f97cc59f28fab278304e034945cb8431a5f /fop-core
parentd6a1aadd0d30263130cf746dd6b5f8b5b70d5348 (diff)
downloadxmlgraphics-fop-aa0f7734e3832439e505479ae60e6aff2173db31.tar.gz
xmlgraphics-fop-aa0f7734e3832439e505479ae60e6aff2173db31.zip
FOP-2999: Rollback after checking next page
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1886916 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core')
-rw-r--r--fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java6
-rw-r--r--fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java4
-rw-r--r--fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java26
-rw-r--r--fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java3
4 files changed, 35 insertions, 4 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java b/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java
index 3f82e6822..79955ff74 100644
--- a/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java
+++ b/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequence.java
@@ -542,4 +542,10 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra
public List<ChangeBar> getClonedChangeBarList() {
return new LinkedList<ChangeBar>(changeBarList);
}
+
+ public void setOnlyTryInfinite(boolean b) {
+ if (pageSequenceMaster != null) {
+ pageSequenceMaster.onlyTryInfinite = b;
+ }
+ }
}
diff --git a/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
index f218e43b4..b9840e006 100644
--- a/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
+++ b/fop-core/src/main/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
@@ -49,6 +49,7 @@ public class PageSequenceMaster extends FObj {
private SubSequenceSpecifier currentSubSequence;
private int currentSubSequenceNumber = -1;
private BlockLevelEventProducer blockLevelEventProducer;
+ protected boolean onlyTryInfinite;
// The terminology may be confusing. A 'page-sequence-master' consists
// of a sequence of what the XSL spec refers to as
@@ -199,6 +200,9 @@ public class PageSequenceMaster extends FObj {
boolean isBlankPage,
String mainFlowName)
throws PageProductionException {
+ if (onlyTryInfinite && currentSubSequence != null && !currentSubSequence.isInfinite()) {
+ throw new PageProductionException("Limited to infinite");
+ }
if (currentSubSequence == null) {
currentSubSequence = getNextSubSequence();
if (currentSubSequence == null) {
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java
index 3c3409ce7..266a7d9b9 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/PageProvider.java
@@ -28,6 +28,7 @@ import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.area.BodyRegion;
import org.apache.fop.area.PageViewport;
import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.pagination.PageProductionException;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.Region;
import org.apache.fop.fo.pagination.RegionBody;
@@ -192,7 +193,9 @@ public class PageProvider implements Constants {
colIndex -= columnCount;
pageIndex++;
page = getPage(false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
- columnCount = page.getPageViewport().getCurrentSpan().getColumnCount();
+ if (page.getPageViewport().getPage() != null) {
+ columnCount = page.getPageViewport().getCurrentSpan().getColumnCount();
+ }
} while (colIndex >= columnCount);
return new Column(page, pageIndex, colIndex, columnCount);
}
@@ -316,7 +319,8 @@ public class PageProvider implements Constants {
log.debug("blank condition doesn't match. Replacing PageViewport.");
replace = true;
}
- if (page.getPageViewport().getCurrentSpan().getColumnCount() == 1
+ if (page.getPageViewport().getPage() != null
+ && page.getPageViewport().getCurrentSpan().getColumnCount() == 1
&& !this.spanAllForCurrentElementList) {
RegionBody rb = (RegionBody)page.getSimplePageMaster().getRegion(Region.FO_REGION_BODY);
int colCount = rb.getColumnCount();
@@ -394,13 +398,27 @@ public class PageProvider implements Constants {
}
public int getCurrentIPD() {
+ if (startPageOfCurrentElementList == 0) {
+ return -1;
+ }
Page page = getPageFromColumnIndex(startColumnOfCurrentElementList);
return page.getPageViewport().getBodyRegion().getColumnIPD();
}
public int getNextIPD() {
- Page page = getPageFromColumnIndex(startColumnOfCurrentElementList + 1);
- return page.getPageViewport().getBodyRegion().getColumnIPD();
+ pageSeq.setOnlyTryInfinite(true);
+ try {
+ int oldSize = cachedPages.size();
+ Page page = getPageFromColumnIndex(startColumnOfCurrentElementList + 1);
+ if (oldSize != cachedPages.size()) {
+ cachedPages.remove(cachedPages.size() - 1);
+ }
+ return page.getPageViewport().getBodyRegion().getColumnIPD();
+ } catch (PageProductionException e) {
+ return getCurrentIPD();
+ } finally {
+ pageSeq.setOnlyTryInfinite(false);
+ }
}
public int getCurrentColumnCount() {
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
index d079824ba..ffc4e7c88 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
@@ -492,6 +492,9 @@ public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManage
private boolean isChangingIPD(LayoutManager lm) {
PageProvider pageProvider = lm.getPSLM().getPageProvider();
int currentIPD = pageProvider.getCurrentIPD();
+ if (currentIPD == -1) {
+ return false;
+ }
int nextIPD = pageProvider.getNextIPD();
return nextIPD != currentIPD;
}