You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by sp...@apache.org on 2007/11/08 21:39:11 UTC

svn commit: r593296 - in /xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr: ./ list/

Author: spepping
Date: Thu Nov  8 12:39:10 2007
New Revision: 593296

URL: http://svn.apache.org/viewvc?rev=593296&view=rev
Log:
Add ListItemListElement.java, which was missing in the preceding two
commits. Do some refactoring.

Added:
    xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/LineBreakingListElement.java   (with props)
    xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemListElement.java   (with props)
Modified:
    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/ListItemLayoutManager.java

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=593296&r1=593295&r2=593296&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 Thu Nov  8 12:39:10 2007
@@ -30,6 +30,7 @@
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.layoutmgr.AbstractBreaker.PageBreakPosition;
+import org.apache.fop.layoutmgr.list.LineBreakingListElement;
 import org.apache.fop.layoutmgr.list.ListItemListElement;
 import org.apache.fop.traits.MinOptMax;
 
@@ -825,19 +826,12 @@
         for (int i = startIndex; i < seq.size(); ++i) {
             ListElement elt = (ListElement) seq.get(i);
             if (!doall && !elt.isUnresolvedElement()
-                    && !(elt instanceof ParagraphListElement)
-                    && !(elt instanceof ListItemListElement)) {
+                    && !(elt instanceof LineBreakingListElement)) {
                 break;
             }
-            if (elt instanceof ParagraphListElement) {
-                LinkedList lineElts = ((ParagraphListElement) elt).doLineBreaking();
-                seq.remove(i);
-                seq.addAll(i, lineElts);
-                // consider the new element at i
-                --i;
-            } else if (elt instanceof ListItemListElement) {
-                LinkedList lineElts = ((ListItemListElement) elt).doLineBreaking();
-                if (((ListItemListElement) elt).lineBreakingIsFinished()) {
+            if (elt instanceof LineBreakingListElement) {
+                LinkedList lineElts = ((LineBreakingListElement) elt).doLineBreaking();
+                if (((LineBreakingListElement) elt).lineBreakingIsFinished()) {
                     seq.remove(i);
                 }
                 seq.addAll(i, lineElts);

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=593296&r1=593295&r2=593296&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 Thu Nov  8 12:39:10 2007
@@ -24,13 +24,15 @@
 
 import org.apache.fop.layoutmgr.inline.KnuthInlineBox;
 import org.apache.fop.layoutmgr.inline.KnuthParagraph;
+import org.apache.fop.layoutmgr.list.LineBreakingListElement;
 
 /**
  * This class represents a List Element for a Knuth Paragraph
  */
-public class ParagraphListElement extends ListElement {
+public class ParagraphListElement extends LineBreakingListElement {
 
     private KnuthParagraph para;
+    private boolean lineBreakingFinished = false;
     
     /**
      * @param para The Knuth Paragraph
@@ -58,7 +60,15 @@
     public LinkedList doLineBreaking() {
         LinkedList returnList = para.getLineLayoutManager().createLineBreaks(para);
         wrapPositions(returnList);
+        lineBreakingFinished = true;
         return returnList;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.fop.layoutmgr.list.LineBreakingListElement#lineBreakingIsFinished()
+     */
+    public boolean lineBreakingIsFinished() {
+        return lineBreakingFinished;
     }
 
     /**

Added: 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=593296&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/LineBreakingListElement.java (added)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/LineBreakingListElement.java Thu Nov  8 12:39:10 2007
@@ -0,0 +1,29 @@
+package org.apache.fop.layoutmgr.list;
+
+import java.util.LinkedList;
+
+import org.apache.fop.layoutmgr.ListElement;
+import org.apache.fop.layoutmgr.Position;
+
+public abstract class LineBreakingListElement extends ListElement {
+
+    /**
+     * Main constructor
+     * @param position the Position instance needed by the addAreas stage of the LMs.
+     */
+    public LineBreakingListElement(Position position) {
+        super(position);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.fop.layoutmgr.ListElement#isUnresolvedElement()
+     */
+    public boolean isUnresolvedElement() {
+        return false;
+    }
+
+    public abstract LinkedList doLineBreaking();
+
+    public abstract boolean lineBreakingIsFinished();
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/LineBreakingListElement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/LineBreakingListElement.java
------------------------------------------------------------------------------
    svn:keywords = Id

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=593296&r1=593295&r2=593296&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 Thu Nov  8 12:39:10 2007
@@ -278,9 +278,7 @@
 
     private LinkedList getCombinedKnuthElementsForListItem(LayoutContext context) {
         // At the first invocation of this method the elements in labelList and bodyList
-        // are copied to array lists to improve element access performance;
-        // at the last invocation the resolved elements are copied back
-        // to labelList and bodyList for use in addAreas
+        // are copied to array lists to improve element access performance
         if (elementLists == null) {
             elementLists = 
                 new List[] {new ArrayList(labelList), new ArrayList(bodyList)};
@@ -289,26 +287,23 @@
         int step;
         LinkedList returnList = new LinkedList();
         
-        if ((step = getNextStep()) == 0) {
-            lineBreakingFinished = true;
-            labelList = new LinkedList(elementLists[0]);
-            bodyList = new LinkedList(elementLists[1]);
-            ElementListObserver.observe(labelList, "list-item-label", label.getPartFO().getId());
-            ElementListObserver.observe(bodyList, "list-item-body", body.getPartFO().getId());
-            return returnList;
-        }
+        step = getNextStep();
 
+        lineBreakingFinished = true;
         boolean keepWithNextActive = false;
-
         if (end[0] + 1 == elementLists[0].size()) {
             if (keepWithNextPendingOnLabel) {
                 keepWithNextActive = true;
             }
+        } else {
+            lineBreakingFinished = false;
         }
         if (end[1] + 1 == elementLists[1].size()) {
             if (keepWithNextPendingOnBody) {
                 keepWithNextActive = true;
             }
+        } else {
+            lineBreakingFinished = false;
         }
 
         // compute penalty height and box height
@@ -339,12 +334,15 @@
             p = KnuthPenalty.INFINITE;
         }
         // add BreakElement if there are more elements in the lists
-        // could this be determined in getNextStep and is it equivalent to lineBreakingFinished?
-        for (int i = 0; i < start.length; i++) {
-            if (end[i] + 1 < elementLists[i].size()) {
-                returnList.add(new BreakElement(stepPosition, penaltyHeight, p, -1, context));
-                break;
-            }
+        if (!lineBreakingFinished) {
+            returnList.add(new BreakElement(stepPosition, penaltyHeight, p, -1, context));
+        } else {
+            // At the last invocation of this method the resolved elements are copied back
+            // to labelList and bodyList for use in addAreas
+            labelList = new LinkedList(elementLists[0]);
+            bodyList = new LinkedList(elementLists[1]);
+            ElementListObserver.observe(labelList, "list-item-label", label.getPartFO().getId());
+            ElementListObserver.observe(bodyList, "list-item-body", body.getPartFO().getId());
         }
 
         return returnList;

Added: 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=593296&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemListElement.java (added)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemListElement.java Thu Nov  8 12:39:10 2007
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr.list;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.ListElement;
+import org.apache.fop.layoutmgr.Position;
+
+
+/**
+ * 
+ */
+public class ListItemListElement extends LineBreakingListElement {
+    
+    private ListItemLayoutManager lm;
+    private LayoutContext context;
+    
+    public ListItemListElement(ListItemLayoutManager lm, Position pos, LayoutContext context) {
+        super(pos);
+        this.lm = lm;
+        this.context = context;
+    }
+
+    /**
+     * @return the lm
+     */
+    public ListItemLayoutManager getListItemLayoutManager() {
+        return lm;
+    }
+
+    /**
+     * @return the context
+     */
+    public LayoutContext getContext() {
+        return context;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.fop.layoutmgr.list.LineBreakingListElement#doLineBreaking()
+     */
+    public LinkedList doLineBreaking() {
+        LinkedList returnList = lm.doLineBreaking(context);
+        wrapPositions(returnList);
+        return returnList;
+    }
+
+    /**
+     * 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
+     */
+    private void wrapPositions(LinkedList list) {
+        Iterator iter = list.iterator();
+        while (iter.hasNext()) {
+            ListElement elt = (ListElement) iter.next();
+            Position pos = getPosition();
+            pos = pos.getLM().rewrapPosition(pos, elt.getPosition());
+            elt.setPosition(pos);
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.fop.layoutmgr.list.LineBreakingListElement#lineBreakingIsFinished()
+     */
+    public boolean lineBreakingIsFinished() {
+        return lm.lineBreakingIsFinished();
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemListElement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemListElement.java
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org