aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2009-10-20 14:53:23 +0000
committerVincent Hennebert <vhennebert@apache.org>2009-10-20 14:53:23 +0000
commitb89abf199dc97efd42511a95ca10ded423b04fd2 (patch)
tree6fb49877b875dd8ae9540925f7d244d8596160a6 /src/java/org/apache
parent77d320fbcda503079eab89eaa12bedf6a1122769 (diff)
downloadxmlgraphics-fop-b89abf199dc97efd42511a95ca10ded423b04fd2.tar.gz
xmlgraphics-fop-b89abf199dc97efd42511a95ca10ded423b04fd2.zip
Issue a warning, when non-restartable content is flowing to a narrower page, that part of it may be clipped
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@827621 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/layoutmgr/AbstractBreaker.java7
-rw-r--r--src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java19
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageProvider.java11
4 files changed, 24 insertions, 19 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
index 2ee4a8a3a..53a52597b 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
@@ -367,7 +367,7 @@ public abstract class AbstractBreaker {
alg.setConstantLineWidth(flowBPD);
int optimalPageCount = alg.findBreakingPoints(effectiveList, 1, true,
BreakingAlgorithm.ALL_BREAKS);
- if (alg.ipdChanged()) {
+ if (alg.getIPDdifference() != 0) {
KnuthNode optimalBreak = alg.getBestNodeBeforeIPDChange();
int positionIndex = optimalBreak.position;
KnuthElement elementAtBreak = alg.getElement(positionIndex);
@@ -381,6 +381,11 @@ public abstract class AbstractBreaker {
LayoutManager restartAtLM = null;
List firstElements = Collections.EMPTY_LIST;
if (containsNonRestartableLM(positionAtBreak)) {
+ if (alg.getIPDdifference() > 0) {
+ log.warn("Content that cannot handle IPD changes is flowing to a"
+ + " narrower page. Part of it may be clipped"
+ + " by the page border.");
+ }
firstElements = new LinkedList();
boolean boxFound = false;
Iterator iter = effectiveList.listIterator(positionIndex + 1);
diff --git a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
index cad047508..4516c8d97 100644
--- a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
@@ -491,7 +491,7 @@ public abstract class BreakingAlgorithm {
elementIndex, previousIsBox, allowedBreaks).isBox();
if (activeNodeCount == 0) {
- if (ipdChanged()) {
+ if (getIPDdifference() != 0) {
return handleIpdChange();
}
if (!force) {
@@ -538,8 +538,8 @@ public abstract class BreakingAlgorithm {
return line;
}
- protected boolean ipdChanged() {
- return false;
+ protected int getIPDdifference() {
+ return 0;
}
protected int handleIpdChange() {
diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
index c238f3c27..83dea01bf 100644
--- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
@@ -96,7 +96,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
//Controls whether a single part should be forced if possible (ex. block-container)
private boolean favorSinglePart = false;
- private boolean ipdChange;
+ private int ipdDifference;
private KnuthNode bestNodeForIPDChange;
//Used to keep track of switches in keep-context
@@ -1077,8 +1077,8 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
}
/** {@inheritDoc} */
- protected boolean ipdChanged() {
- return ipdChange;
+ protected int getIPDdifference() {
+ return ipdDifference;
}
/** {@inheritDoc} */
@@ -1104,9 +1104,9 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
* @param node the active node to add
*/
protected void addNode(int line, KnuthNode node) {
- if (node.position < par.size() - 1 && line > 0 && ipdChange(line - 1)) {
+ if (node.position < par.size() - 1 && line > 0
+ && (ipdDifference = compareIPDs(line - 1)) != 0) {
log.trace("IPD changes at page " + line);
- ipdChange = true;
if (bestNodeForIPDChange == null
|| node.totalDemerits < bestNodeForIPDChange.totalDemerits) {
bestNodeForIPDChange = node;
@@ -1117,7 +1117,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
* The whole sequence could actually fit on the last page before
* the IPD change. No need to do any special handling.
*/
- ipdChange = false;
+ ipdDifference = 0;
}
super.addNode(line, node);
}
@@ -1127,12 +1127,11 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
return bestNodeForIPDChange;
}
- /** {@inheritDoc} */
- protected boolean ipdChange(int line) {
+ private int compareIPDs(int line) {
if (pageProvider == null) {
- return false;
+ return 0;
}
- return pageProvider.ipdChange(line);
+ return pageProvider.compareIPDs(line);
}
}
diff --git a/src/java/org/apache/fop/layoutmgr/PageProvider.java b/src/java/org/apache/fop/layoutmgr/PageProvider.java
index bd556366a..2e531a8d8 100644
--- a/src/java/org/apache/fop/layoutmgr/PageProvider.java
+++ b/src/java/org/apache/fop/layoutmgr/PageProvider.java
@@ -161,12 +161,13 @@ public class PageProvider implements Constants {
}
/**
- * Returns true if the part following the given one has a different IPD.
+ * Compares the IPD of the given part with the following one.
*
* @param index index of the current part
- * @return true if the following part has a different IPD, false otherwise
+ * @return a negative integer, zero or a positive integer as the current IPD is less
+ * than, equal to or greater than the IPD of the following part
*/
- public boolean ipdChange(int index) {
+ public int compareIPDs(int index) {
int columnCount = 0;
int colIndex = startColumnOfCurrentElementList + index;
int pageIndex = -1;
@@ -179,11 +180,11 @@ public class PageProvider implements Constants {
} while (colIndex >= columnCount);
if (colIndex + 1 < columnCount) {
// Next part is a column on same page => same IPD
- return false;
+ return 0;
} else {
Page nextPage = getPage(false, pageIndex + 1, RELTO_CURRENT_ELEMENT_LIST);
return page.getPageViewport().getBodyRegion().getIPD()
- != nextPage.getPageViewport().getBodyRegion().getIPD();
+ - nextPage.getPageViewport().getBodyRegion().getIPD();
}
}