From: Glen Mazza Date: Wed, 1 Jun 2005 04:22:18 +0000 (+0000) Subject: Simplifications to PSLM.gKNE(). X-Git-Tag: fop-0_90-alpha1~596 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=317270ae05f404dd9f17cf3f1ce5e9141e7d5c13;p=xmlgraphics-fop.git Simplifications to PSLM.gKNE(). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198711 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java index 8cfa6d052..0a0c1eeb2 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java @@ -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. */ diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index 4541a1be5..d44d5fd4e 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -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 diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index 428e2d061..369c0664e 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -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; }