diff options
Diffstat (limited to 'src/java/org/apache')
4 files changed, 34 insertions, 26 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java index c4fd42a35..e68698e57 100644 --- a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java +++ b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java @@ -146,4 +146,23 @@ public class ElementListUtils { return last.isForcedBreak(); } + /** + * Determines the position of the previous break before the start index on an + * element list. + * @param elems the element list + * @param startIndex the start index + * @return the position of the previous break, or -1 if there was no previous break + */ + public static int determinePreviousBreak(List elems, int startIndex) { + int prevBreak = startIndex - 1; + while (prevBreak >= 0) { + KnuthElement el = (KnuthElement)elems.get(prevBreak); + if (el.isPenalty() && el.getP() < KnuthElement.INFINITE) { + break; + } + prevBreak--; + } + return prevBreak; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java index 45e9990ea..583f8ffaa 100644 --- a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java +++ b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java @@ -692,14 +692,14 @@ public class SpaceResolver { * @param effectiveList the effective element list * @param startElementIndex index of the first element in the part to be processed * @param endElementIndex index of the last element in the part to be processed - * @param lastBreak index of the the break possibility just before this part (used to + * @param prevBreak index of the the break possibility just before this part (used to * identify a break condition, lastBreak <= 0 represents a no-break condition) */ public static void performConditionalsNotification(List effectiveList, - int startElementIndex, int endElementIndex, int lastBreak) { + int startElementIndex, int endElementIndex, int prevBreak) { KnuthElement el = null; - if (lastBreak > 0) { - el = (KnuthElement)effectiveList.get(lastBreak); + if (prevBreak > 0) { + el = (KnuthElement)effectiveList.get(prevBreak); } SpaceResolver.SpaceHandlingBreakPosition beforeBreak = null; SpaceResolver.SpaceHandlingBreakPosition afterBreak = null; diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index 5a98deac6..0ed202c6f 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -461,30 +461,15 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager int bodyFirstIndex = ((ListItemPosition) positionList.getFirst()).getBodyFirstIndex(); int bodyLastIndex = ((ListItemPosition) positionList.getLast()).getBodyLastIndex(); - int lastBreak; - //Determine last break if any - lastBreak = labelFirstIndex - 1; - while (lastBreak >= 0) { - KnuthElement el = (KnuthElement)labelList.get(lastBreak); - if (el.isPenalty() && el.getP() < KnuthElement.INFINITE) { - break; - } - lastBreak--; - } + //Determine previous break if any + int previousBreak = ElementListUtils.determinePreviousBreak(labelList, labelFirstIndex); SpaceResolver.performConditionalsNotification(labelList, - labelFirstIndex, labelLastIndex, lastBreak); - - //Determine last break if any - lastBreak = bodyFirstIndex - 1; - while (lastBreak >= 0) { - KnuthElement el = (KnuthElement)bodyList.get(lastBreak); - if (el.isPenalty() && el.getP() < KnuthElement.INFINITE) { - break; - } - lastBreak--; - } + labelFirstIndex, labelLastIndex, previousBreak); + + //Determine previous break if any + previousBreak = ElementListUtils.determinePreviousBreak(labelList, labelFirstIndex); SpaceResolver.performConditionalsNotification(bodyList, - bodyFirstIndex, bodyLastIndex, lastBreak); + bodyFirstIndex, bodyLastIndex, previousBreak); // add label areas if (labelFirstIndex <= labelLastIndex) { diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index 99028d915..9fabeccc5 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -49,6 +49,7 @@ import org.apache.fop.layoutmgr.ListElement; import org.apache.fop.layoutmgr.MinOptMaxUtil; import org.apache.fop.layoutmgr.Position; import org.apache.fop.layoutmgr.PositionIterator; +import org.apache.fop.layoutmgr.SpaceResolver; import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition; import org.apache.fop.traits.MinOptMax; @@ -948,6 +949,9 @@ public class TableContentLayoutManager implements PercentBaseContext { cellLM.setContentHeight(contentHeight); cellLM.setRowHeight(effCellHeight); //cellLM.setRowHeight(row.getHeight().opt); + int prevBreak = ElementListUtils.determinePreviousBreak(pgu.getElements(), startPos); + SpaceResolver.performConditionalsNotification(pgu.getElements(), + startPos, endPos, prevBreak); cellLM.addAreas(new KnuthPossPosIter(pgu.getElements(), startPos, endPos + 1), layoutContext); } |