aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2010-01-18 12:28:32 +0000
committerVincent Hennebert <vhennebert@apache.org>2010-01-18 12:28:32 +0000
commitab6e2cc40a0c0dde6b98eec000ab94d1c7e35cb1 (patch)
treec4ea2ae6a53d577f1157a85c1c67274526772b27 /src/java
parenta5197e625c0a6ee39e453b9af2eec50953cd1735 (diff)
downloadxmlgraphics-fop-ab6e2cc40a0c0dde6b98eec000ab94d1c7e35cb1.tar.gz
xmlgraphics-fop-ab6e2cc40a0c0dde6b98eec000ab94d1c7e35cb1.zip
Bugzilla #46486: having a special page-master for the last page caused loss of content when normal blocks were mixed with blocks spanning all columns.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@900364 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/area/MainReference.java14
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageBreaker.java58
2 files changed, 41 insertions, 31 deletions
diff --git a/src/java/org/apache/fop/area/MainReference.java b/src/java/org/apache/fop/area/MainReference.java
index 0922ebd01..dd53113af 100644
--- a/src/java/org/apache/fop/area/MainReference.java
+++ b/src/java/org/apache/fop/area/MainReference.java
@@ -19,8 +19,9 @@
package org.apache.fop.area;
-import java.util.List;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
/**
* The main-reference-area generated by an fo:region-body
@@ -75,6 +76,17 @@ public class MainReference extends Area {
}
/**
+ * Do not use. Used to handle special page-master for last page: transfer the content
+ * that had already been added to a normal page to this main reference for the last
+ * page. TODO this is hacky.
+ *
+ * @param spans content already laid out
+ */
+ public void setSpans(List spans) {
+ spanAreas = new ArrayList(spans);
+ }
+
+ /**
* Get the span area currently being filled (i.e., the last span created).
* @return the active span.
*/
diff --git a/src/java/org/apache/fop/layoutmgr/PageBreaker.java b/src/java/org/apache/fop/layoutmgr/PageBreaker.java
index 134e69f31..25ecd5a75 100644
--- a/src/java/org/apache/fop/layoutmgr/PageBreaker.java
+++ b/src/java/org/apache/fop/layoutmgr/PageBreaker.java
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.ListIterator;
import org.apache.fop.area.Block;
+import org.apache.fop.area.BodyRegion;
import org.apache.fop.area.Footnote;
import org.apache.fop.area.PageViewport;
import org.apache.fop.fo.Constants;
@@ -289,7 +290,7 @@ public class PageBreaker extends AbstractBreaker {
if (needColumnBalancing) {
//column balancing for the last part
- doPhase3(alg, partCount, originalList, effectiveList, false);
+ redoLayout(alg, partCount, originalList, effectiveList);
return;
}
@@ -298,7 +299,7 @@ public class PageBreaker extends AbstractBreaker {
//last part is reached
if (lastPageMasterDefined) {
//last-page condition
- doPhase3(alg, partCount, originalList, effectiveList, true);
+ redoLayout(alg, partCount, originalList, effectiveList);
return;
}
}
@@ -308,16 +309,12 @@ public class PageBreaker extends AbstractBreaker {
}
/**
- * Restart the algorithm at the break corresponding
- * to the given partCount
- * (currently only used to redo the part after the
- * last break in case of column-balancing
- * and/or a last page-master)
+ * Restart the algorithm at the break corresponding to the given partCount. Used to
+ * re-do the part after the last break in case of either column-balancing or a last
+ * page-master.
*/
- private void doPhase3(PageBreakingAlgorithm alg, int partCount,
- BlockSequence originalList, BlockSequence effectiveList,
- boolean isLastPart) {
-
+ private void redoLayout(PageBreakingAlgorithm alg, int partCount,
+ BlockSequence originalList, BlockSequence effectiveList) {
int newStartPos = 0;
int restartPoint = pageProvider.getStartingPartIndexForLastPage(partCount);
@@ -344,15 +341,10 @@ public class PageBreaker extends AbstractBreaker {
pageProvider.setStartOfNextElementList(currentPageNum,
pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
- PageBreakingAlgorithm algRestart = null;
- int optimalPageCount;
//Make sure we only add the areas we haven't added already
effectiveList.ignoreAtStart = newStartPos;
- if (isLastPart) {
- pageProvider.setLastPageIndex(currentPageNum);
- }
-
+ PageBreakingAlgorithm algRestart;
if (needColumnBalancing) {
AbstractBreaker.log.debug("Column balancing now!!!");
AbstractBreaker.log.debug("===================================================");
@@ -365,7 +357,13 @@ public class PageBreaker extends AbstractBreaker {
pslm.getCurrentPV().getBodyRegion().getColumnCount());
AbstractBreaker.log.debug("===================================================");
} else {
- //plain last page, no column balancing
+ // Handle special page-master for last page
+ BodyRegion currentBody = pageProvider.getPage(false, currentPageNum)
+ .getPageViewport().getBodyRegion();
+ pageProvider.setLastPageIndex(currentPageNum);
+ BodyRegion lastBody = pageProvider.getPage(false, currentPageNum)
+ .getPageViewport().getBodyRegion();
+ lastBody.getMainReference().setSpans(currentBody.getMainReference().getSpans());
AbstractBreaker.log.debug("Last page handling now!!!");
AbstractBreaker.log.debug("===================================================");
//Restart last page
@@ -377,16 +375,25 @@ public class PageBreaker extends AbstractBreaker {
AbstractBreaker.log.debug("===================================================");
}
- optimalPageCount = algRestart.findBreakingPoints(effectiveList,
+ int optimalPageCount = algRestart.findBreakingPoints(effectiveList,
newStartPos,
1, true, BreakingAlgorithm.ALL_BREAKS);
AbstractBreaker.log.debug("restart: optimalPageCount= " + optimalPageCount
+ " pageBreaks.size()= " + algRestart.getPageBreaks().size());
boolean fitsOnePage
- = optimalPageCount <= pslm.getCurrentPV().getBodyRegion().getColumnCount();
+ = optimalPageCount <= pslm.getCurrentPV().getBodyRegion().getMainReference().getCurrentSpan().getColumnCount();
- if (isLastPart) {
+ if (needColumnBalancing) {
+ if (!fitsOnePage) {
+ AbstractBreaker.log.warn(
+ "Breaking algorithm produced more columns than are available.");
+ /* reenable when everything works
+ throw new IllegalStateException(
+ "Breaking algorithm must not produce more columns than available.");
+ */
+ }
+ } else {
if (fitsOnePage) {
//Replace last page
pslm.setCurrentPage(pageProvider.getPage(false, currentPageNum));
@@ -399,15 +406,6 @@ public class PageBreaker extends AbstractBreaker {
pslm.setCurrentPage(pslm.makeNewPage(true, true));
return;
}
- } else {
- if (!fitsOnePage) {
- AbstractBreaker.log.warn(
- "Breaking algorithm produced more columns than are available.");
- /* reenable when everything works
- throw new IllegalStateException(
- "Breaking algorithm must not produce more columns than available.");
- */
- }
}
addAreas(algRestart, optimalPageCount, originalList, effectiveList);