]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Simplifications to PSLM.gKNE().
authorGlen Mazza <gmazza@apache.org>
Wed, 1 Jun 2005 04:22:18 +0000 (04:22 +0000)
committerGlen Mazza <gmazza@apache.org>
Wed, 1 Jun 2005 04:22:18 +0000 (04:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198711 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java

index 8cfa6d052134d5b17a25601528c255cb9cb64c1b..0a0c1eeb28e37b890241729bd21f1e886238f6df 100644 (file)
@@ -104,6 +104,12 @@ public abstract class AbstractBreaker {
     protected abstract void addAreas(PositionIterator posIter, LayoutContext context);
     protected abstract LayoutManager getTopLevelLM();
     protected abstract LayoutManager getCurrentChildLM();
+    
+    /*
+     * This method is to contain the logic to determine the LM's
+     * getNextKnuthElements() implementation(s) that are to be called. 
+     * @return LinkedList of Knuth elements.  
+     */
     protected abstract LinkedList getNextKnuthElements(LayoutContext context, int alignment);
 
     /** @return true if there's no content that could be handled. */
index 4541a1be5a70e4993f43bb525f4797ec9d6f7265..d44d5fd4e3da58825007b45f32284f0b2294f019 100644 (file)
@@ -124,17 +124,6 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
         return null;
     }
 
-    protected boolean hasMoreLM(LayoutManager prevLM) {
-        // prevLM should = curChildLM
-        if (prevLM != curChildLM) {
-            //log.debug("AbstractLayoutManager.peekNextLM: " +
-            //                   "passed LM is not current child LM!");
-            return false;
-        }
-        return !childLMiter.hasNext();
-    }
-
-
     /**
      * Reset the layoutmanager "iterator" so that it will start
      * with the passed Position's generating LM
index 428e2d06189685b7c7cba5846a73d3888067681d..369c0664eadc5a2ea6c22a3ef1f5dfceb5b5b0ab 100644 (file)
@@ -33,6 +33,7 @@ import org.apache.fop.datatypes.PercentBase;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.Marker;
 import org.apache.fop.fo.flow.RetrieveMarker;
+import org.apache.fop.fo.pagination.Flow;
 import org.apache.fop.fo.pagination.PageSequence;
 import org.apache.fop.fo.pagination.Region;
 import org.apache.fop.fo.pagination.SideRegion;
@@ -129,6 +130,11 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
 
         curPV = makeNewPage(false, true, false);
 
+        Flow mainFlow = pageSeq.getMainFlow();
+        childFLM = (FlowLayoutManager) 
+            getLayoutManagerMaker().makeLayoutManager(mainFlow);
+        childFLM.setParent(this);
+
         PageBreaker breaker = new PageBreaker(this);
         int flowBPD = (int) curPV.getBodyRegion().getBPD();
         breaker.doLayout(flowBPD);
@@ -312,35 +318,25 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
      * @param context the layout context for finding breaks
      * @return the break for the page
      */
-    public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
-
-        LayoutManager curLM; // currently active LM
-
-        while ((curLM = getChildLM()) != null) {
-            LinkedList returnedList = null;
-            if (childFLM == null && (curLM instanceof FlowLayoutManager)) {
-                childFLM = (FlowLayoutManager)curLM;
-            } else {
-                if (curLM != childFLM) {
-                    log.error("PSLM> invalid child LM");
-                }
-            }
+    public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {       
+        LinkedList returnedList = null;
 
+        while (!childFLM.isFinished()) {
             LayoutContext childLC = new LayoutContext(0);
             childLC.setStackLimit(context.getStackLimit());
             childLC.setRefIPD(context.getRefIPD());
 
-            if (!curLM.isFinished()) {
-                int flowIPD = curPV.getCurrentSpan().getColumnWidth();
-                int flowBPD = (int) curPV.getBodyRegion().getBPD();
-                pageSeq.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, flowIPD);
-                pageSeq.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, flowBPD);
-                returnedList = curLM.getNextKnuthElements(childLC, alignment);
-            }
+            int flowIPD = curPV.getCurrentSpan().getColumnWidth();
+            int flowBPD = (int) curPV.getBodyRegion().getBPD();
+            pageSeq.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, flowIPD);
+            pageSeq.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, flowBPD);
+            returnedList = childFLM.getNextKnuthElements(childLC, alignment);
+
             if (returnedList != null) {
                 return returnedList;
             }
         }
+
         setFinished(true);
         return null;
     }