]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixed NPE in BlockContainerLayoutManager when used as a child of an inline-level...
authorJeremias Maerki <jeremias@apache.org>
Mon, 10 Mar 2008 10:06:37 +0000 (10:06 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 10 Mar 2008 10:06:37 +0000 (10:06 +0000)
Areas are now generated for block-level FOs when used as children of inline-level FOs.
ClassCastException in ListLayoutManager.mustKeepTogether() fixed (occured if used as child of an inline-level FO).

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

22 files changed:
src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
src/java/org/apache/fop/layoutmgr/LayoutContext.java
src/java/org/apache/fop/layoutmgr/PageBreaker.java
src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
src/java/org/apache/fop/layoutmgr/table/TableHFPenaltyPosition.java
src/java/org/apache/fop/layoutmgr/table/TableHeaderFooterPosition.java
status.xml
test/layoutengine/standard-testcases/inline_block-level_nested_1.xml [new file with mode: 0644]

index 54fd315b1a60bc55b03edb3201e8aca4bd98fd34..65d537bcd4a76195cb363b615d09bc9e3b70c45f 100644 (file)
@@ -272,7 +272,7 @@ public abstract class AbstractBreaker {
      */
     public void doLayout(int flowBPD, boolean autoHeight) {
         LayoutContext childLC = createLayoutContext();
-        childLC.setStackLimit(new MinOptMax(flowBPD));
+        childLC.setStackLimitBP(new MinOptMax(flowBPD));
 
         if (getCurrentDisplayAlign() == Constants.EN_X_FILL) {
             //EN_X_FILL is non-standard (by LF)
@@ -495,7 +495,7 @@ public abstract class AbstractBreaker {
                     int averageLineLength = optimizeLineLength(effectiveList, 
                             startElementIndex, endElementIndex);
                     if (averageLineLength != 0) {
-                        childLC.setStackLimit(new MinOptMax(averageLineLength));
+                        childLC.setStackLimitBP(new MinOptMax(averageLineLength));
                     }
                 }
                 /* *** *** non-standard extension *** *** */
index 80e0b74cc29079deb2c9a3543077fc989e635628..1b0d02639fe13f7154f1b01f9c6433781aca73ba 100644 (file)
@@ -117,7 +117,7 @@ public class AreaAdditionUtil {
             // set space after for each LM, in order to implement
             // display-align = distribute
             lc.setSpaceAfter(layoutContext.getSpaceAfter());
-            lc.setStackLimit(layoutContext.getStackLimit());
+            lc.setStackLimitsFrom(layoutContext);
             childLM.addAreas(childPosIter, lc);
         }
         
index fc60b561eb4ca938185659d64615f9cbc3d3a0c4..435f25b487071c20c6951f60b53d33a26d94057e 100644 (file)
@@ -38,7 +38,6 @@ import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.flow.BlockContainer;
 import org.apache.fop.fo.properties.CommonAbsolutePosition;
-import org.apache.fop.layoutmgr.inline.InlineLayoutManager;
 import org.apache.fop.traits.MinOptMax;
 import org.apache.fop.traits.SpaceVal;
 
@@ -201,7 +200,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
             = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
         autoHeight = false;
         //boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0);
-        int maxbpd = context.getStackLimit().opt;
+        int maxbpd = context.getStackLimitBP().opt;
         int allocBPD;
         if (height.getEnum() == EN_AUTO 
                 || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) {
@@ -280,8 +279,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
                 LayoutContext childLC = new LayoutContext(0);
                 childLC.copyPendingMarksFrom(context);
                 // curLM is a ?
-                childLC.setStackLimit(MinOptMax.subtract(context
-                        .getStackLimit(), stackLimit));
+                childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit));
                 childLC.setRefIPD(relDims.ipd);
                 childLC.setWritingMode(getBlockContainerFO().getWritingMode());
 
@@ -411,7 +409,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
                 if (isFixed()) {
                     availHeight = (int)getCurrentPV().getViewArea().getHeight();
                 } else {
-                    availHeight = context.getStackLimit().opt; 
+                    availHeight = context.getStackLimitBP().opt; 
                 }
                 allocBPD = availHeight;
                 allocBPD -= offset.y;
@@ -444,7 +442,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
                     }
                 }
             } else {
-                int maxbpd = context.getStackLimit().opt;
+                int maxbpd = context.getStackLimitBP().opt;
                 allocBPD = maxbpd;
                 if (!switchedProgressionDirection) {
                     autoHeight = true;
@@ -625,7 +623,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
 
             while ((curLM = getChildLM()) != null) {
                 LayoutContext childLC = new LayoutContext(0);
-                childLC.setStackLimit(context.getStackLimit());
+                childLC.setStackLimitBP(context.getStackLimitBP());
                 childLC.setRefIPD(context.getRefIPD());
                 childLC.setWritingMode(getBlockContainerFO().getWritingMode());
                 
@@ -854,7 +852,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
                 // set last area flag
                 lc.setFlags(LayoutContext.LAST_AREA,
                         (layoutContext.isLastArea() && childLM == lastLM));
-                /*LF*/lc.setStackLimit(layoutContext.getStackLimit());
+                /*LF*/lc.setStackLimitBP(layoutContext.getStackLimitBP());
                 // Add the line areas to Area
                 childLM.addAreas(childPosIter, lc);
             }
@@ -992,30 +990,21 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
         
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public boolean mustKeepTogether() {
         //TODO Keeps will have to be more sophisticated sooner or later
-        return (!getBlockContainerFO().getKeepTogether().getWithinPage().isAuto()
-                || !getBlockContainerFO().getKeepTogether().getWithinColumn().isAuto()
-                || (getParent() instanceof BlockLevelLayoutManager
-                    && ((BlockLevelLayoutManager) getParent()).mustKeepTogether())
-                || (getParent() instanceof InlineLayoutManager
-                    && ((InlineLayoutManager) getParent()).mustKeepTogether()));
+        return super.mustKeepTogether()
+                || !getBlockContainerFO().getKeepTogether().getWithinPage().isAuto()
+                || !getBlockContainerFO().getKeepTogether().getWithinColumn().isAuto();
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public boolean mustKeepWithPrevious() {
         return !getBlockContainerFO().getKeepWithPrevious().getWithinPage().isAuto()
                 || !getBlockContainerFO().getKeepWithPrevious().getWithinColumn().isAuto();
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public boolean mustKeepWithNext() {
         return !getBlockContainerFO().getKeepWithNext().getWithinPage().isAuto()
                 || !getBlockContainerFO().getKeepWithNext().getWithinColumn().isAuto();
index bb39def8d668a83e1c3ce57456070bfade02077d..a65c0ed9b5f1f3aa2c48331efccb7012c113dbf5 100644 (file)
@@ -25,6 +25,7 @@ import java.util.ListIterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.LineArea;
@@ -389,7 +390,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager
             // set last area flag
             lc.setFlags(LayoutContext.LAST_AREA,
                     (layoutContext.isLastArea() && childLM == lastLM));
-            lc.setStackLimit(layoutContext.getStackLimit());
+            lc.setStackLimitBP(layoutContext.getStackLimitBP());
             // Add the line areas to Area
             childLM.addAreas(childPosIter, lc);
         }
index 5faad623c886f8dbc03b3b6e20feee9fe4b15679..541912a082ef9c0169ed9efc8fb6a662fbe5ff20 100644 (file)
@@ -274,13 +274,14 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
             if (curLM instanceof LineLayoutManager) {
                 // curLM is a LineLayoutManager
                 // set stackLimit for lines (stack limit is now i-p-direction, not b-p-direction!)
-                childLC.setStackLimit(new MinOptMax(getContentAreaIPD()));
+                childLC.setStackLimitBP(context.getStackLimitBP());
+                childLC.setStackLimitIP(new MinOptMax(getContentAreaIPD()));
                 childLC.setRefIPD(getContentAreaIPD());
             } else {
                 // curLM is a ?
                 //childLC.setStackLimit(MinOptMax.subtract(context
                 //        .getStackLimit(), stackSize));
-                childLC.setStackLimit(context.getStackLimit());
+                childLC.setStackLimitBP(context.getStackLimitBP());
                 childLC.setRefIPD(referenceIPD);
             }
 
index a70dd0883bb3a62427a717342e158c40095a2d29..115532cf12f97da475975200188df111d899f699 100644 (file)
@@ -99,7 +99,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager
             //MinOptMax bpd = context.getStackLimit();
 
             LayoutContext childLC = new LayoutContext(0);
-            childLC.setStackLimit(context.getStackLimit());
+            childLC.setStackLimitBP(context.getStackLimitBP());
             childLC.setRefIPD(context.getRefIPD());
             childLC.setWritingMode(getCurrentPage().getSimplePageMaster().getWritingMode());
             
index 9eb38600b6309b3eda755971340f47c8e61ab39a..ba06d70b134a2099e6b8dde6de28e8490c0c57dc 100644 (file)
@@ -74,12 +74,21 @@ public class LayoutContext {
     private int flags; // Contains some set of flags defined above
     /**
      * Total available stacking dimension for a "galley-level" layout
-     * manager (Line or Flow). It is passed by the parent LM. For LineLM,
-     * the block LM determines this based on indent properties.
+     * manager in block-progression-direction. It is passed by the
+     * parent LM.
      * These LM <b>may</b> wish to pass this information down to lower
      * level LM to allow them to optimize returned break possibilities.
      */
-    private MinOptMax stackLimit;
+    private MinOptMax stackLimitBP;
+    /**
+     * Total available stacking dimension for a "galley-level" layout
+     * manager in inline-progression-direction. It is passed by the
+     * parent LM. For LineLM, the block LM determines this based on
+     * indent properties.
+     * These LM <b>may</b> wish to pass this information down to lower
+     * level LM to allow them to optimize returned break possibilities.
+     */
+    private MinOptMax stackLimitIP;
 
     /** True if current element list is spanning in multi-column layout. */
     private int nextSpan = Constants.NOT_SET;
@@ -145,7 +154,7 @@ public class LayoutContext {
         this.flags = parentLC.flags;
         this.refIPD = parentLC.refIPD;
         this.writingMode = parentLC.writingMode;
-        this.stackLimit = null; // Don't reference parent MinOptMax!
+        setStackLimitsFrom(parentLC);
         this.leadingSpace = parentLC.leadingSpace; //???
         this.trailingSpace = parentLC.trailingSpace; //???
         this.hyphContext = parentLC.hyphContext;
@@ -166,7 +175,8 @@ public class LayoutContext {
     public LayoutContext(int flags) {
         this.flags = flags;
         this.refIPD = 0;
-        stackLimit = new MinOptMax(0);
+        stackLimitBP = new MinOptMax(0);
+        stackLimitIP = new MinOptMax(0);
         leadingSpace = null;
         trailingSpace = null;
     }
@@ -306,14 +316,47 @@ public class LayoutContext {
         }
     }
     
-    public void setStackLimit(MinOptMax limit) {
-        stackLimit = limit;
+    /**
+     * Sets the stack limit in block-progression-dimension.
+     * @param limit the stack limit
+     */
+    public void setStackLimitBP(MinOptMax limit) {
+        stackLimitBP = limit;
     }
 
-    public MinOptMax getStackLimit() {
-        return stackLimit;
+    /**
+     * Returns the stack limit in block-progression-dimension.
+     * @return the stack limit
+     */
+    public MinOptMax getStackLimitBP() {
+        return stackLimitBP;
     }
 
+    /**
+     * Sets the stack limit in inline-progression-dimension.
+     * @param limit the stack limit
+     */
+    public void setStackLimitIP(MinOptMax limit) {
+        stackLimitIP = limit;
+    }
+
+    /**
+     * Returns the stack limit in inline-progression-dimension.
+     * @return the stack limit
+     */
+    public MinOptMax getStackLimitIP() {
+        return stackLimitIP;
+    }
+
+    /**
+     * Sets (Copies) the stack limits in both directions from another layout context.
+     * @param context the layout context to taje the values from
+     */
+    public void setStackLimitsFrom(LayoutContext context) {
+        setStackLimitBP(context.getStackLimitBP());
+        setStackLimitIP(context.getStackLimitIP());
+    }
+    
     /**
      * Sets the inline-progression-dimension of the nearest ancestor reference area.
      */
@@ -536,22 +579,27 @@ public class LayoutContext {
 
     /** {@inheritDoc} */
     public String toString() {
-        return "Layout Context:" +
-        "\nStack Limit: \t" + (getStackLimit() == null ? "null" : getStackLimit().toString()) +
-        "\nTrailing Space: \t" + (getTrailingSpace() == null ? "null" : getTrailingSpace().toString()) +
-        "\nLeading Space: \t" + (getLeadingSpace() == null ? "null" : getLeadingSpace().toString()) + 
-        "\nReference IPD: \t" + getRefIPD() +
-        "\nSpace Adjust: \t" + getSpaceAdjust() + 
-        "\nIPD Adjust: \t" + getIPDAdjust() +
-        "\nResolve Leading Space: \t" + resolveLeadingSpace() +
-        "\nSuppress Leading Space: \t" + suppressLeadingSpace() +
-        "\nIs First Area: \t" + isFirstArea() + 
-        "\nStarts New Area: \t" + startsNewArea() + 
-        "\nIs Last Area: \t" + isLastArea() +
-        "\nTry Hyphenate: \t" + tryHyphenate() + 
-        "\nKeeps: \t[" + (isKeepWithNextPending() ? "keep-with-next" : "") + "][" 
-            + (isKeepWithPreviousPending() ? "keep-with-previous" : "") + "] pending" +
-        "\nBreaks: \tforced [" + (breakBefore != Constants.EN_AUTO ? "break-before" : "") + "][" 
+        return "Layout Context:"
+        + "\nStack Limit BPD: \t"
+            + (getStackLimitBP() == null ? "null" : getStackLimitBP().toString())
+        + "\nStack Limit IPD: \t"
+            + (getStackLimitIP() == null ? "null" : getStackLimitIP().toString())
+        + "\nTrailing Space: \t"
+            + (getTrailingSpace() == null ? "null" : getTrailingSpace().toString())
+        + "\nLeading Space: \t"
+            + (getLeadingSpace() == null ? "null" : getLeadingSpace().toString()) 
+        + "\nReference IPD: \t" + getRefIPD()
+        + "\nSpace Adjust: \t" + getSpaceAdjust()
+        + "\nIPD Adjust: \t" + getIPDAdjust()
+        + "\nResolve Leading Space: \t" + resolveLeadingSpace()
+        + "\nSuppress Leading Space: \t" + suppressLeadingSpace()
+        + "\nIs First Area: \t" + isFirstArea()
+        + "\nStarts New Area: \t" + startsNewArea()
+        + "\nIs Last Area: \t" + isLastArea()
+        + "\nTry Hyphenate: \t" + tryHyphenate()
+        + "\nKeeps: \t[" + (isKeepWithNextPending() ? "keep-with-next" : "") + "][" 
+            + (isKeepWithPreviousPending() ? "keep-with-previous" : "") + "] pending"
+        + "\nBreaks: \tforced [" + (breakBefore != Constants.EN_AUTO ? "break-before" : "") + "][" 
         + (breakAfter != Constants.EN_AUTO ? "break-after" : "") + "]";
     }
 
index cf830a7ecb3807a843908d283272b56ee36ca770..3e100cd50ea97d945390ec402b0c6e9a57857f68 100644 (file)
@@ -156,7 +156,7 @@ public class PageBreaker extends AbstractBreaker {
                     // element represents a line with footnote citations
                     bFootnotesPresent = true;
                     LayoutContext footnoteContext = new LayoutContext(context);
-                    footnoteContext.setStackLimit(context.getStackLimit());
+                    footnoteContext.setStackLimitBP(context.getStackLimitBP());
                     footnoteContext.setRefIPD(pslm.getCurrentPV()
                             .getRegionReference(Constants.FO_REGION_BODY).getIPD());
                     LinkedList footnoteBodyLMs = ((KnuthBlockBox) element).getFootnoteBodyLMs();
index c8b89e6af1faf2b08d951019c795400bc22b92ca..b1e41452793809d9f429c836b07cd06172013c1b 100644 (file)
@@ -93,7 +93,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
         //TODO Empty this method?!?
         // set layout dimensions
         setContentAreaIPD(context.getRefIPD());
-        setContentAreaBPD(context.getStackLimit().opt);
+        setContentAreaBPD(context.getStackLimitBP().opt);
 
         //TODO Copied from elsewhere. May be worthwhile to factor out the common parts. 
         // currently active LM
@@ -111,10 +111,10 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
             }
 
             // Set up a LayoutContext
-            MinOptMax bpd = context.getStackLimit();
+            MinOptMax bpd = context.getStackLimitBP();
 
             LayoutContext childLC = new LayoutContext(0);
-            childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
+            childLC.setStackLimitBP(MinOptMax.subtract(bpd, stackSize));
             childLC.setRefIPD(context.getRefIPD());
 
             // get elements from curLM
@@ -307,7 +307,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
 
             while ((curLM = getChildLM()) != null) {
                 LayoutContext childLC = new LayoutContext(0);
-                childLC.setStackLimit(context.getStackLimit());
+                childLC.setStackLimitBP(context.getStackLimitBP());
                 childLC.setRefIPD(context.getRefIPD());
                 childLC.setWritingMode(context.getWritingMode());
 
index 03e9b382a8f383af015c47a86f82287e177b878d..ff7c5b3ced0ddf4c4ff55747b7311018f90aae9d 100644 (file)
 
 package org.apache.fop.layoutmgr.inline;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
+import org.apache.fop.area.LineArea;
+import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.pagination.Title;
 import org.apache.fop.layoutmgr.AbstractBaseLayoutManager;
@@ -34,19 +45,8 @@ import org.apache.fop.layoutmgr.PageSequenceLayoutManager;
 import org.apache.fop.layoutmgr.Position;
 import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.SpaceSpecifier;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.LineArea;
-import org.apache.fop.area.inline.InlineArea;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.ArrayList;
-import java.util.Iterator;
 import org.apache.fop.traits.MinOptMax;
 
-import org.apache.fop.area.Block;
-
 /**
  * Content Layout Manager.
  * For use with objects that contain inline areas such as
@@ -115,7 +115,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
         childLC.setLeadingSpace(new SpaceSpecifier(false));
         childLC.setTrailingSpace(new SpaceSpecifier(false));
         // set stackLimit for lines
-        childLC.setStackLimit(new MinOptMax(ipd));
+        childLC.setStackLimitIP(new MinOptMax(ipd));
         childLC.setRefIPD(ipd);
 
         int lineHeight = 14000;
index b449b668990093c568a6bc4a8c15edd19e950303..1f53e792e6002c5437f984e985819980cd06d38a 100755 (executable)
 
 package org.apache.fop.layoutmgr.inline;
 
-import java.util.ListIterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.ListIterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.area.Area;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.InlineBlockParent;
@@ -47,12 +48,12 @@ import org.apache.fop.layoutmgr.InlineKnuthSequence;
 import org.apache.fop.layoutmgr.KnuthBox;
 import org.apache.fop.layoutmgr.KnuthSequence;
 import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.NonLeafPosition;
-import org.apache.fop.layoutmgr.SpaceSpecifier;
-import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.NonLeafPosition;
 import org.apache.fop.layoutmgr.Position;
 import org.apache.fop.layoutmgr.PositionIterator;
+import org.apache.fop.layoutmgr.SpaceSpecifier;
+import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.traits.MinOptMax;
 import org.apache.fop.traits.SpaceVal;
 
index 6df7ac00c8c3f2fcde3c34cf1311f18cef260327..9037cf62857db2cf569f01768b020285b36866f7 100644 (file)
@@ -26,6 +26,7 @@ import java.util.ListIterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.area.Area;
 import org.apache.fop.area.LineArea;
 import org.apache.fop.area.Trait;
@@ -583,7 +584,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
         // Set up constraints for inline level managers
 
         // IPD remaining in line
-        MinOptMax availIPD = context.getStackLimit();
+        MinOptMax availIPD = context.getStackLimitIP();
 
         clearPrevIPD();
 
@@ -646,7 +647,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
         
         InlineLevelLayoutManager curLM;
         LinkedList returnedList = null;
-        iLineWidth = context.getStackLimit().opt;
+        iLineWidth = context.getStackLimitIP().opt;
             
         // convert all the text in a sequence of paragraphs made
         // of KnuthBox, KnuthGlue and KnuthPenalty objects
@@ -1687,7 +1688,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
              */
             if (false && textAlignment == EN_JUSTIFY) {
                 // re-compute space adjust ratio
-                int updatedDifference = context.getStackLimit().opt
+                int updatedDifference = context.getStackLimitIP().opt
                                         - lbp.lineWidth + lbp.difference;
                 double updatedRatio = 0.0;
                 if (updatedDifference > 0) {
@@ -1701,12 +1702,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager
             } else if (false && textAlignment == EN_CENTER) {
                 // re-compute indent
                 int updatedIndent = lbp.startIndent
-                                    + (context.getStackLimit().opt - lbp.lineWidth) / 2;
+                                    + (context.getStackLimitIP().opt - lbp.lineWidth) / 2;
                 lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent));
             } else if (false && textAlignment == EN_END) {
                 // re-compute indent
                 int updatedIndent = lbp.startIndent 
-                                    + (context.getStackLimit().opt - lbp.lineWidth);
+                                    + (context.getStackLimitIP().opt - lbp.lineWidth);
                 lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent));
             }
             
@@ -1770,7 +1771,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
             // set last area flag
             blocklc.setFlags(LayoutContext.LAST_AREA,
                              (context.isLastArea() && childLM == lastLM));
-            blocklc.setStackLimit(context.getStackLimit());
+            blocklc.setStackLimitsFrom(context);
             // Add the line areas to Area
             childLM.addAreas(childPosIter, blocklc);
             blocklc.setLeadingSpace(blocklc.getTrailingSpace());
index 470cbbe9c018675ebaa551b9da23ea6fbaa663f3..e17880e59bf5348e985343ce84b06f6f43cf893c 100644 (file)
  
 package org.apache.fop.layoutmgr.list;
 
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
 import org.apache.fop.fo.flow.ListBlock;
-import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
 import org.apache.fop.layoutmgr.ConditionalElementListener;
 import org.apache.fop.layoutmgr.ElementListUtils;
-import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.NonLeafPosition;
+import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.RelSide;
 import org.apache.fop.layoutmgr.TraitSetter;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
 import org.apache.fop.traits.MinOptMax;
 import org.apache.fop.traits.SpaceVal;
 
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
 /**
  * LayoutManager for a list-block FO.
  * A list block contains list items which are stacked within
@@ -200,7 +200,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager
             lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
             lc.setFlags(LayoutContext.FIRST_AREA, childLM == firstLM);
             lc.setFlags(LayoutContext.LAST_AREA, childLM == lastLM);
-            lc.setStackLimit(layoutContext.getStackLimit());
+            lc.setStackLimitBP(layoutContext.getStackLimitBP());
             childLM.addAreas(childPosIter, lc);
         }
 
@@ -280,7 +280,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager
     /** {@inheritDoc} */
     public boolean mustKeepTogether() {
         //TODO Keeps will have to be more sophisticated sooner or later
-        return ((BlockLevelLayoutManager)getParent()).mustKeepTogether() 
+        return super.mustKeepTogether() 
                 || !getListBlockFO().getKeepTogether().getWithinPage().isAuto()
                 || !getListBlockFO().getKeepTogether().getWithinColumn().isAuto();
     }
index 853b1a128a4ef3cffb4689282bdd5dd9ed464887..363f6493f755dca9d6f2df631f3b952fbf885529 100644 (file)
  
 package org.apache.fop.layoutmgr.list;
 
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
 import org.apache.fop.fo.flow.AbstractListItemPart;
 import org.apache.fop.fo.flow.ListItemBody;
 import org.apache.fop.fo.flow.ListItemLabel;
 import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
 import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
-import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.NonLeafPosition;
+import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.LinkedList;
 
 /**
  * LayoutManager for a list-item-label or list-item-body FO.
@@ -162,7 +162,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager {
             lc.setFlags(LayoutContext.LAST_AREA, childLM == lastLM);
             // set the space adjustment ratio
             lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
-            lc.setStackLimit(layoutContext.getStackLimit());
+            lc.setStackLimitBP(layoutContext.getStackLimitBP());
             childLM.addAreas(childPosIter, lc);
         }
 
index dc28e98e2ab9b63201aae3903ae380957ed73dfa..5c6e9aeb1d6f4ae9de5f10d100d56f5a86d7f6e6 100644 (file)
 
 package org.apache.fop.layoutmgr.list;
 
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
 import org.apache.fop.fo.flow.ListItem;
 import org.apache.fop.fo.flow.ListItemBody;
 import org.apache.fop.fo.flow.ListItemLabel;
@@ -30,28 +38,21 @@ import org.apache.fop.layoutmgr.BreakElement;
 import org.apache.fop.layoutmgr.ConditionalElementListener;
 import org.apache.fop.layoutmgr.ElementListObserver;
 import org.apache.fop.layoutmgr.ElementListUtils;
-import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.KnuthBox;
+import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.KnuthPenalty;
+import org.apache.fop.layoutmgr.KnuthPossPosIter;
 import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.NonLeafPosition;
+import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.RelSide;
 import org.apache.fop.layoutmgr.SpaceResolver;
 import org.apache.fop.layoutmgr.TraitSetter;
-import org.apache.fop.layoutmgr.KnuthElement;
-import org.apache.fop.layoutmgr.KnuthBox;
-import org.apache.fop.layoutmgr.KnuthPenalty;
-import org.apache.fop.layoutmgr.KnuthPossPosIter;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
 import org.apache.fop.traits.MinOptMax;
 import org.apache.fop.traits.SpaceVal;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.ListIterator;
-
 /**
  * LayoutManager for a list-item FO.
  * The list item contains a list item label and a list item body.
@@ -115,6 +116,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
             return iBodyLastIndex;
         }
         
+        /** {@inheritDoc} */
+        public boolean generatesAreas() {
+            return true;
+        }
+
         /** {@inheritDoc} */
         public String toString() {
             StringBuffer sb = new StringBuffer("ListItemPosition:");
@@ -510,7 +516,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
             // set the space adjustment ratio
             lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
             // TO DO: use the right stack limit for the label
-            lc.setStackLimit(layoutContext.getStackLimit());
+            lc.setStackLimitBP(layoutContext.getStackLimitBP());
             label.addAreas(labelIter, lc);
         }
 
@@ -531,7 +537,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager
             // set the space adjustment ratio
             lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
             // TO DO: use the right stack limit for the body
-            lc.setStackLimit(layoutContext.getStackLimit());
+            lc.setStackLimitBP(layoutContext.getStackLimitBP());
             body.addAreas(bodyIter, lc);
         }
 
index c2e26e18dbdd1fec3adae68de7a1cdf30265a5a1..917e8296be14b7db17bb7c795acd7c6870bc8b64 100644 (file)
@@ -24,6 +24,7 @@ import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.flow.table.EffRow;
@@ -147,7 +148,7 @@ class RowGroupLayoutManager {
                             }
                         }
                         LayoutContext childLC = new LayoutContext(0);
-                        childLC.setStackLimit(context.getStackLimit()); //necessary?
+                        childLC.setStackLimitBP(context.getStackLimitBP()); //necessary?
                         childLC.setRefIPD(spanWidth);
                         
                         //Get the element list for the cell contents
index 8e92a233b8f27623c4a39f69d93e3edbcff3e7e6..7036f199b4a53fd196b1c91ee8562f2f0ad50f55 100644 (file)
@@ -23,6 +23,7 @@ import java.util.LinkedList;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.Trait;
@@ -146,7 +147,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
      * {@inheritDoc}
      */
     public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
-        MinOptMax stackLimit = new MinOptMax(context.getStackLimit());
+        MinOptMax stackLimit = new MinOptMax(context.getStackLimitBP());
 
         referenceIPD = context.getRefIPD();
         cellIPD = referenceIPD;
@@ -161,8 +162,8 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
         while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) {
             LayoutContext childLC = new LayoutContext(0);
             // curLM is a ?
-            childLC.setStackLimit(MinOptMax.subtract(context
-                    .getStackLimit(), stackLimit));
+            childLC.setStackLimitBP(MinOptMax.subtract(context
+                    .getStackLimitBP(), stackLimit));
             childLC.setRefIPD(cellIPD);
 
             // get elements from curLM
index db34764b1fb5ee3f80159da6b7a48bcfcdc80982..260b8cfdf1a94f65b051fb9e7d00a1b76be3b54a 100644 (file)
@@ -106,10 +106,12 @@ class TableContentPosition extends Position {
         }
     }
 
+    /** {@inheritDoc} */
     public boolean generatesAreas() {
         return true;
     }
 
+    /** {@inheritDoc} */
     public String toString() {
         StringBuffer sb = new StringBuffer("TableContentPosition:");
         sb.append(getIndex());
index afa1669858c47873fcd756d1855787caf56a8ec8..3e504a45c84c9f26729f83227ae4bdfd9db3b852 100644 (file)
@@ -43,6 +43,11 @@ class TableHFPenaltyPosition extends Position {
         super(lm);
     }
 
+    /** {@inheritDoc} */
+    public boolean generatesAreas() {
+        return true;
+    }
+
     public String toString() {
         StringBuffer sb = new StringBuffer("TableHFPenaltyPosition:");
         sb.append(getIndex()).append("(");
index c3ae72c74372f093472323228de0fbb3c8034f67..8d3b993b2624c1c6a8c3902b7f0cc22535a897f6 100644 (file)
@@ -48,6 +48,11 @@ class TableHeaderFooterPosition extends Position {
         this.nestedElements = nestedElements;
     }
 
+    /** {@inheritDoc} */
+    public boolean generatesAreas() {
+        return true;
+    }
+
     public String toString() {
         StringBuffer sb = new StringBuffer("Table");
         sb.append(header ? "Header" : "Footer");
index 594b113e15e15bef3f631277e3f6484770d355cd..34307f7214f27cee357e34a40bae7ee9bcf301d4 100644 (file)
           </p>
         </section>
       </notes>
+      <action context="Layout" dev="JM" type="fix">
+        Fixed exceptions when lists, tables or block-container are children of an inline-level
+        FO.
+      </action>
       <action context="Layout" dev="VH" type="add" importance="high">
         Added support for background on fo:table-column and fo:table-header/footer/body elements.
       </action>
diff --git a/test/layoutengine/standard-testcases/inline_block-level_nested_1.xml b/test/layoutengine/standard-testcases/inline_block-level_nested_1.xml
new file mode 100644 (file)
index 0000000..6b6761d
--- /dev/null
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks fo:inline and nested block-level nodes.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="6in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            <fo:inline>before
+              <fo:list-block>
+                <fo:list-item>
+                  <fo:list-item-label end-indent="label-end()">
+                    <fo:block>&#x2022;</fo:block>
+                  </fo:list-item-label>
+                  <fo:list-item-body start-indent="body-start()">
+                    <fo:block id="list-item-body1">Inline list item one.</fo:block>
+                  </fo:list-item-body>
+                </fo:list-item>
+              </fo:list-block>
+            after</fo:inline>
+          </fo:block>
+          <fo:block space-before="0.5em">
+            <fo:inline>before
+              <fo:table table-layout="fixed" width="100%">
+                <fo:table-column column-width="proportional-column-width(1)"
+                  number-columns-repeated="2"/>"
+                <fo:table-body>
+                  <fo:table-row>
+                    <fo:table-cell id="table-cell1">
+                      <fo:block>cell1</fo:block>
+                    </fo:table-cell>
+                    <fo:table-cell>
+                      <fo:block>cell2</fo:block>
+                    </fo:table-cell>
+                  </fo:table-row>
+                </fo:table-body>
+              </fo:table>
+            after</fo:inline>
+          </fo:block>
+          <fo:block space-before="0.5em">
+            <fo:inline>before
+              <fo:block-container>
+                <fo:block id="block-in-bc">block in block-container</fo:block>
+              </fo:block-container>
+            after</fo:inline>
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <element-list category="breaker">
+      <box w="14400"/>
+      <penalty w="0" p="0"/>
+      <box w="14400"/>
+      <penalty w="0" p="0"/>
+      <box w="14400"/>
+      <penalty w="0" p="0"/>
+      <glue w="6000" aux="true"/>
+      <box w="14400"/>
+      <penalty w="0" p="0"/>
+      <box w="14400"/>
+      <penalty w="0" p="0"/>
+      <box w="14400"/>
+      <penalty w="0" p="0"/>
+      <glue w="6000" aux="true"/>
+      <box w="14400"/>
+      <penalty w="0" p="0"/>
+      <box w="14400"/>
+      <penalty w="0" p="0"/>
+      <box w="14400"/>
+      <skip>3</skip>
+    </element-list>
+    <true xpath="boolean(//block[@prod-id='list-item-body1'])"/>
+    <true xpath="boolean(//block[@prod-id='table-cell1'])"/>
+    <true xpath="boolean(//block[@prod-id='block-in-bc'])"/>
+  </checks>
+</testcase>