diff options
author | Glen Mazza <gmazza@apache.org> | 2003-12-27 21:03:34 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2003-12-27 21:03:34 +0000 |
commit | 3218d18b86a969583ac9ba7aaf830b90d62e6e3b (patch) | |
tree | 33ec04c79e84f8c4b998e1f66d39a3bf63d630b0 /src | |
parent | d0cb3249faf74ff6aafb9005a447760c02c902c5 (diff) | |
download | xmlgraphics-fop-3218d18b86a969583ac9ba7aaf830b90d62e6e3b.tar.gz xmlgraphics-fop-3218d18b86a969583ac9ba7aaf830b90d62e6e3b.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/LineLayoutManager.java | 37 |
1 files changed, 36 insertions, 1 deletions
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 |