Author: spepping
Date: Wed Nov 21 12:04:27 2007
New Revision: 597197

URL: http://svn.apache.org/viewvc?rev=597197&view=rev
Log:
Implemented fox:widow-content-limit and fox:orphan-content-limit,
small feature but hard to solve. The extent of a sublist of Knuth
elements to which one or both of these properties apply (actually the
sublist generated by list-block) is registered in a new SubSequence
object, which is held by the BlockKnuthSequence. At the end of the
sublist the properties are applied, i.e. the offending legal breaks
are removed. Until then the sublist is not presented to the
pagebreaking algorithm. To make it possible to apply this mechanism to
footnotes, the type of FBLM.elementList was changed to
BlockKnuthSequence.

Modified:
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageBreaker.java
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ParagraphListElement.java
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/LineBreakingListElement.java
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
    
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemListElement.java

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
 Wed Nov 21 12:04:27 2007
@@ -22,6 +22,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Stack;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java
 Wed Nov 21 12:04:27 2007
@@ -20,7 +20,7 @@
 package org.apache.fop.layoutmgr;
 
 import java.util.List;
-
+import java.util.Stack;
 
 /**
  * Represents a list of block level Knuth elements.
@@ -29,6 +29,8 @@
     
     private boolean isClosed = false;
     
+    private Stack subSequences;
+    
     /**
      * Creates a new and empty list.
      */
@@ -83,4 +85,57 @@
         return this;
     }
 
+    public class SubSequence {
+        private KnuthBox firstBox = null;
+        private int widowRowLimit = 0;
+        private SubSequence(KnuthBox firstBox) {
+            this.firstBox = firstBox;
+        }
+        private SubSequence(KnuthBox firstBox, int widowRowLimit) {
+            this.firstBox = firstBox;
+            this.widowRowLimit = widowRowLimit;
+        }
+        
+        /**
+         * @return the firstBox
+         */
+        public KnuthBox getFirstBox() {
+            return firstBox;
+        }
+        
+        /**
+         * @return the widowRowLimit
+         */
+        public int getWidowRowLimit() {
+            return widowRowLimit;
+        }
+
+    }
+    
+    public void addSubSequence(KnuthBox firstBox) {
+        if (subSequences == null) {
+            subSequences = new Stack();
+        }
+        subSequences.push(new SubSequence(firstBox));
+    }
+
+    public void addSubSequence(KnuthBox firstBox, int orphanRowLimit) {
+        if (subSequences == null) {
+            subSequences = new Stack();
+        }
+        subSequences.push(new SubSequence(firstBox, orphanRowLimit));
+    }
+    
+    public boolean hasSubSequence() {
+        return !(subSequences == null || subSequences.isEmpty());
+    }
+    
+    public SubSequence getSubSequence() {
+        return (SubSequence) subSequences.peek();
+    }
+
+    public SubSequence removeSubSequence() {
+        return (SubSequence) subSequences.pop();
+    }
+    
 }

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
 Wed Nov 21 12:04:27 2007
@@ -592,7 +592,7 @@
      * @param seq the Knuth Sequence
      * @param startIndex the start index
      */
