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 je...@apache.org on 2005/01/26 16:00:45 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr FlowLayoutManager.java

jeremias    2005/01/26 07:00:45

  Modified:    src/java/org/apache/fop/layoutmgr FlowLayoutManager.java
  Log:
  Added a check for endless loops.
  
  Revision  Changes    Path
  1.10      +24 -8     xml-fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
  
  Index: FlowLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FlowLayoutManager.java	20 Oct 2004 21:07:02 -0000	1.9
  +++ FlowLayoutManager.java	26 Jan 2005 15:00:45 -0000	1.10
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 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.
  @@ -23,7 +23,6 @@
   import org.apache.fop.area.Area;
   import org.apache.fop.area.BlockParent;
   
  -import java.util.ArrayList;
   import java.util.List;
   import org.apache.fop.traits.MinOptMax;
   
  @@ -34,10 +33,11 @@
    * and filling them with block-level areas generated by its children.
    */
   public class FlowLayoutManager extends BlockStackingLayoutManager {
  +    
       private Flow fobj;
       
       /** List of break possibilities */
  -    protected List blockBreaks = new ArrayList();
  +    protected List blockBreaks = new java.util.ArrayList();
   
       /** Array of areas currently being filled stored by area class */
       private BlockParent[] currentAreas = new BlockParent[Area.CLASS_MAX];
  @@ -45,8 +45,15 @@
       private int iStartPos = 0;
   
       /**
  +     * Used to count the number of subsequent times to layout child areas on
  +     * multiple pages.
  +     */
  +    private int numSubsequentOverflows = 0;
  +    
  +    /**
        * This is the top level layout manager.
        * It is created by the PageSequence FO.
  +     * @param node Flow object
        */
       public FlowLayoutManager(Flow node) {
           super(node);
  @@ -87,6 +94,10 @@
                       childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
   
                       if (bp.isForcedBreak() || bp.nextBreakOverflows()) {
  +                        if (log.isDebugEnabled()) {
  +                            log.debug("BreakPoss signals " + (bp.isForcedBreak() 
  +                                    ? "forced break" : "next break overflows"));
  +                        }
                           breakPage = true;
                       }
                   }
  @@ -99,9 +110,16 @@
                   breakPage = true;
               }
               if (breakPage) {
  +                numSubsequentOverflows++;
  +                if (numSubsequentOverflows > 50) {
  +                    log.error("Content overflows available area. Giving up after 50 attempts.");
  +                    setFinished(true);
  +                    return null;
  +                }
                   return new BreakPoss(
                         new LeafPosition(this, blockBreaks.size() - 1));
               }
  +            numSubsequentOverflows = 0; //Reset emergency counter
           }
           setFinished(true);
           if (blockBreaks.size() > 0) {
  @@ -121,9 +139,8 @@
           while (parentIter.hasNext()) {
               LeafPosition lfp = (LeafPosition) parentIter.next();
               // Add the block areas to Area
  -            PositionIterator breakPosIter =
  -              new BreakPossPosIter(blockBreaks, iStartPos,
  -                                   lfp.getLeafPos() + 1);
  +            PositionIterator breakPosIter =  new BreakPossPosIter(
  +                    blockBreaks, iStartPos, lfp.getLeafPos() + 1);
               iStartPos = lfp.getLeafPos() + 1;
               while ((childLM = breakPosIter.getNextChildLM()) != null) {
                   childLM.addAreas(breakPosIter, lc);
  @@ -149,8 +166,7 @@
        */
       public Area getParentArea(Area childArea) {
           // Get an area from the Page
  -        BlockParent parentArea =
  -          (BlockParent) parentLM.getParentArea(childArea);
  +        BlockParent parentArea = (BlockParent)parentLM.getParentArea(childArea);
           this.currentAreas[parentArea.getAreaClass()] = parentArea;
           setCurrentArea(parentArea);
           return parentArea;
  
  
  

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