aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-06-02 12:50:55 +0000
committerJeremias Maerki <jeremias@apache.org>2008-06-02 12:50:55 +0000
commitf384a587d01937d1f0ddc2318070157c563b072b (patch)
tree60e57ad46d1a82aa70792480545dd292e1c28aa6
parenta3f12ad2eaf2d0edf78ed9e126803db1ebd296b8 (diff)
downloadxmlgraphics-fop-f384a587d01937d1f0ddc2318070157c563b072b.tar.gz
xmlgraphics-fop-f384a587d01937d1f0ddc2318070157c563b072b.zip
Integer keeps inside multi-line blocks and in between block-paragraphs.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@662417 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java31
-rw-r--r--test/layoutengine/standard-testcases/block_keep-together_integers_1.xml17
2 files changed, 36 insertions, 12 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index 8c46796eb..c9f72e64f 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -46,6 +46,7 @@ import org.apache.fop.layoutmgr.BreakElement;
import org.apache.fop.layoutmgr.BreakingAlgorithm;
import org.apache.fop.layoutmgr.ElementListObserver;
import org.apache.fop.layoutmgr.InlineKnuthSequence;
+import org.apache.fop.layoutmgr.KeepUtil;
import org.apache.fop.layoutmgr.KnuthBlockBox;
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthElement;
@@ -1052,11 +1053,14 @@ public class LineLayoutManager extends InlineStackingLayoutManager
LinkedList returnList = new LinkedList();
for (int p = 0; p < knuthParagraphs.size(); p++) {
- // null penalty between paragraphs
- if (p > 0 && !((BlockLevelLayoutManager) parentLM).mustKeepTogether()) {
- returnList.add(new BreakElement(
- new Position(this), 0, context));
- //returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
+ // penalty between paragraphs
+ if (p > 0) {
+ int strength = getKeepTogetherStrength();
+ int penalty = KeepUtil.getPenaltyForKeep(strength);
+ if (penalty < KnuthElement.INFINITE) {
+ returnList.add(new BreakElement(
+ new Position(this), penalty, context));
+ }
}
LineLayoutPossibilities llPoss;
@@ -1090,14 +1094,17 @@ public class LineLayoutManager extends InlineStackingLayoutManager
for (int i = 0;
i < llPoss.getChosenLineCount();
i++) {
- if (!((BlockLevelLayoutManager) parentLM).mustKeepTogether()
+ if (returnList.size() > 0
+ && i > 0 //if i==0 break generated above already
&& i >= fobj.getOrphans()
- && i <= llPoss.getChosenLineCount() - fobj.getWidows()
- && returnList.size() > 0) {
- // null penalty allowing a page break between lines
- returnList.add(new BreakElement(
- returnPosition, 0, context));
- //returnList.add(new KnuthPenalty(0, 0, false, returnPosition, false));
+ && i <= llPoss.getChosenLineCount() - fobj.getWidows()) {
+ // penalty allowing a page break between lines
+ int strength = getKeepTogetherStrength();
+ int penalty = KeepUtil.getPenaltyForKeep(strength);
+ if (penalty < KnuthElement.INFINITE) {
+ returnList.add(new BreakElement(
+ returnPosition, penalty, context));
+ }
}
int endIndex
= ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos();
diff --git a/test/layoutengine/standard-testcases/block_keep-together_integers_1.xml b/test/layoutengine/standard-testcases/block_keep-together_integers_1.xml
index f6027bf01..8ad263fcb 100644
--- a/test/layoutengine/standard-testcases/block_keep-together_integers_1.xml
+++ b/test/layoutengine/standard-testcases/block_keep-together_integers_1.xml
@@ -54,6 +54,11 @@
</fo:block>
<fo:block>block10</fo:block>
</fo:block>
+ <fo:block keep-together.within-column="5" linefeed-treatment="preserve">The quick brown fox jumps over the lazy dog.
+ The quick brown fox jumps over the lazy dog.
+ The quick brown fox jumps over the lazy dog.
+ The quick brown fox jumps over the lazy dog.
+ </fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
@@ -76,7 +81,9 @@
<box/>
<penalty w="0" p="0"/>
<box/> <!-- block 3 -->
+ <penalty w="0" p="999"/>
<box/>
+ <penalty w="0" p="999"/>
<box/>
<penalty w="0" p="0"/>
<box/> <!-- block4 -->
@@ -91,7 +98,17 @@
<penalty w="0" p="INF"/>
<box/> <!-- block9 -->
<penalty w="0" p="999"/>
+ <box/> <!-- block10 -->
+ <penalty w="0" p="0"/>
+
+ <box/>
+ <penalty w="0" p="999"/>
+ <box/>
+ <penalty w="0" p="999"/>
<box/>
+ <penalty w="0" p="999"/>
+ <box/>
+
<skip>3</skip>
</element-list>