]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bug 25756 (Patch by Simon Pepping): Remove line BPs where line consists
authorGlen Mazza <gmazza@apache.org>
Sat, 27 Dec 2003 21:03:34 +0000 (21:03 +0000)
committerGlen Mazza <gmazza@apache.org>
Sat, 27 Dec 2003 21:03:34 +0000 (21:03 +0000)
only of suppressible content (whitespace).

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197058 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/LineLayoutManager.java

index 32a280f39608d327295f150379d3afbf419fabc1..63ba1d2ea5191c8ad0d4ac8795b8f4fd7db9e768 100644 (file)
@@ -325,7 +325,15 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
             return null;
         }
         if (prevBP == null) {
-            prevBP = bp;
+            BreakPoss prevLineEnd = (iPrevLineEnd == 0)
+                ? null
+                : (BreakPoss) vecInlineBreaks.get(iPrevLineEnd);
+            if (allAreSuppressible(prevLineEnd)) {
+                removeAllBP(prevLineEnd);
+                return null;
+            } else {
+                prevBP = bp;
+            }
         }
 
         // Choose the best break
@@ -421,6 +429,33 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
         return couldEndLine;
     }
 
+    /** Test whether all breakposs in vecInlineBreaks
+        back to and excluding prev are suppressible */
+    private boolean allAreSuppressible(BreakPoss prev) {
+        ListIterator bpIter =
+            vecInlineBreaks.listIterator(vecInlineBreaks.size());
+        boolean allAreSuppressible = true;
+        BreakPoss bp;
+        while (bpIter.hasPrevious()
+               && (bp = (BreakPoss) bpIter.previous()) != prev
+               && (allAreSuppressible = bp.isSuppressible())) {
+        }
+        return allAreSuppressible;
+    }
+
+    /** Remove all BPs from the end back to and excluding prev
+        from vecInlineBreaks*/
+    private void removeAllBP(BreakPoss prev) {
+        int iPrev;
+        if (prev == null) {
+            vecInlineBreaks.clear();
+        } else if ((iPrev = vecInlineBreaks.indexOf(prev)) != -1) {
+            for (int i = vecInlineBreaks.size(); iPrev < i; --i) {
+                vecInlineBreaks.remove(i);
+            }
+        }
+    }
+
     private HyphContext getHyphenContext(BreakPoss prev,
                                          BreakPoss newBP) {
         // Get a "word" to hyphenate by getting characters from all