You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by lf...@apache.org on 2005/08/25 14:19:42 UTC

svn commit: r240050 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java

Author: lfurini
Date: Thu Aug 25 05:19:19 2005
New Revision: 240050

URL: http://svn.apache.org/viewcvs?rev=240050&view=rev
Log:
Fix for bug 35940
Some more checks in order to remove all the elements representing trailing spaces at the end of a paragraph

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=240050&r1=240049&r2=240050&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Thu Aug 25 05:19:19 2005
@@ -233,11 +233,8 @@
         }
 
         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) {
@@ -268,6 +265,45 @@
             } else {
                 this.clear();
                 return null;
+            }
+        }
+
+        /**
+         * 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);
+                }
             }
         }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org