aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop
diff options
context:
space:
mode:
authorSimon Pepping <spepping@apache.org>2004-05-29 09:07:59 +0000
committerSimon Pepping <spepping@apache.org>2004-05-29 09:07:59 +0000
commitab2c0a4f56557c613f870405d03968061384451c (patch)
treefbd989a80c7af500e15022c201b3789e3dddcb54 /src/java/org/apache/fop
parentec0d3c558af3272a4693944c0fcf13b93c209d44 (diff)
downloadxmlgraphics-fop-ab2c0a4f56557c613f870405d03968061384451c.tar.gz
xmlgraphics-fop-ab2c0a4f56557c613f870405d03968061384451c.zip
Remove trailing spaces at the end of a paragraph.
Modify the way to deal with BPs which have not been added to vecInlineBreaks. See bug 28706. The code was rewritten w.r.t. the submitted patch. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197652 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
-rw-r--r--src/java/org/apache/fop/layoutmgr/LineLayoutManager.java39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
index b32428953..b9dd60ba4 100644
--- a/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
@@ -244,8 +244,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
/* If we are not in justified text, we can end the line at
* prevBP.
*/
- vecInlineBreaks.add(bp);
if (prevBP == null) {
+ vecInlineBreaks.add(bp);
prevBP = bp;
}
break;
@@ -313,9 +313,15 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
if (!bp.isForcedBreak() && vecPossEnd.size() > 0) {
prevBP = getBestBP(vecPossEnd);
}
- // Backup child LM if necessary
- if (bp != prevBP && !prevCouldEndLine(prevBP)) {
- reset();
+ if (bp != prevBP) {
+ /** Remove BPs after prevBP
+ if condAllAreSuppressible returns true,
+ else backup child LM */
+ if (condAllAreSuppressible(prevBP)) {
+ removeAllBP(prevBP);
+ } else {
+ reset();
+ }
}
// Don't justify last line in the sequence or if forced line-end
@@ -388,27 +394,18 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
return true;
}
- /** Test whether all breakposs in vecInlineBreaks
- back to and including prev could end line */
- private boolean prevCouldEndLine(BreakPoss prev) {
+ /** Return true if we are at the end of this LM,
+ and BPs after prev have been added to vecInlineBreaks
+ and all breakposs in vecInlineBreaks
+ back to and excluding prev are suppressible */
+ private boolean condAllAreSuppressible(BreakPoss prev) {
if (!isFinished()) {
return false;
}
- ListIterator bpIter =
- vecInlineBreaks.listIterator(vecInlineBreaks.size());
- boolean couldEndLine = true;
- while (bpIter.hasPrevious()) {
- BreakPoss bp = (BreakPoss) bpIter.previous();
- if (bp == prev) {
- break;
- } else {
- couldEndLine = bp.isSuppressible();
- if (!couldEndLine) {
- break;
- }
- }
+ if (vecInlineBreaks.get(vecInlineBreaks.size() - 1) == prev) {
+ return false;
}
- return couldEndLine;
+ return allAreSuppressible(prev);
}
/** Test whether all breakposs in vecInlineBreaks