-    void resolveElements(List seq, int startIndex) {
+    void resolveElements(KnuthSequence seq, int startIndex) {
         ;
     }
 

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ElementListUtils.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
 Wed Nov 21 12:04:27 2007
@@ -19,6 +19,7 @@
 
 package org.apache.fop.layoutmgr;
 
+import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
@@ -34,7 +35,7 @@
      * Removes all legal breaks in an element list.
      * @param elements the element list
      */
-    public static void removeLegalBreaks(LinkedList elements) {
+    public static void removeLegalBreaks(List elements) {
         ListIterator i = elements.listIterator();
         while (i.hasNext()) {
             ListElement el = (ListElement)i.next();
@@ -63,7 +64,7 @@
      * @param constraint min/opt/max value to restrict the range in which the 
breaks are removed.
      * @return true if the opt constraint is bigger than the list contents
      */
-    public static boolean removeLegalBreaks(LinkedList elements, MinOptMax 
constraint) {
+    public static boolean removeLegalBreaks(List elements, MinOptMax 
constraint) {
         return removeLegalBreaks(elements, constraint.opt);
     }
     
@@ -75,7 +76,7 @@
      * @param constraint value to restrict the range in which the breaks are 
removed.
      * @return true if the constraint is bigger than the list contents
      */
-    public static boolean removeLegalBreaks(LinkedList elements, int 
constraint) {
+    public static boolean removeLegalBreaks(List elements, int constraint) {
         int len = 0;
         ListIterator iter = elements.listIterator();
         while (iter.hasNext()) {
@@ -122,7 +123,7 @@
      * @param constraint value to restrict the range in which the breaks are 
removed.
      * @return true if the constraint is bigger than the list contents
      */
-    public static boolean removeLegalBreaksFromEnd(LinkedList elements, int 
constraint) {
+    public static boolean removeLegalBreaksFromEnd(List elements, int 
constraint) {
         int len = 0;
         ListIterator i = elements.listIterator(elements.size());
         while (i.hasPrevious()) {
@@ -231,6 +232,32 @@
             prevBreak--;
         }
         return prevBreak;
+    }
+    
+    public static KnuthBox firstKnuthBox(List list) {
+        Iterator iter = list.iterator();
+        KnuthBox box = null;
+        while (iter.hasNext()) {
+            Object o = iter.next();
+            if (o instanceof KnuthBox) {
+                box = (KnuthBox) o;
+                break;
+            }
+        }
+        return box;
+    }
+    
+    public static KnuthBox lastKnuthBox(List list) {
+        ListIterator iter = list.listIterator(list.size());
+        KnuthBox box = null;
+        while (iter.hasPrevious()) {
+            Object o = iter.previous();
+            if (o instanceof KnuthBox) {
+                box = (KnuthBox) o;
+                break;
+            }
+        }
+        return box;
     }
     
 }

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
 Wed Nov 21 12:04:27 2007
@@ -30,7 +30,7 @@
 public class FootnoteBodyLayoutManager extends BlockStackingLayoutManager {
     
     /* Holds the Knuth elements of the footnote */
-    private LinkedList elementList = null;
+    private BlockKnuthSequence elementList = null;
 
     /**
      * Creates a new FootnoteBodyLayoutManager.
@@ -97,7 +97,7 @@
     /**
      * @return the elementList
      */
-    public LinkedList getElementList() {
+    public BlockKnuthSequence getElementList() {
         return elementList;
     }
 
@@ -106,6 +106,7 @@
      * @param alignment
      */
     public void getKnuthElements(LayoutContext context, int alignment) {
-        this.elementList = getNextKnuthElements(context, alignment);
+        LinkedList returnedList = getNextKnuthElements(context, alignment); 
+        this.elementList = new BlockKnuthSequence(returnedList); 
     }
 }

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageBreaker.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageBreaker.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageBreaker.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageBreaker.java
 Wed Nov 21 12:04:27 2007
@@ -412,7 +412,7 @@
             || pbp.footnoteFirstElementIndex <= pbp.footnoteLastElementIndex) {
             // call addAreas() for each FootnoteBodyLM
             for (int i = pbp.footnoteFirstListIndex; i <= 
pbp.footnoteLastListIndex; i++) {
-                LinkedList elementList = alg.getFootnoteList(i);
+                BlockKnuthSequence elementList = alg.getFootnoteList(i);
                 int firstIndex = (i == pbp.footnoteFirstListIndex 
                         ? pbp.footnoteFirstElementIndex : 0);
                 int lastIndex = (i == pbp.footnoteLastListIndex 

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
 Wed Nov 21 12:04:27 2007
@@ -30,8 +30,8 @@
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.layoutmgr.AbstractBreaker.PageBreakPosition;
+import org.apache.fop.layoutmgr.BlockKnuthSequence.SubSequence;
 import org.apache.fop.layoutmgr.list.LineBreakingListElement;
-import org.apache.fop.layoutmgr.list.ListItemListElement;
 import org.apache.fop.traits.MinOptMax;
 
 class PageBreakingAlgorithm extends BreakingAlgorithm {
@@ -249,7 +249,7 @@
         // compute the total length of the footnotes
         ListIterator elementListsIterator = elementLists.listIterator();
         while (elementListsIterator.hasNext()) {
-            LinkedList noteList = (LinkedList) elementListsIterator.next();
+            BlockKnuthSequence noteList = (BlockKnuthSequence) 
elementListsIterator.next();
             
             /* Line breaking and space resolution
              * (Note: this does not respect possible stacking constraints 
@@ -293,7 +293,7 @@
 
     private void resetFootnotes(LinkedList elementLists) {
         for (int i = 0; i < elementLists.size(); i++) {
-            LinkedList removedList = (LinkedList) 
footnotesList.remove(footnotesList.size() - 1);
+            footnotesList.remove(footnotesList.size() - 1);
             lengthList.remove(lengthList.size() - 1);
 
             // update totalFootnotesLength
@@ -336,7 +336,7 @@
                     actualWidth += allFootnotes;
                     insertedFootnotesLength = pageNode.totalFootnotes + 
allFootnotes;
                     footnoteListIndex = footnotesList.size() - 1;
-                    footnoteElementIndex = ((LinkedList) 
footnotesList.get(footnoteListIndex)).size() - 1;
+                    footnoteElementIndex = ((List) 
footnotesList.get(footnoteListIndex)).size() - 1;
                 } else if (((canDeferOldFootnotes = 
checkCanDeferOldFootnotes(pageNode, elementIndex))
                             || newFootnotes)
                            && (footnoteSplit = getFootnoteSplit(pageNode, 
getLineWidth() - actualWidth,
@@ -360,7 +360,7 @@
                     actualWidth += allFootnotes;
                     insertedFootnotesLength = pageNode.totalFootnotes + 
allFootnotes;
                     footnoteListIndex = footnotesList.size() - 1;
-                    footnoteElementIndex = ((LinkedList) 
footnotesList.get(footnoteListIndex)).size() - 1;
+                    footnoteElementIndex = ((List) 
footnotesList.get(footnoteListIndex)).size() - 1;
                 }
             } else {
                 // all footnotes have already been placed on previous pages
@@ -443,7 +443,7 @@
         return ((newFootnotes
                  && firstNewFootnoteIndex != 0
                  && (listIndex < firstNewFootnoteIndex - 1
-                     || elementIndex < ((LinkedList) 
footnotesList.get(listIndex)).size() - 1))
+                     || elementIndex < ((List) 
footnotesList.get(listIndex)).size() - 1))
                 || length < totalFootnotesLength);
     }
 
@@ -485,7 +485,7 @@
             // already placed in a page: advance to the next element
             int listIndex = prevListIndex;
             int elementIndex = prevElementIndex;
-            if (elementIndex == ((LinkedList) 
footnotesList.get(listIndex)).size() - 1) {
+            if (elementIndex == ((List) footnotesList.get(listIndex)).size() - 
1) {
                 listIndex++;
                 elementIndex = 0;
             } else {
@@ -518,7 +518,7 @@
             }
 
             // try adding a split of the next note
-            noteListIterator = ((LinkedList) 
footnotesList.get(listIndex)).listIterator(elementIndex);
+            noteListIterator = ((List) 
footnotesList.get(listIndex)).listIterator(elementIndex);
 
             int prevSplitLength = 0;
             int prevIndex = -1;
@@ -576,7 +576,7 @@
                 footnoteListIndex = (prevIndex != -1) ? listIndex : listIndex 
- 1;
                 footnoteElementIndex = (prevIndex != -1)
                     ? prevIndex 
-                    : ((LinkedList) 
footnotesList.get(footnoteListIndex)).size() - 1;
+                    : ((List) footnotesList.get(footnoteListIndex)).size() - 1;
             }
             return prevSplitLength;
         }
@@ -646,7 +646,7 @@
                                 * deferredFootnoteDemerits;
             }
             if (footnoteElementIndex 
-                    < ((LinkedList) 
footnotesList.get(footnoteListIndex)).size() - 1) {
+                    < ((List) footnotesList.get(footnoteListIndex)).size() - 
1) {
                 // add demerits for the footnote split between pages
                 demerits += splitFootnoteDemerits;
             }
@@ -686,7 +686,7 @@
                                 - insertedFootnotesLength;
                 insertedFootnotesLength = 
((Integer)lengthList.get(footnoteListIndex)).intValue();
                 footnoteElementIndex
-                    = 
((LinkedList)footnotesList.get(footnoteListIndex)).size() - 1;
+                    = ((List)footnotesList.get(footnoteListIndex)).size() - 1;
             } else if ((split = getFootnoteSplit(footnoteListIndex, 
footnoteElementIndex,
                                                  insertedFootnotesLength, 
availableBPD, true))
                        > 0) {
@@ -787,7 +787,7 @@
         int firstListIndex = ((KnuthPageNode) 
bestActiveNode.previous).footnoteListIndex;
         int firstElementIndex = ((KnuthPageNode) 
bestActiveNode.previous).footnoteElementIndex;
         if (footnotesList != null
-            && firstElementIndex == ((LinkedList) 
footnotesList.get(firstListIndex)).size() - 1) {
+            && firstElementIndex == ((List) 
footnotesList.get(firstListIndex)).size() - 1) {
             // advance to the next list
             firstListIndex++;
             firstElementIndex = 0;
@@ -822,19 +822,61 @@
      * @param startIndex the start index
      * @param doall resolve all elements or not
      */
-    void resolveElements(List seq, int startIndex, boolean doall) {
+    void resolveElements(BlockKnuthSequence seq, int startIndex, boolean 
doall) {
         for (int i = startIndex; i < seq.size(); ++i) {
             ListElement elt = (ListElement) seq.get(i);
             if (!doall && !elt.isUnresolvedElement()
-                    && !(elt instanceof LineBreakingListElement)) {
+                    && !(elt instanceof LineBreakingListElement)
+                    && !((AbstractBreaker.BlockSequence)seq).hasSubSequence()) 
{
                 break;
             }
             if (elt instanceof LineBreakingListElement) {
-                LinkedList lineElts = ((LineBreakingListElement) 
elt).doLineBreaking();
-                if (((LineBreakingListElement) elt).lineBreakingIsFinished()) {
+                LineBreakingListElement lbelt = (LineBreakingListElement) elt;
+                boolean startOfSubsequence =
+                    lbelt.lineBreakingIsStarting() && 
lbelt.isStartOfSubsequence();
+                LinkedList lineElts = lbelt.doLineBreaking();
+                
+                if (startOfSubsequence) {
+                    KnuthBox box = ElementListUtils.firstKnuthBox(lineElts);
+                    if (box == null) {
+                        log.debug("Could not find a KnuthBox in step");
+                    } else {
+                        seq.addSubSequence(box, lbelt.getWidowRowLimit());
+                    }
+                }
+                
+                boolean endOfSubsequence = false;
+                if (lbelt.lineBreakingIsFinished()) {
                     seq.remove(i);
+                    endOfSubsequence = lbelt.isEndOfSubsequence();
                 }
                 seq.addAll(i, lineElts);
+                
+                if (endOfSubsequence) {
+                    SubSequence sseq;
+                    // may throw EmptyStackException
+                    sseq = seq.removeSubSequence();
+                    int widowRowLimit = sseq.getWidowRowLimit();
+                    int orphanRowLimit = lbelt.getOrphanRowLimit();
+                    Object nextElt = seq.get(i);
+                    KnuthBox box = ElementListUtils.lastKnuthBox(lineElts);
+                    if (box == null) {
+                        log.debug("Could not find a KnuthBox in step");
+                    } else {
+                        int fromIndex = seq.indexOf(sseq.getFirstBox());
+                        int toIndex = seq.indexOf(box);
+                        List subList = seq.subList(fromIndex, toIndex+1);
+                        SpaceResolver.resolveElementList(subList, 0, true);
+                        if (widowRowLimit != 0) {
+                            ElementListUtils.removeLegalBreaks(subList, 
widowRowLimit);
+                        }
+                        if (orphanRowLimit != 0) {
+                            ElementListUtils.removeLegalBreaksFromEnd(subList, 
orphanRowLimit);
+                        }
+                        i = seq.indexOf(nextElt);
+                    }
+                }
+                
                 // consider the new element at i
                 --i;
             }
@@ -849,15 +891,15 @@
      * @param seq the Knuth Sequence
      * @param startIndex the start index
      */
-    void resolveElements(List seq, int startIndex) {
-        resolveElements(seq, startIndex, false);
+    void resolveElements(KnuthSequence seq, int startIndex) {
+        resolveElements((BlockKnuthSequence) seq, startIndex, false);
     }
     
     /**
      * Resolve all elements in seq
      * @param seq the Knuth Sequence
      */
-    void resolveElements(List seq) {
+    void resolveElements(BlockKnuthSequence seq) {
         resolveElements(seq, 0, true);
     }
 
@@ -883,8 +925,8 @@
         return bestActiveNode.line;
     }
 
-    public LinkedList getFootnoteList(int index) {
-        return (LinkedList) footnotesList.get(index);
+    public BlockKnuthSequence getFootnoteList(int index) {
+        return (BlockKnuthSequence) footnotesList.get(index);
     }
     
     /** @return the associated top-level formatting object. */

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ParagraphListElement.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ParagraphListElement.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ParagraphListElement.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/ParagraphListElement.java
 Wed Nov 21 12:04:27 2007
@@ -32,6 +32,7 @@
 public class ParagraphListElement extends LineBreakingListElement {
 
     private KnuthParagraph para;
+    private boolean lineBreakingStarting = true;
     private boolean lineBreakingFinished = false;
     
     /**
@@ -60,8 +61,16 @@
     public LinkedList doLineBreaking() {
         LinkedList returnList = 
para.getLineLayoutManager().createLineBreaks(para);
         wrapPositions(returnList);
+        lineBreakingStarting = false;
         lineBreakingFinished = true;
         return returnList;
+    }
+
+    /* (non-Javadoc)
+     * @see 
org.apache.fop.layoutmgr.list.LineBreakingListElement#lineBreakingIsStarting()
+     */
+    public boolean lineBreakingIsStarting() {
+        return lineBreakingStarting;
     }
 
     /* (non-Javadoc)

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/LineBreakingListElement.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/LineBreakingListElement.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/LineBreakingListElement.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/LineBreakingListElement.java
 Wed Nov 21 12:04:27 2007
@@ -24,6 +24,24 @@
 
     public abstract LinkedList doLineBreaking();
 
+    public abstract boolean lineBreakingIsStarting();
+
     public abstract boolean lineBreakingIsFinished();
+
+    public boolean isStartOfSubsequence() {
+        return false;
+    }
+
+    public boolean isEndOfSubsequence() {
+        return false;
+    }
+    
+    public int getWidowRowLimit() {
+        return 0;
+    }
+    
+    public int getOrphanRowLimit() {
+        return 0;
+    }
 
 }

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
 Wed Nov 21 12:04:27 2007
@@ -19,29 +19,28 @@
  
 package org.apache.fop.layoutmgr.list;
 
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
 import org.apache.fop.fo.flow.ListBlock;
 import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
 import org.apache.fop.layoutmgr.ConditionalElementListener;
-import org.apache.fop.layoutmgr.ElementListUtils;
-import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.NonLeafPosition;
+import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.RelSide;
 import org.apache.fop.layoutmgr.TraitSetter;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
 import org.apache.fop.traits.MinOptMax;
 import org.apache.fop.traits.SpaceVal;
 
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
 /**
  * LayoutManager for a list-block FO.
  * A list block contains list items which are stacked within
@@ -118,16 +117,24 @@
         resetSpaces(); 
         LinkedList returnList = super.getNextKnuthElements(context, alignment);
 
-        //fox:widow-content-limit
-        int widowRowLimit = 
getListBlockFO().getWidowContentLimit().getValue(); 
-        if (widowRowLimit != 0) {
-            ElementListUtils.removeLegalBreaks(returnList, widowRowLimit);
-        }
-
-        //fox:orphan-content-limit
-        int orphanRowLimit = 
getListBlockFO().getOrphanContentLimit().getValue(); 
-        if (orphanRowLimit != 0) {
-            ElementListUtils.removeLegalBreaksFromEnd(returnList, 
orphanRowLimit);
+        if (childLMs != null && !childLMs.isEmpty()) {
+            //fox:widow-content-limit
+            int widowRowLimit = 
getListBlockFO().getWidowContentLimit().getValue(); 
+            if (widowRowLimit != 0) {
+                ((ListItemLayoutManager) 
childLMs.get(0)).setWidowRowLimit(widowRowLimit);
+            }
+
+            //fox:orphan-content-limit
+            int orphanRowLimit = 
getListBlockFO().getOrphanContentLimit().getValue(); 
+            if (orphanRowLimit != 0) {
+                ((ListItemLayoutManager) childLMs.get(childLMs.size() - 
1)).setOrphanRowLimit(orphanRowLimit);
+            }
+
+            // create a subsequence only if there is a widow or orphan content 
limit 
+            if (widowRowLimit != 0 || orphanRowLimit != 0) {
+                ((ListItemLayoutManager) 
childLMs.get(0)).setIsStartOfSubsequence(true);
+                ((ListItemLayoutManager) childLMs.get(childLMs.size() - 
1)).setIsEndOfSubsequence(true);
+            }
         }
 
         return returnList;

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
 Wed Nov 21 12:04:27 2007
@@ -82,6 +82,7 @@
     private int[] end = {-1, -1};
     int addedBoxHeight = 0;
     
+    private boolean lineBreakingStarting = true; 
     private boolean lineBreakingFinished = false; 
 
     private int listItemHeight;
@@ -95,7 +96,12 @@
     
     private boolean keepWithNextPendingOnLabel;
     private boolean keepWithNextPendingOnBody;
-  
+    
+    private int widowRowLimit = 0;
+    private int orphanRowLimit = 0;
+    private boolean isStartOfSubsequence = false;
+    private boolean isEndOfSubsequence = false;
+    
     private class ListItemPosition extends Position {
         private int iLabelFirstIndex;
         private int iLabelLastIndex;
@@ -272,6 +278,10 @@
         return returnList;
     }
     
+    public boolean lineBreakingIsStarting() {
+        return lineBreakingStarting;
+    }
+    
     public boolean lineBreakingIsFinished() {
         return lineBreakingFinished;
     }
@@ -289,6 +299,7 @@
         
         step = getNextStep();
 
+        lineBreakingStarting = false;
         lineBreakingFinished = true;
         boolean keepWithNextActive = false;
         if (end[0] + 1 == elementLists[0].size()) {
@@ -418,6 +429,62 @@
     }
 
     /**
+     * @return the widowRowLimit
+     */
+    public int getWidowRowLimit() {
+        return widowRowLimit;
+    }
+
+    /**
+     * @param widowRowLimit the widowRowLimit to set
+     */
+    public void setWidowRowLimit(int widowRowLimit) {
+        this.widowRowLimit = widowRowLimit;
+    }
+
+    /**
+     * @return the orphanRowLimit
+     */
+    public int getOrphanRowLimit() {
+        return orphanRowLimit;
+    }
+
+    /**
+     * @param orphanRowLimit the orphanRowLimit to set
+     */
+    public void setOrphanRowLimit(int orphanRowLimit) {
+        this.orphanRowLimit = orphanRowLimit;
+    }
+    
+    /**
+     * @return the bIsStartOfSubsequence
+     */
+    public boolean isStartOfSubsequence() {
+        return isStartOfSubsequence;
+    }
+    
+    /**
+     * @param isStartOfSubsequence the isStartOfSubsequence to set
+     */
+    public void setIsStartOfSubsequence(boolean isStartOfSubsequence) {
+        this.isStartOfSubsequence = isStartOfSubsequence;
+    }
+
+    /**
+     * @return the bIsEndOfSubsequence
+     */
+    public boolean isEndOfSubsequence() {
+        return isEndOfSubsequence;
+    }
+
+    /**
+     * @param isEndOfSubsequence the isEndOfSubsequence to set
+     */
+    public void setIsEndOfSubsequence(boolean isEndOfSubsequence) {
+        this.isEndOfSubsequence = isEndOfSubsequence;
+    }
+
+    /**
      * The iteration stops at the first resolved element (after line breaking).
      * After space resolution it is guaranteed that seq does not to contain
      * ParagraphListElements until the first resolved element.
@@ -740,7 +807,6 @@
             log.debug(this + ": Padding " + side + " -> " + effectiveLength);
         }
     }
-
     
 }
 

Modified: 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemListElement.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemListElement.java?rev=597197&r1=597196&r2=597197&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemListElement.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemListElement.java
 Wed Nov 21 12:04:27 2007
@@ -64,6 +64,20 @@
     }
 
     /**
+     * @return the widowRowLimit
+     */
+    public int getWidowRowLimit() {
+        return lm.getWidowRowLimit();
+    }
+
+    /**
+     * @return the orphanRowLimit
+     */
+    public int getOrphanRowLimit() {
+        return lm.getOrphanRowLimit();
+    }
+
+    /**
      * Wrap the position in each element in list in a position stack
      * which is a copy of the position stack of this paragraph list element.
      * @param list
@@ -79,10 +93,31 @@
     }
     
     /* (non-Javadoc)
+     * @see 
org.apache.fop.layoutmgr.list.LineBreakingListElement#lineBreakingIsStarting()
+     */
+    public boolean lineBreakingIsStarting() {
+        return lm.lineBreakingIsStarting();
+    }
+
+    /* (non-Javadoc)
      * @see 
org.apache.fop.layoutmgr.list.LineBreakingListElement#lineBreakingIsFinished()
      */
     public boolean lineBreakingIsFinished() {
         return lm.lineBreakingIsFinished();
+    }
+
+    /* (non-Javadoc)
+     * @see 
org.apache.fop.layoutmgr.list.LineBreakingListElement#isStartOfSubsequence()
+     */
+    public boolean isStartOfSubsequence() {
+        return lm.isStartOfSubsequence();
+    }
+
+    /* (non-Javadoc)
+     * @see 
org.apache.fop.layoutmgr.list.LineBreakingListElement#isEndOfSubsequence()
+     */
+    public boolean isEndOfSubsequence() {
+        return lm.isEndOfSubsequence();
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to