From: Vincent Hennebert Date: Tue, 20 Oct 2009 14:53:23 +0000 (+0000) Subject: Issue a warning, when non-restartable content is flowing to a narrower page, that... X-Git-Tag: fop-1_0~131 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b89abf199dc97efd42511a95ca10ded423b04fd2;p=xmlgraphics-fop.git 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 --- 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(); } }