You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ad...@apache.org on 2009/03/22 20:34:39 UTC
svn commit: r757241 - in
/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr:
BlockStackingLayoutManager.java ElementListUtils.java FlowLayoutManager.java
Author: adelmelle
Date: Sun Mar 22 19:34:39 2009
New Revision: 757241
URL: http://svn.apache.org/viewvc?rev=757241&view=rev
Log:
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.
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=757241&r1=757240&r2=757241&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java Sun Mar 22 19:34:39 2009
@@ -347,18 +347,19 @@
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
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java?rev=757241&r1=757240&r2=757241&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ElementListUtils.java Sun Mar 22 19:34:39 2009
@@ -194,6 +194,16 @@
}
/**
+ * 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 @@
return prevBreak;
}
-}
+}
\ No newline at end of file
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=757241&r1=757240&r2=757241&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java Sun Mar 22 19:34:39 2009
@@ -83,13 +83,11 @@
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 @@
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;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org