gmazza 2003/12/27 13:03:34
Modified: src/java/org/apache/fop/layoutmgr LineLayoutManager.java
Log:
Bug 25756 (Patch by Simon Pepping): Remove line BPs where line consists
only of suppressible content (whitespace).
Revision Changes Path
1.9 +36 -1 xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
Index: LineLayoutManager.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- LineLayoutManager.java 23 Dec 2003 20:41:58 -0000 1.8
+++ LineLayoutManager.java 27 Dec 2003 21:03:34 -0000 1.9
@@ -325,7 +325,15 @@
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
@@ -419,6 +427,33 @@
if (!couldEndLine || bp == prev) break;
}
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,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]