Author: vhennebert
Date: Tue Oct 20 14:53:23 2009
New Revision: 827621
URL: http://svn.apache.org/viewvc?rev=827621&view=rev
Log:
Issue a warning, when non-restartable content is flowing to a narrower page,
that part of it may be clipped
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageProvider.java
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?rev=827621&r1=827620&r2=827621&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
Tue Oct 20 14:53:23 2009
@@ -367,7 +367,7 @@
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 @@
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);
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java?rev=827621&r1=827620&r2=827621&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
Tue Oct 20 14:53:23 2009
@@ -491,7 +491,7 @@
elementIndex, previousIsBox, allowedBreaks).isBox();
if (activeNodeCount == 0) {
- if (ipdChanged()) {
+ if (getIPDdifference() != 0) {
return handleIpdChange();
}
if (!force) {
@@ -538,8 +538,8 @@
return line;
}
- protected boolean ipdChanged() {
- return false;
+ protected int getIPDdifference() {
+ return 0;
}
protected int handleIpdChange() {
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=827621&r1=827620&r2=827621&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
Tue Oct 20 14:53:23 2009
@@ -96,7 +96,7 @@
//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 @@
}
/** {...@inheritdoc} */
- protected boolean ipdChanged() {
- return ipdChange;
+ protected int getIPDdifference() {
+ return ipdDifference;
}
/** {...@inheritdoc} */
@@ -1104,9 +1104,9 @@
* @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 @@
* 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 @@
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);
}
}
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageProvider.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageProvider.java?rev=827621&r1=827620&r2=827621&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageProvider.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageProvider.java
Tue Oct 20 14:53:23 2009
@@ -161,12 +161,13 @@
}
/**
- * 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 @@
} 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();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]