From 3218d18b86a969583ac9ba7aaf830b90d62e6e3b Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Sat, 27 Dec 2003 21:03:34 +0000 Subject: [PATCH] Bug 25756 (Patch by Simon Pepping): Remove line BPs where line consists only of suppressible content (whitespace). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197058 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/LineLayoutManager.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java index 32a280f39..63ba1d2ea 100644 --- a/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java @@ -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 -- 2.39.5