]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
set user agent on layout managers for values and logging
authorKeiron Liddle <keiron@apache.org>
Mon, 18 Nov 2002 15:54:16 +0000 (15:54 +0000)
committerKeiron Liddle <keiron@apache.org>
Mon, 18 Nov 2002 15:54:16 +0000 (15:54 +0000)
improved break handling so that it breaks before overflow

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195556 13f79535-47bb-0310-9956-ffa450edef68

27 files changed:
src/org/apache/fop/fo/FONode.java
src/org/apache/fop/fo/Title.java
src/org/apache/fop/fo/flow/Block.java
src/org/apache/fop/fo/flow/Flow.java
src/org/apache/fop/fo/flow/Leader.java
src/org/apache/fop/fo/flow/ListItem.java
src/org/apache/fop/fo/pagination/PageSequence.java
src/org/apache/fop/layoutmgr/AbstractLayoutManager.java
src/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
src/org/apache/fop/layoutmgr/BlockLayoutManager.java
src/org/apache/fop/layoutmgr/BreakPoss.java
src/org/apache/fop/layoutmgr/ContentLayoutManager.java
src/org/apache/fop/layoutmgr/FlowLayoutManager.java
src/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java
src/org/apache/fop/layoutmgr/LayoutManager.java
src/org/apache/fop/layoutmgr/LineLayoutManager.java
src/org/apache/fop/layoutmgr/PageLayoutManager.java
src/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
src/org/apache/fop/layoutmgr/list/Item.java
src/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
src/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
src/org/apache/fop/layoutmgr/table/Body.java
src/org/apache/fop/layoutmgr/table/Caption.java
src/org/apache/fop/layoutmgr/table/Cell.java
src/org/apache/fop/layoutmgr/table/Row.java
src/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
src/org/apache/fop/layoutmgr/table/TableLayoutManager.java

index c212b85b96fb72cdbdaf888a4d2dbb79c97c75a9..dabd6ff80c8bcf3ce7a1d8eeb81c844b39dbb96a 100644 (file)
@@ -45,6 +45,10 @@ public abstract class FONode {
         userAgent = ua;
     }
 
+    public FOUserAgent getUserAgent() {
+        return userAgent;
+    }
+
     public void setStructHandler(StructureHandler st) {
     }
 
