aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2009-03-22 19:34:39 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2009-03-22 19:34:39 +0000
commit15487f97808f907a319102362d07771241aa5a7f (patch)
tree16fe4447dd41a643b1572581a49ee6474a6265c2 /src/java
parent39846b082abe7df751bd45cd70abe61e842fbb20 (diff)
downloadxmlgraphics-fop-15487f97808f907a319102362d07771241aa5a7f.tar.gz
xmlgraphics-fop-15487f97808f907a319102362d07771241aa5a7f.zip
Add startsWithForcedBreak() utility method to ElementListUtils.
Avoid generating "in-between" penalties if the content list that will be appended already starts with a forced break. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@757241 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java15
-rw-r--r--src/java/org/apache/fop/layoutmgr/ElementListUtils.java12
-rw-r--r--src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java39
3 files changed, 37 insertions, 29 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index 1f18a67a0..5a44c8391 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -347,18 +347,19 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
return returnList;
} else {
- if (prevLM != null) {
- // there is a block handled by prevLM
- // before the one handled by curLM
- addInBetweenBreak(contentList, context, childLC);
- }
if (returnedList == null || returnedList.isEmpty()) {
//Avoid NoSuchElementException below (happens with empty blocks)
continue;
}
+ if (prevLM != null
+ && !ElementListUtils.startsWithForcedBreak(returnedList)) {
+ // there is a block handled by prevLM before the one
+ // handled by curLM, and the one handled
+ // by the current LM does not begin with a break
+ addInBetweenBreak(contentList, context, childLC);
+ }
contentList.addAll(returnedList);
- if (((ListElement) ListUtil.getLast(returnedList))
- .isForcedBreak()) {
+ if (ElementListUtils.endsWithForcedBreak(returnedList)) {
// a descendant of this block has break-after
if (curLM.isFinished() && !hasNextChildLM()) {
forcedBreakAfterLast = (BreakElement) ListUtil
diff --git a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
index d7f854a42..7e337dc6b 100644
--- a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
+++ b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
@@ -194,6 +194,16 @@ public final class ElementListUtils {
}
/**
+ * Indicates whether the given element list starts with a forced break.
+ * @param elems the element list
+ * @return true if the list starts with a forced break
+ */
+ public static boolean startsWithForcedBreak(List elems) {
+ return !elems.isEmpty()
+ && ((ListElement) elems.get(0)).isForcedBreak();
+ }
+
+ /**
* Indicates whether the given element list ends with a penalty with a non-infinite penalty
* value.
* @param elems the element list
@@ -229,4 +239,4 @@ public final class ElementListUtils {
return prevBreak;
}
-}
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
index 245fa7235..597032848 100644
--- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
@@ -83,13 +83,11 @@ public class FlowLayoutManager extends BlockStackingLayoutManager
int span = EN_NONE;
int disableColumnBalancing = EN_FALSE;
if (curLM instanceof BlockLayoutManager) {
- span = ((BlockLayoutManager)curLM).getBlockFO().getSpan();
- disableColumnBalancing = ((BlockLayoutManager) curLM).getBlockFO()
- .getDisableColumnBalancing();
+ span = ((BlockLayoutManager)curLM).getSpan();
+ disableColumnBalancing = ((BlockLayoutManager) curLM).getDisableColumnBalancing();
} else if (curLM instanceof BlockContainerLayoutManager) {
- span = ((BlockContainerLayoutManager)curLM).getBlockContainerFO().getSpan();
- disableColumnBalancing = ((BlockContainerLayoutManager) curLM)
- .getBlockContainerFO().getDisableColumnBalancing();
+ span = ((BlockContainerLayoutManager)curLM).getSpan();
+ disableColumnBalancing = ((BlockContainerLayoutManager) curLM).getDisableColumnBalancing();
}
int currentSpan = context.getCurrentSpan();
@@ -130,24 +128,23 @@ public class FlowLayoutManager extends BlockStackingLayoutManager
returnList.addAll(returnedList);
SpaceResolver.resolveElementList(returnList);
return returnList;
- } else {
- if (returnList.size() > 0) {
+ } else if (returnedList.size() > 0) {
+ if (returnList.size() > 0
+ && !ElementListUtils.startsWithForcedBreak(returnedList)) {
addInBetweenBreak(returnList, context, childLC);
}
- if (returnedList.size() > 0) {
- returnList.addAll(returnedList);
- if (ElementListUtils.endsWithForcedBreak(returnList)) {
- if (curLM.isFinished() && !hasNextChildLM()) {
- //If the layout manager is finished at this point, the pending
- //marks become irrelevant.
- childLC.clearPendingMarks();
- //setFinished(true);
- break;
- }
- // a descendant of this flow has break-after
- SpaceResolver.resolveElementList(returnList);
- return returnList;
+ returnList.addAll(returnedList);
+ if (ElementListUtils.endsWithForcedBreak(returnList)) {
+ if (curLM.isFinished() && !hasNextChildLM()) {
+ //If the layout manager is finished at this point, the pending
+ //marks become irrelevant.
+ childLC.clearPendingMarks();
+ //setFinished(true);
+ break;
}
+ // a descendant of this flow has break-after
+ SpaceResolver.resolveElementList(returnList);
+ return returnList;
}
}