aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2003-12-27 21:03:34 +0000
committerGlen Mazza <gmazza@apache.org>2003-12-27 21:03:34 +0000
commit3218d18b86a969583ac9ba7aaf830b90d62e6e3b (patch)
tree33ec04c79e84f8c4b998e1f66d39a3bf63d630b0 /src
parentd0cb3249faf74ff6aafb9005a447760c02c902c5 (diff)
downloadxmlgraphics-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.java37
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