index 6ac1df5ca68e3794bd8bf8358cb4a0a1a12d07fb..9ee5d5c38612e2bde17713a676816576714a02a3 100644 (file)
@@ -35,11 +35,13 @@ public class Title extends FObjMixed {
         InlineStackingLayoutManager lm;
         lm = new InlineStackingLayoutManager(this,
                      new LMiter(children.listIterator()));
+        lm.setUserAgent(getUserAgent());
         lm.init();
 
         // get breaks then add areas to title
 
         ContentLayoutManager clm = new ContentLayoutManager(title);
+        clm.setUserAgent(getUserAgent());
         lm.setParentLM(clm);
 
         clm.fillArea(lm);
index 296e45dbfe35f05c1c0bbe461b23eaee8b15caa6..a3c7f744469515f772afa0fd846e207ebef80c90 100644 (file)
@@ -176,6 +176,7 @@ public class Block extends FObjMixed {
 
     public void addLayoutManager(List list) {
         BlockLayoutManager blm = new BlockLayoutManager(this);
+        blm.setUserAgent(getUserAgent());
         TextInfo ti = propMgr.getTextLayoutProps(fontInfo);
         blm.setBlockTextInfo(ti);
         list.add(blm);
index 50ea4c2da583837bbafcc2b7c45c8f875a54cbb3..4f786d0c05b686d576d83414c61cb43bbe235bbf 100644 (file)
@@ -111,7 +111,9 @@ public class Flow extends FObj {
     }
 
     public void addLayoutManager(List list) {
-        list.add(new FlowLayoutManager(this));
+        FlowLayoutManager lm = new FlowLayoutManager(this);
+        lm.setUserAgent(getUserAgent());
+        list.add(lm);
     }
 
 }
index c2fb0e372d5d9c030adfee4db5bc280aa55c62b4..930cf59af1d0f0ae1b19c8e7b338f6a3f7f3c7a4 100644 (file)
@@ -123,12 +123,14 @@ public class Leader extends FObjMixed {
             InlineStackingLayoutManager lm;
             lm = new InlineStackingLayoutManager(this,
                      new LMiter(children.listIterator()));
+            lm.setUserAgent(getUserAgent());
             lm.init();
 
             // get breaks then add areas to FilledArea
             FilledArea fa = new FilledArea();
 
             ContentLayoutManager clm = new ContentLayoutManager(fa);
+            clm.setUserAgent(getUserAgent());
             lm.setParentLM(clm);
 
             clm.fillArea(lm);
index 1dc296d3e4d9a730813ae7eb16c32e9173dbadaa..af5db5880848fbe12192597b532cc53d34850ec0 100644 (file)
@@ -43,6 +43,8 @@ public class ListItem extends FObj {
             blm.setLabel(label.getItemLayoutManager());
             blm.setBody(body.getItemLayoutManager());
             list.add(blm);
+        } else {
+            getLogger().error("list-item requires list-item-label and list-item-body");
         }
     }
 
index 9af862bfe0989a0e825a19887642a2642ec1552c..9e377eee09ca630dec58c469d690f19d0dbc2bc4 100644 (file)
@@ -339,6 +339,7 @@ public class PageSequence extends FObj {
 
         // This will layout pages and add them to the area tree
         PageLayoutManager pageLM = new PageLayoutManager(areaTree, this);
+        pageLM.setUserAgent(getUserAgent());
         pageLM.setPageCounting(currentPageNumber, pageNumberGenerator);
 
         // For now, skip the threading and just call run directly.
index 0a57777bdc64c0a9984a183394412a5761713843..9d649b2662ef2c483f28cbed44552ecb566d595a 100644 (file)
@@ -8,6 +8,7 @@
 package org.apache.fop.layoutmgr;
 
 import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.FOUserAgent;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Resolveable;
 import org.apache.fop.area.PageViewport;
@@ -17,12 +18,15 @@ import org.apache.fop.layout.BorderAndPadding;
 import org.apache.fop.layout.BackgroundProps;
 import org.apache.fop.traits.BorderProps;
 
+import org.apache.avalon.framework.logger.Logger;
+
 import java.util.ListIterator;
 
 /**
  * The base class for all LayoutManagers.
  */
 public abstract class AbstractLayoutManager implements LayoutManager {
+    protected FOUserAgent userAgent;
     protected LayoutManager parentLM;
     protected FObj fobj;
     protected String foID = null;
@@ -51,6 +55,23 @@ public abstract class AbstractLayoutManager implements LayoutManager {
         childLMiter = lmIter;
     }
 
+    /**
+     * Set the user agent.
+     *
+     * @param ua the user agent
+     */
+    public void setUserAgent(FOUserAgent ua) {
+        userAgent = ua;
+    }
+
+    public FOUserAgent getUserAgent() {
+        return userAgent;
+    }
+
+    protected Logger getLogger() {
+        return userAgent.getLogger();
+    }
+
     public void setParentLM(LayoutManager lm) {
         this.parentLM = lm;
     }
@@ -109,6 +130,7 @@ public abstract class AbstractLayoutManager implements LayoutManager {
         }
         while (childLMiter.hasNext()) {
             curChildLM = (LayoutManager) childLMiter.next();
+            curChildLM.setUserAgent(getUserAgent());
             curChildLM.setParentLM(this);
             curChildLM.init();
             return curChildLM;
index f30ad2970719de839b32e6b17ca8fa2e53953898..4ccfea572ab475e0ace96c57caec10adb784c044 100644 (file)
@@ -193,7 +193,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager {
             if (overflow == Overflow.HIDDEN) {
                 clip = true;
             } else if (overflow == Overflow.ERROR_IF_OVERFLOW) {
-                //log.error("contents overflows block-container viewport: clipping");
+                getLogger().error("contents overflows block-container viewport: clipping");
                 clip = true;
             }
         }
index 0ad73017069f14a79b4e8fb15de04d7f0a8b1197..63e56c613f95857e3f051423c1a838ae749c48c6 100644 (file)
@@ -91,6 +91,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             LineLayoutManager child;
             child = new LineLayoutManager(fobj, inlines, lineHeight,
                                             lead, follow);
+            child.setUserAgent(getUserAgent());
             return child;
 
         }
@@ -149,20 +150,29 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             boolean over = false;
             while (!curLM.isFinished()) {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                    stackSize.add(bp.getStackingSize());
-                    if (stackSize.opt > context.getStackLimit().max) {
+                    if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
                         // reset to last break
                         if (lastPos != null) {
-                            reset(lastPos.getPosition());
+                            LayoutManager lm = lastPos.getLayoutManager();
+                            lm.resetPosition(lastPos.getPosition());
+                            if (lm != curLM) {
+                                curLM.resetPosition(null);
+                            }
                         } else {
                             curLM.resetPosition(null);
                         }
                         over = true;
                         break;
                     }
+                    stackSize.add(bp.getStackingSize());
                     lastPos = bp;
                     childBreaks.add(bp);
 
+                    if (bp.nextBreakOverflows()) {
+                        over = true;
+                        break;
+                    }
+
                     if (curLM.generatesInlineAreas()) {
                         // Reset stackLimit for non-first lines
                         childLC.setStackLimit(new MinOptMax(ipd/* - iIndents*/));
@@ -179,6 +189,9 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
                 }
                 BreakPoss breakPoss = new BreakPoss(
                                     new LeafPosition(this, childBreaks.size() - 1));
+                if (over) {
+                    breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+                }
                 breakPoss.setStackingSize(stackSize);
                 return breakPoss;
             }
@@ -189,6 +202,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
         return breakPoss;
     }
 
+    int iStartPos = 0;
+
     public void addAreas(PositionIterator parentIter,
                          LayoutContext layoutContext) {
         getParentArea(null);
@@ -200,12 +215,10 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
         addID();
 
         LayoutManager childLM ;
-        int iStartPos = 0;
         LayoutContext lc = new LayoutContext(0);
         while (parentIter.hasNext()) {
             LeafPosition lfp = (LeafPosition) parentIter.next();
             if (lfp.getLeafPos() == -2) {
-                childBreaks.clear();
                 curBlockArea = null;
                 flush();
                 return;
@@ -225,7 +238,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
         // if adjusted space after
         addBlockSpacing(adjust, layoutProps.spaceAfter.space);
 
-        childBreaks.clear();
         curBlockArea = null;
     }
 
@@ -273,6 +285,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
         if (resetPos == null) {
             reset(null);
             childBreaks.clear();
+            iStartPos = 0;
         } else {
             //reset(resetPos);
             LayoutManager lm = resetPos.getLM();
index 2f9a01d11044af01f08d4b00b37d15136a5c9dd2..237db85aecaede80711056523e03ce1fba1bdea7 100644 (file)
@@ -162,6 +162,10 @@ public class BreakPoss {
         return ((m_flags & FORCE) != 0);
     }
 
+    public boolean nextBreakOverflows() {
+        return ((m_flags & NEXT_OVERFLOWS) != 0);
+    }
+
     public boolean isSuppressible() {
         return ((m_flags & ALL_ARE_SUPPRESS_AT_LB) != 0);
     }
index 3432c953fd6ef4e8dea88461b92f108e5b2c1364..49b55d12827b4ab445a9ad4f6d51c94b179a6c4f 100644 (file)
@@ -6,11 +6,14 @@
  */
 package org.apache.fop.layoutmgr;
 
+import org.apache.fop.fo.FOUserAgent;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.MinOptMax;
 import org.apache.fop.area.Resolveable;
 import org.apache.fop.area.PageViewport;
 
+import org.apache.avalon.framework.logger.Logger;
+
 import java.util.List;
 import java.util.ArrayList;
 
@@ -21,7 +24,7 @@ import java.util.ArrayList;
  * leader use-content and title.
  */
 public class ContentLayoutManager implements LayoutManager {
-
+    private FOUserAgent userAgent;
     private Area holder;
     private int stackSize;
     private LayoutManager parentLM;
@@ -122,6 +125,23 @@ public class ContentLayoutManager implements LayoutManager {
         holder.addChild(childArea);
     }
 
+    /**
+     * Set the user agent.
+     *
+     * @param ua the user agent
+     */
+    public void setUserAgent(FOUserAgent ua) {
+        userAgent = ua;
+    }
+
+    public FOUserAgent getUserAgent() {
+        return userAgent;
+    }
+
+    protected Logger getLogger() {
+        return userAgent.getLogger();
+    }
+
     /** @see org.apache.fop.layoutmgr.LayoutManager */
     public void setParentLM(LayoutManager lm) {
         parentLM = lm;
index f8011f033253d4d3600e11eddaf7d8143668d7e1..58e57834d7b5e4c223be1294efe047908c7f7e0c 100644 (file)
@@ -38,12 +38,13 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
 
     public BreakPoss getNextBreakPoss(LayoutContext context) {
 
-        LayoutManager curLM ; // currently active LM
+        // currently active LM
+        LayoutManager curLM;
         MinOptMax stackSize = new MinOptMax();
 
         while ((curLM = getChildLM()) != null) {
             if (curLM.generatesInlineAreas()) {
-                // problem
+                getLogger().error("inline area not allowed under flow - ignoring");
                 curLM.setFinished(true);
                 continue;
             }
@@ -65,9 +66,8 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
                     // set stackLimit for remaining space
                     childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
 
-                    if (bp.isForcedBreak()) {
+                    if (bp.isForcedBreak() || bp.nextBreakOverflows()) {
                         breakPage = true;
-                        break;
                     }
                 }
             }
@@ -91,10 +91,11 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
         return null;
     }
 
+    int iStartPos = 0;
+
     public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
 
-        LayoutManager childLM ;
-        int iStartPos = 0;
+        LayoutManager childLM;
         LayoutContext lc = new LayoutContext(0);
         while (parentIter.hasNext()) {
             LeafPosition lfp = (LeafPosition) parentIter.next();
@@ -109,8 +110,6 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
         }
 
         flush();
-        // clear the breaks for the page to start for the next page
-        blockBreaks.clear();
     }
 
 
@@ -147,6 +146,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager {
      */
     public LayoutManager retrieveMarker(String name, int pos, int boundary) {
         // error cannot retrieve markers in flow
+        getLogger().error("Cannot retrieve a marker from the flow");
         return null;
     }
 }
index 1554a3d1ec440c8bb3f2f0e644a5f985679ba2ff..8931289a5879e1cd64bfa622938e9eac7b26b49f 100644 (file)
@@ -149,7 +149,7 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager {
         if (prevPos != null) {
             // ASSERT (prevPos.getLM() == this)
             if (prevPos.getLM() != this) {
-                //log.error(
+                //getLogger().error(
                 //  "InlineStackingLayoutManager.resetPosition: " +
                 //  "LM mismatch!!!");
             }
@@ -239,7 +239,7 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager {
 
             // ignore nested blocks for now
             if (!curLM.generatesInlineAreas()) {
-                System.err.println("WARNING: ignoring block inside inline fo");
+                getLogger().warn("ignoring block inside inline fo");
                 curLM.setFinished(true);
                 continue;
             }
@@ -547,7 +547,7 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager {
                                           spaceRange.min) * dSpaceAdjust);
             }
             if (iAdjust != 0) {
-                //log.error("Add leading space: " + iAdjust);
+                //getLogger().debug("Add leading space: " + iAdjust);
                 Space ls = new Space();
                 ls.setWidth(iAdjust);
                 parentArea.addChild(ls);
index ab3b3fc621e5aeac3ffb0a593163b152f6e0186c..82126380471360ed5083b5e578e64792757dc607 100644 (file)
@@ -7,6 +7,7 @@
 
 package org.apache.fop.layoutmgr;
 
+import org.apache.fop.fo.FOUserAgent;
 
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Resolveable;
@@ -16,11 +17,40 @@ import org.apache.fop.area.PageViewport;
  * The interface for all LayoutManagers.
  */
 public interface LayoutManager {
-    public boolean generatesInlineAreas();
-    public Area getParentArea (Area childArea);
-    public void addChild (Area childArea);
+
+    /**
+     * Set the user agent.
+     *
+     * @param ua the user agent
+     */
+    public void setUserAgent(FOUserAgent ua);
+
+    /**
+     * Get the user agent.
+     *
+     * @return the user agent
+     */
+    public FOUserAgent getUserAgent();
+
+    /**
+     * Set the parent layout manager.
+     * The parent layout manager is required for adding areas.
+     *
+     * @param lm the parent layout manager
+     */
     public void setParentLM(LayoutManager lm);
 
+    public void init();
+
+    /**
+     * Generates inline areas.
+     * This is used to check if the layout manager generates inline
+     * areas.
+     *
+     * @return true if the layout manager generates inline areas
+     */
+    public boolean generatesInlineAreas();
+
     /**
      * Return true if the next area which would be generated by this
      * LayoutManager could start a new line (or flow for block-level FO).
@@ -37,6 +67,11 @@ public interface LayoutManager {
     public BreakPoss getNextBreakPoss(LayoutContext context);
 
 
+    public void resetPosition(Position position);
+
+    public void getWordChars(StringBuffer sbChars, Position bp1,
+                             Position bp2);
+
     /**
      * Return a value indicating whether this LayoutManager has laid out
      * all its content (or generated BreakPossibilities for all content.)
@@ -50,6 +85,9 @@ public interface LayoutManager {
      */
     public void setFinished(boolean isFinished);
 
+    public Area getParentArea(Area childArea);
+    public void addChild(Area childArea);
+
     /**
      * Tell the layout manager to add all the child areas implied
      * by Position objects which will be returned by the
@@ -57,13 +95,6 @@ public interface LayoutManager {
      */
     public void addAreas(PositionIterator posIter, LayoutContext context);
 
-    public void init();
-
-    public void resetPosition(Position position);
-
-    public void getWordChars(StringBuffer sbChars, Position bp1,
-                             Position bp2);
-
     /**
      * Get the string of the current page number.
      *
@@ -121,3 +152,4 @@ public interface LayoutManager {
     public LayoutManager retrieveMarker(String name, int pos, int boundary);
 
 }
+
index 0a057d7e3daeaa1bc46fa2a0a7934dc496d11103..88264476497f5995ea4ffbccc99a57b5ef7c1c1a 100644 (file)
@@ -366,7 +366,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
         while (bpIter.hasPrevious() && bpIter.previous() != prev) {
         }
         if (bpIter.next() != prev) {
-            //log.error("findHyphenPoss: problem!");
+            getLogger().error("findHyphenPoss: problem!");
             return null;
         }
         StringBuffer sbChars = new StringBuffer(30);
@@ -382,7 +382,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
             prev = bp;
         }
         vecInlineBreaks.remove(vecInlineBreaks.size() - 1); // remove last
-        //log.debug("Word to hyphenate: " + sbChars.toString());
+        getLogger().debug("Word to hyphenate: " + sbChars.toString());
 
         // Now find all hyphenation points in this word (get in an array of offsets)
         // hyphProps are from the block level?. Note that according to the spec,
@@ -586,7 +586,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager {
      */
     public void addAreas(PositionIterator parentIter, double dSpaceAdjust) {
         LayoutManager childLM;
-        //int iStartPos = 0;
         LayoutContext lc = new LayoutContext(0);
         while (parentIter.hasNext()) {
             LineBreakPosition lbp = (LineBreakPosition) parentIter.next();
index 6f1c1a8b8a4ef0d0f1415ddf9e1a878cddfa78ad..9c494fa6138d744faf1206ee89f81ff76f2c5010 100644 (file)
@@ -328,7 +328,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable
         // end the page.
         getParentArea(area);
         // Alternatively the child LM indicates to parent that it's full?
-        //System.out.println("size: " + area.getAllocationBPD().max +
+        //getLogger().debug("size: " + area.getAllocationBPD().max +
         //                   ":" + curSpan.getMaxBPD().min);
         /*if (area.getAllocationBPD().max >= curSpan.getMaxBPD().min) {
             // Consider it filled
@@ -385,9 +385,10 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable
                   .getRegion(regionClass);
                 reg.getRegion().setIPD((int)reg.getViewArea().getWidth());
                 if (reg == null) {
-                    System.out.println("no region viewport: shouldn't happen");
+                    getLogger().error("no region viewport: shouldn't happen");
                 }
                 StaticContentLayoutManager lm = flow.getLayoutManager();
+                lm.setUserAgent(getUserAgent());
                 lm.init();
                 lm.setRegionReference(reg.getRegion());
                 lm.setParentLM(this);
@@ -403,7 +404,7 @@ public class PageLayoutManager extends AbstractLayoutManager implements Runnable
                         lm.addAreas(new BreakPossPosIter(vecBreakPoss, 0,
                                                           vecBreakPoss.size()), null);
                     } else {
-                      System.out.println("bp==null  cls=" + regionClass);
+                      getLogger().error("bp==null  cls=" + regionClass);
                     }
                 }
                 //lm.flush();
index 280d2ef8abb7c764aba933267314bbd276eea599..7d5c3a75efaea021e2016b145840b4dd454f2587 100644 (file)
@@ -36,7 +36,8 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
    
     public BreakPoss getNextBreakPoss(LayoutContext context) {
 
-        LayoutManager curLM; // currently active LM
+        // currently active LM
+        LayoutManager curLM;
 
         while ((curLM = getChildLM()) != null) {
             // Make break positions and return page break
@@ -47,7 +48,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
                     blockBreaks.add(bp);
                     if (bp.isForcedBreak()) {
-                        System.out.println("Forced breaks are not allowed in static content");
+                        getLogger().error("Forced breaks are not allowed in static content - ignoring");
                         return null;
                     }
                 }
@@ -79,8 +80,6 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
         }
 
         flush();
-        // clear the breaks for the page to start for the next page
-        blockBreaks.clear();
     }
 
 
@@ -105,6 +104,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
      */
     public void addMarker(String name, LayoutManager lm, boolean start) {
         // error markers not allowed in static
+        getLogger().error("Cannot add marker to static areas");
     }
 }
 
index 579c08491b732550aeac948c1ed0b2269e38a03c..029c864e9804cd752a2917436692e26fcab577fc 100644 (file)
@@ -88,27 +88,40 @@ public class Item extends BlockStackingLayoutManager {
                                      stackSize));
             childLC.setRefIPD(ipd);
 
+            boolean over = false;
             while (!curLM.isFinished()) {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                    stackSize.add(bp.getStackingSize());
-                    if (stackSize.opt > context.getStackLimit().max) {
+                    if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
                         // reset to last break
                         if (lastPos != null) {
-                            reset(lastPos.getPosition());
+                            LayoutManager lm = lastPos.getLayoutManager();
+                            lm.resetPosition(lastPos.getPosition());
+                            if (lm != curLM) {
+                                curLM.resetPosition(null);
+                            }
                         } else {
                             curLM.resetPosition(null);
                         }
                         break;
                     }
+                    stackSize.add(bp.getStackingSize());
                     lastPos = bp;
                     childBreaks.add(bp);
 
+                    if (bp.nextBreakOverflows()) {
+                        over = true;
+                        break;
+                    }
+
                     childLC.setStackLimit(MinOptMax.subtract(
                                              context.getStackLimit(), stackSize));
                 }
             }
             BreakPoss breakPoss = new BreakPoss(
                                     new LeafPosition(this, childBreaks.size() - 1));
+            if (over) { 
+                breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+            }
             breakPoss.setStackingSize(stackSize);
             return breakPoss;
         }
@@ -220,6 +233,8 @@ public class Item extends BlockStackingLayoutManager {
     public void resetPosition(Position resetPos) {
         if (resetPos == null) {
             reset(null);
+        } else {
+            //reset(resetPos);
         }
     }
 }
index 36bb832f0499d4be561a2ec95dbe01ee4453cb0e..73db239dd90ff2d1553f9dd54b7229295e83634f 100644 (file)
@@ -70,7 +70,8 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
      * @return the next break possibility
      */
     public BreakPoss getNextBreakPoss(LayoutContext context) {
-        LayoutManager curLM; // currently active LM
+        // currently active LM
+        LayoutManager curLM;
 
         MinOptMax stackSize = new MinOptMax();
         // if starting add space before
@@ -89,27 +90,40 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
                                      stackSize));
             childLC.setRefIPD(ipd);
 
+            boolean over = false;
             while (!curLM.isFinished()) {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                    stackSize.add(bp.getStackingSize());
-                    if (stackSize.opt > context.getStackLimit().max) {
+                    if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
                         // reset to last break
                         if (lastPos != null) {
-                            reset(lastPos.getPosition());
+                            LayoutManager lm = lastPos.getLayoutManager();
+                            lm.resetPosition(lastPos.getPosition());
+                            if (lm != curLM) {
+                                curLM.resetPosition(null);
+                            }
                         } else {
                             curLM.resetPosition(null);
                         }
                         break;
                     }
+                    stackSize.add(bp.getStackingSize());
                     lastPos = bp;
                     bodyBreaks.add(bp);
 
+                    if (bp.nextBreakOverflows()) {
+                        over = true;
+                        break;
+                    }
+
                     childLC.setStackLimit(MinOptMax.subtract(
                                              context.getStackLimit(), stackSize));
                 }
             }
             BreakPoss breakPoss = new BreakPoss(
                                     new LeafPosition(this, bodyBreaks.size() - 1));
+            if (over) { 
+                breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+            }
             breakPoss.setStackingSize(stackSize);
             return breakPoss;
         }
@@ -209,6 +223,8 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager {
         if (resetPos == null) {
             bodyBreaks.clear();
             reset(null);
+        } else {
+            
         }
     }
 }
index dbff104dcfc8230a6cc188ce4bfcf2af6f608e06..e495f0c4441ad22f40a12a723ac068d1fac114fc 100644 (file)
@@ -82,7 +82,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
      * @return the next break possibility
      */
     public BreakPoss getNextBreakPoss(LayoutContext context) {
-        Item curLM; // currently active LM
+        // currently active LM
+        Item curLM;
+
+        label.setUserAgent(getUserAgent());
+        body.setUserAgent(getUserAgent());
 
         BreakPoss lastPos = null;
         List breakList = new ArrayList();
@@ -92,6 +96,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
         int max = 0;
 
         int stage = 0;
+        boolean over = false;
         while (true) {
             if(stage == 0) {
                 curLM = label;
@@ -120,11 +125,14 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
             stage++;
             while (!curLM.isFinished()) {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                    stackSize.add(bp.getStackingSize());
-                    if (stackSize.opt > context.getStackLimit().max) {
+                    if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
                         // reset to last break
                         if (lastPos != null) {
-                            curLM.resetPosition(lastPos.getPosition());
+                            LayoutManager lm = lastPos.getLayoutManager();
+                            lm.resetPosition(lastPos.getPosition());
+                            if (lm != curLM) {
+                                curLM.resetPosition(null);
+                            }
                         } else {
                             curLM.resetPosition(null);
                         }
@@ -132,8 +140,14 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
                     } else {
                         lastPos = bp;
                     }
+                    stackSize.add(bp.getStackingSize());
                     childBreaks.add(bp);
 
+                    if (bp.nextBreakOverflows()) {
+                        over = true;
+                        break;
+                    }
+
                     childLC.setStackLimit(MinOptMax.subtract(
                                              context.getStackLimit(), stackSize));
                 }
@@ -160,6 +174,9 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager {
         setFinished(true);
         ItemPosition rp = new ItemPosition(this, breakList.size() - 1, breakList);
         BreakPoss breakPoss = new BreakPoss(rp);
+        if (over) { 
+            breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+        }
         breakPoss.setStackingSize(itemSize);
         return breakPoss;
     }
index 7ca0079d33e98261a839d3c7a22c31b0bc237160..7fc135b7dcc22532986d12b7586ff7bc4248d4bb 100644 (file)
@@ -8,6 +8,7 @@
 package org.apache.fop.layoutmgr.table;
 
 import org.apache.fop.fo.PropertyManager;
+import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
 import org.apache.fop.layoutmgr.LeafPosition;
 import org.apache.fop.layoutmgr.BreakPoss;
@@ -99,27 +100,42 @@ public class Body extends BlockStackingLayoutManager {
 
             curLM.setColumns(columns);
 
+            boolean over = false;
+
             while (!curLM.isFinished()) {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                    stackSize.add(bp.getStackingSize());
-                    if (stackSize.opt > context.getStackLimit().max) {
+                    if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
                         // reset to last break
                         if (lastPos != null) {
-                            reset(lastPos.getPosition());
+                            LayoutManager lm = lastPos.getLayoutManager();
+                            lm.resetPosition(lastPos.getPosition());
+                            if (lm != curLM) {
+                                curLM.resetPosition(null);
+                            }
                         } else {
                             curLM.resetPosition(null);
                         }
+                        over = true;
                         break;
                     }
+                    stackSize.add(bp.getStackingSize());
                     lastPos = bp;
                     childBreaks.add(bp);
 
+                    if (bp.nextBreakOverflows()) {
+                        over = true;
+                        break;
+                    }
+
                     childLC.setStackLimit(MinOptMax.subtract(
                                              context.getStackLimit(), stackSize));
                 }
             }
             BreakPoss breakPoss = new BreakPoss(
                                     new LeafPosition(this, childBreaks.size() - 1));
+            if (over) {
+                breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+            }
             breakPoss.setStackingSize(stackSize);
             return breakPoss;
         }
index 6c111cd563f97596cdc85f0715dff6fc61c8e77b..c69ab7b0f3c9738df15190857914256a151443ea 100644 (file)
@@ -74,27 +74,42 @@ public class Caption extends BlockStackingLayoutManager {
                                      stackSize));
             childLC.setRefIPD(ipd);
 
+            boolean over = false;
+
             while (!curLM.isFinished()) {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                    stackSize.add(bp.getStackingSize());
-                    if (stackSize.opt > context.getStackLimit().max) {
+                    if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
                         // reset to last break
                         if (lastPos != null) {
-                            reset(lastPos.getPosition());
+                            LayoutManager lm = lastPos.getLayoutManager();
+                            lm.resetPosition(lastPos.getPosition());
+                            if (lm != curLM) {
+                                curLM.resetPosition(null);
+                            }
                         } else {
                             curLM.resetPosition(null);
                         }
+                        over = true;
                         break;
                     }
+                    stackSize.add(bp.getStackingSize());
                     lastPos = bp;
                     childBreaks.add(bp);
 
+                    if (bp.nextBreakOverflows()) {
+                        over = true;
+                        break;
+                    }
+
                     childLC.setStackLimit(MinOptMax.subtract(
                                              context.getStackLimit(), stackSize));
                 }
             }
             BreakPoss breakPoss = new BreakPoss(
                                     new LeafPosition(this, childBreaks.size() - 1));
+            if (over) {
+                breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+            }
             breakPoss.setStackingSize(stackSize);
             return breakPoss;
         }
index 0c0dd1f5a4289f9df7c07de9f24363a91150a5c4..c0e00da2d0d8d74a9625dd209fdcb417db1ee6c6 100644 (file)
@@ -77,7 +77,7 @@ public class Cell extends BlockStackingLayoutManager {
 
         while ((curLM = getChildLM()) != null) {
             if(curLM.generatesInlineAreas()) {
-                // error
+                getLogger().error("table-cell must contain block areas - ignoring");
                 curLM.setFinished(true);
                 continue;
             }
@@ -90,27 +90,42 @@ public class Cell extends BlockStackingLayoutManager {
                                      stackSize));
             childLC.setRefIPD(ipd);
 
+            boolean over = false;
+
             while (!curLM.isFinished()) {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                    stackSize.add(bp.getStackingSize());
-                    if (stackSize.opt > context.getStackLimit().max) {
+                    if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
                         // reset to last break
                         if (lastPos != null) {
-                            reset(lastPos.getPosition());
+                            LayoutManager lm = lastPos.getLayoutManager();
+                            lm.resetPosition(lastPos.getPosition());
+                            if (lm != curLM) {
+                                curLM.resetPosition(null);
+                            }
                         } else {
                             curLM.resetPosition(null);
                         }
+                        over = true;
                         break;
                     }
+                    stackSize.add(bp.getStackingSize());
                     lastPos = bp;
                     childBreaks.add(bp);
 
+                    if (bp.nextBreakOverflows()) {
+                        over = true;
+                        break;
+                    }
+
                     childLC.setStackLimit(MinOptMax.subtract(
                                              context.getStackLimit(), stackSize));
                 }
             }
             BreakPoss breakPoss = new BreakPoss(
                                     new LeafPosition(this, childBreaks.size() - 1));
+            if (over) {
+                breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+            }
             breakPoss.setStackingSize(stackSize);
             return breakPoss;
         }
index 8c8d0a790bc555c6f33dae97af497dc4a8dc7701..a7beb6695e74e402f916b542cbf98361836e5e17 100644 (file)
@@ -84,6 +84,7 @@ public class Row extends BlockStackingLayoutManager {
         // add cells to list
         while (childLMiter.hasNext()) {
             curChildLM = (LayoutManager) childLMiter.next();
+            curChildLM.setUserAgent(getUserAgent());
             curChildLM.setParentLM(this);
             curChildLM.init();
             cellList.add(curChildLM);
@@ -125,6 +126,8 @@ public class Row extends BlockStackingLayoutManager {
         int max = 0;
 
         int cellcount = 0;
+        boolean over = false;
+
         while ((curLM = getCellLM(cellcount++)) != null) {
 
             List childBreaks = new ArrayList();
@@ -151,19 +154,29 @@ public class Row extends BlockStackingLayoutManager {
 
             while (!curLM.isFinished()) {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                    stackSize.add(bp.getStackingSize());
-                    if (stackSize.opt > context.getStackLimit().max) {
+                    if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
                         // reset to last break
                         if (lastPos != null) {
-                            reset(lastPos.getPosition());
+                            LayoutManager lm = lastPos.getLayoutManager();
+                            lm.resetPosition(lastPos.getPosition());
+                            if (lm != curLM) {
+                                curLM.resetPosition(null);
+                            }
                         } else {
                             curLM.resetPosition(null);
                         }
+                        over = true;
                         break;
                     }
+                    stackSize.add(bp.getStackingSize());
                     lastPos = bp;
                     childBreaks.add(bp);
 
+                    if (bp.nextBreakOverflows()) {
+                        over = true;
+                        break;
+                    }
+
                     childLC.setStackLimit(MinOptMax.subtract(
                                              context.getStackLimit(), stackSize));
                 }
@@ -190,10 +203,44 @@ public class Row extends BlockStackingLayoutManager {
         setFinished(true);
         RowPosition rp = new RowPosition(this, breakList.size() - 1, breakList);
         BreakPoss breakPoss = new BreakPoss(rp);
+        if (over) { 
+            breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+        }
         breakPoss.setStackingSize(rowSize);
         return breakPoss;
     }
 
+    /**
+     * Reset the layoutmanager "iterator" so that it will start
+     * with the passed Position's generating LM
+     * on the next call to getChildLM.
+     * @param pos a Position returned by a child layout manager
+     * representing a potential break decision.
+     * If pos is null, then back up to the first child LM.
+     */    
+    protected void reset(Position pos) {
+        LayoutManager curLM; // currently active LM
+        int cellcount = 0;
+
+        if (pos == null) {
+            while ((curLM = getCellLM(cellcount++)) != null) {
+                curLM.resetPosition(null);
+                cellcount++;
+            }
+        } else {
+            RowPosition rpos = (RowPosition)pos;
+            List breaks = rpos.cellBreaks;
+
+            while ((curLM = getCellLM(cellcount++)) != null) {
+                List childbreaks = (List)breaks.get(cellcount);
+                curLM.resetPosition((Position)childbreaks.get(childbreaks.size() - 1));
+                cellcount++;
+            }
+        }
+
+        setFinished(false);
+    }
+
     /**
      * Set the y position offset of this row.
      * This is used to set the position of the areas returned by this row.
index 920a72785da93431032bfa42b1038aa2c496aebc..0b7c2ccf42394672664c9bce818ac038b4f9a910 100644 (file)
@@ -76,27 +76,41 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
                                      stackSize));
             childLC.setRefIPD(ipd);
 
+            boolean over = false;
             while (!curLM.isFinished()) {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                    stackSize.add(bp.getStackingSize());
-                    if (stackSize.opt > context.getStackLimit().max) {
+                    if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
                         // reset to last break
                         if (lastPos != null) {
-                            reset(lastPos.getPosition());
+                            LayoutManager lm = lastPos.getLayoutManager();
+                            lm.resetPosition(lastPos.getPosition());
+                            if (lm != curLM) {
+                                curLM.resetPosition(null);
+                            }
                         } else {
                             curLM.resetPosition(null);
                         }
+                        over = true;
                         break;
                     }
+                    stackSize.add(bp.getStackingSize());
                     lastPos = bp;
                     childBreaks.add(bp);
 
+                    if (bp.nextBreakOverflows()) {
+                        over = true;
+                        break;
+                    }
+
                     childLC.setStackLimit(MinOptMax.subtract(
                                              context.getStackLimit(), stackSize));
                 }
             }
             BreakPoss breakPoss = new BreakPoss(
                                     new LeafPosition(this, childBreaks.size() - 1));
+            if (over) {
+                breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+            }
             breakPoss.setStackingSize(stackSize);
             return breakPoss;
         }
index c51c6061cffdd7fe7aa27da2270642a8faa0909c..45672fffed65fd9e79c14a4eaddf2f1bccbc0ec5 100644 (file)
@@ -139,27 +139,41 @@ public class TableLayoutManager extends BlockStackingLayoutManager {
 
             curLM.setColumns(columns);
 
+            boolean over = false;
             while (!curLM.isFinished()) {
                 if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
-                    stackSize.add(bp.getStackingSize());
-                    if (stackSize.opt > context.getStackLimit().max) {
+                    if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) {
                         // reset to last break
                         if (lastPos != null) {
-                            reset(lastPos.getPosition());
+                            LayoutManager lm = lastPos.getLayoutManager();
+                            lm.resetPosition(lastPos.getPosition());
+                            if (lm != curLM) {
+                                curLM.resetPosition(null);
+                            }
                         } else {
                             curLM.resetPosition(null);
                         }
+                        over = true;
                         break;
                     }
+                    stackSize.add(bp.getStackingSize());
                     lastPos = bp;
                     bodyBreaks.add(bp);
 
+                    if (bp.nextBreakOverflows()) {
+                        over = true;
+                        break;
+                    }
+
                     childLC.setStackLimit(MinOptMax.subtract(
                                              context.getStackLimit(), stackSize));
                 }
             }
             BreakPoss breakPoss = new BreakPoss(
                                     new LeafPosition(this, bodyBreaks.size() - 1));
+            if (over) {
+                breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true);
+            }
             breakPoss.setStackingSize(stackSize);
             return breakPoss;
         }