aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLuca Furini <lfurini@apache.org>2005-08-25 12:19:19 +0000
committerLuca Furini <lfurini@apache.org>2005-08-25 12:19:19 +0000
commitb811e764d5bc71e3dc3c4ac8f7a43145aabe7df5 (patch)
tree7379eb97ebe12432de8a3c41fb306c957b59c5cf /src
parent77c546387484364c1e6efdf439ff9be8a1af4057 (diff)
downloadxmlgraphics-fop-b811e764d5bc71e3dc3c4ac8f7a43145aabe7df5.tar.gz
xmlgraphics-fop-b811e764d5bc71e3dc3c4ac8f7a43145aabe7df5.zip
Fix for bug 35940
Some more checks in order to remove all the elements representing trailing spaces at the end of a paragraph git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@240050 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java46
1 files changed, 41 insertions, 5 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index f51e6af2b..e294908a8 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -233,11 +233,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
public KnuthSequence endSequence() {
- // remove glue and penalty item at the end of the paragraph
- while (this.size() > ignoreAtStart
- && !((KnuthElement)this.get(this.size() - 1)).isBox()) {
- this.remove(this.size() - 1);
- }
+ // remove elements representig spaces at the end of the paragraph
+ removeElementsForTrailingSpaces();
if (this.size() > ignoreAtStart) {
if (bTextAlignment == EN_CENTER
&& bTextAlignmentLast != EN_JUSTIFY) {
@@ -271,6 +268,45 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
}
+ /**
+ * remove elements representing spaces at the end of the paragraph;
+ * the text could have one or more trailing spaces, each of them
+ * being either a normal space or a non-breaking space;
+ * according to the alignment, the sub-sequence of elements
+ * representing each space has a different "pattern"
+ */
+ private void removeElementsForTrailingSpaces() {
+ KnuthElement removedElement;
+ while (this.size() > ignoreAtStart
+ && ((KnuthElement) this.get(this.size() - 1)).isGlue()) {
+ if (textAlignment == EN_CENTER) {
+ // centered text: the pattern is
+ // <glue> <penaly> <glue> <box> <penaly> <glue>
+ removedElement = (KnuthGlue) this.remove(this.size() - 1);
+ removedElement = (KnuthPenalty) this.remove(this.size() - 1);
+ removedElement = (KnuthBox) this.remove(this.size() - 1);
+ removedElement = (KnuthGlue) this.remove(this.size() - 1);
+ removedElement = (KnuthPenalty) this.remove(this.size() - 1);
+ removedElement = (KnuthGlue) this.remove(this.size() - 1);
+ } else if (textAlignment == EN_START || textAlignment == EN_END) {
+ // left- or right-aligned text: the pattern is
+ // <glue> <penalty> <glue>
+ removedElement = (KnuthGlue) this.remove(this.size() - 1);
+ removedElement = (KnuthPenalty) this.remove(this.size() - 1);
+ removedElement = (KnuthGlue) this.remove(this.size() - 1);
+ } else {
+ // justified text: the pattern is
+ // <glue>
+ removedElement = (KnuthGlue) this.remove(this.size() - 1);
+ }
+ // if the space was a non-breaking one, there is also a penalty
+ if (this.size() > ignoreAtStart
+ && ((KnuthElement) this.get(this.size() - 1)).isPenalty()) {
+ removedElement = (KnuthPenalty) this.remove(this.size() - 1);
+ }
+ }
+ }
+
private void addALetterSpace() {
KnuthBox prevBox = (KnuthBox) removeLast();
LinkedList oldList = new LinkedList();