From 8bf1daae93a7cf5459835211fa3b5f6429b6b644 Mon Sep 17 00:00:00 2001
From: Jeremias Maerki
Date: Mon, 10 Mar 2008 10:06:37 +0000
Subject: [PATCH] Fixed NPE in BlockContainerLayoutManager when used as a child
of an inline-level FO. Split IP and BP stack limits in LayoutContext (there's
now a certain amount of redundancy with "refIPD" in LayoutContext which I
didn't resolve). 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
---
.../apache/fop/layoutmgr/AbstractBreaker.java | 4 +-
.../fop/layoutmgr/AreaAdditionUtil.java | 2 +-
.../BlockContainerLayoutManager.java | 35 ++----
.../fop/layoutmgr/BlockLayoutManager.java | 3 +-
.../layoutmgr/BlockStackingLayoutManager.java | 5 +-
.../fop/layoutmgr/FlowLayoutManager.java | 2 +-
.../apache/fop/layoutmgr/LayoutContext.java | 98 ++++++++++++-----
.../org/apache/fop/layoutmgr/PageBreaker.java | 2 +-
.../layoutmgr/StaticContentLayoutManager.java | 8 +-
.../inline/ContentLayoutManager.java | 24 ++--
.../layoutmgr/inline/InlineLayoutManager.java | 9 +-
.../layoutmgr/inline/LineLayoutManager.java | 13 ++-
.../list/ListBlockLayoutManager.java | 24 ++--
.../list/ListItemContentLayoutManager.java | 20 ++--
.../layoutmgr/list/ListItemLayoutManager.java | 38 ++++---
.../table/RowGroupLayoutManager.java | 3 +-
.../table/TableCellLayoutManager.java | 7 +-
.../layoutmgr/table/TableContentPosition.java | 2 +
.../table/TableHFPenaltyPosition.java | 5 +
.../table/TableHeaderFooterPosition.java | 5 +
status.xml | 4 +
.../inline_block-level_nested_1.xml | 104 ++++++++++++++++++
22 files changed, 293 insertions(+), 124 deletions(-)
create mode 100644 test/layoutengine/standard-testcases/inline_block-level_nested_1.xml
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
index 54fd315b1..65d537bcd 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
@@ -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 *** *** */
diff --git a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
index 80e0b74cc..1b0d02639 100644
--- a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
+++ b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
@@ -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);
}
diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
index fc60b561e..435f25b48 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
@@ -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();
diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
index bb39def8d..a65c0ed9b 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
@@ -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);
}
diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index 5faad623c..541912a08 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -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);
}
diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
index a70dd0883..115532cf1 100644
--- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
@@ -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());
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutContext.java b/src/java/org/apache/fop/layoutmgr/LayoutContext.java
index 9eb38600b..ba06d70b1 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutContext.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutContext.java
@@ -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 may 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 may 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" : "") + "]";
}
diff --git a/src/java/org/apache/fop/layoutmgr/PageBreaker.java b/src/java/org/apache/fop/layoutmgr/PageBreaker.java
index cf830a7ec..3e100cd50 100644
--- a/src/java/org/apache/fop/layoutmgr/PageBreaker.java
+++ b/src/java/org/apache/fop/layoutmgr/PageBreaker.java
@@ -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();
diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
index c8b89e6af..b1e414527 100644
--- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
@@ -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());
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
index 03e9b382a..ff7c5b3ce 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
@@ -19,9 +19,20 @@
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;
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
index b449b6689..1f53e792e 100755
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
@@ -19,12 +19,13 @@
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;
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index 6df7ac00c..9037cf628 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -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());
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
index 470cbbe9c..e17880e59 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
@@ -19,29 +19,29 @@
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();
}
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
index 853b1a128..363f6493f 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
@@ -19,24 +19,24 @@
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);
}
diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
index dc28e98e2..5c6e9aeb1 100644
--- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
@@ -19,8 +19,16 @@
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);
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
index c2e26e18d..917e8296b 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
@@ -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
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
index 8e92a233b..7036f199b 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
@@ -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
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java b/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
index db34764b1..260b8cfdf 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java
@@ -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());
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableHFPenaltyPosition.java b/src/java/org/apache/fop/layoutmgr/table/TableHFPenaltyPosition.java
index afa166985..3e504a45c 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableHFPenaltyPosition.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableHFPenaltyPosition.java
@@ -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("(");
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableHeaderFooterPosition.java b/src/java/org/apache/fop/layoutmgr/table/TableHeaderFooterPosition.java
index c3ae72c74..8d3b993b2 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableHeaderFooterPosition.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableHeaderFooterPosition.java
@@ -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");
diff --git a/status.xml b/status.xml
index 594b113e1..34307f721 100644
--- a/status.xml
+++ b/status.xml
@@ -94,6 +94,10 @@
+
+ Fixed exceptions when lists, tables or block-container are children of an inline-level
+ FO.
+
Added support for background on fo:table-column and fo:table-header/footer/body elements.
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
index 000000000..6b6761dee
--- /dev/null
+++ b/test/layoutengine/standard-testcases/inline_block-level_nested_1.xml
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+ This test checks fo:inline and nested block-level nodes.
+
+
+
+
+
+
+
+
+
+
+
+
+ before
+
+
+
+ •
+
+
+ Inline list item one.
+
+
+
+ after
+
+
+ before
+
+ "
+
+
+
+ cell1
+
+
+ cell2
+
+
+
+
+ after
+
+
+ before
+
+ block in block-container
+
+ after
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3
+
+
+
+
+
+
--
2.39.5