diff options
author | Simon Steiner <ssteiner@apache.org> | 2018-06-20 11:32:05 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2018-06-20 11:32:05 +0000 |
commit | ee143ede26953cd06b1ac5ce7a49d38086c85e1c (patch) | |
tree | aa55287ff20e280a75af855246776ad6e3b91513 /fop-core | |
parent | 3c80c6cd977a524345ac731c84f358e42b1017e4 (diff) | |
download | xmlgraphics-fop-ee143ede26953cd06b1ac5ce7a49d38086c85e1c.tar.gz xmlgraphics-fop-ee143ede26953cd06b1ac5ce7a49d38086c85e1c.zip |
FOP-2799: Only reduce penalty if there is a existing break
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1833908 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core')
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index 69b78c9bc..9d9769a7c 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -448,12 +448,9 @@ public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManage // add the original line where the float was but without the float now returnList.add(new KnuthBlockBox(boxHeight, footnoteList, stepPosition, false)); } - if (originalBodyPosition != null) { - LayoutManager lm = originalBodyPosition.getLM(); - if ((lm instanceof ListBlockLayoutManager || lm instanceof BlockLayoutManager) - && getKeepWithPrevious().isAuto()) { - stepPenalty++; - } + if (originalBodyPosition != null && getKeepWithPrevious().isAuto() + && shouldWeAvoidBreak(returnList, originalBodyPosition.getLM())) { + stepPenalty++; } if (addedBoxHeight < totalHeight) { Keep keep = keepWithNextActive.compare(getKeepTogether()); @@ -469,6 +466,26 @@ public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManage return returnList; } + private boolean shouldWeAvoidBreak(List returnList, LayoutManager lm) { + if (lm instanceof BlockLayoutManager) { + return true; + } + if (lm instanceof ListBlockLayoutManager) { + int penaltyShootout = 0; + for (Object o : returnList) { + if (o instanceof BreakElement) { + if (((BreakElement) o).getPenaltyValue() > 0) { + penaltyShootout++; + } else { + penaltyShootout--; + } + } + } + return penaltyShootout > 0; + } + return false; + } + private int getNextStep(List[] elementLists, int[] start, int[] end, int[] partialHeights) { // backup of partial heights int[] backupHeights = {partialHeights[0], partialHeights[1]}; |