From fb3926df45b065e4161d8769c11131fe8af7b4fd Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Wed, 7 May 2008 14:04:17 +0000 Subject: Bugzilla 41500: Fixed a ClassCastException when fo:wrapper was used as a child of an fo:block-container. Bugzilla 42423: Added support for the "id" attribute on fo:wrappers that are children of the fo:flow. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@654111 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/BlockStackingLayoutManager.java | 16 +++++++++++++--- .../org/apache/fop/layoutmgr/FlowLayoutManager.java | 4 +++- .../fop/layoutmgr/inline/WrapperLayoutManager.java | 19 ++++++++++++++++++- 3 files changed, 34 insertions(+), 5 deletions(-) (limited to 'src/java/org/apache/fop/layoutmgr') diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index e9d529ebe..b208e4e9b 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -1527,10 +1527,20 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected void wrapPositionElements(List sourceList, List targetList, boolean force) { ListIterator listIter = sourceList.listIterator(); + Object tempElement; while (listIter.hasNext()) { - ListElement tempElement; - tempElement = (ListElement) listIter.next(); - wrapPositionElement(tempElement, targetList, force); + tempElement = listIter.next(); + if (tempElement instanceof ListElement) { + wrapPositionElement( + (ListElement) tempElement, + targetList, + force); + } else if (tempElement instanceof List) { + wrapPositionElements( + (List) tempElement, + targetList, + force); + } } } diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java index c54f0ce12..9cd5c622d 100644 --- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java @@ -30,6 +30,7 @@ import org.apache.fop.area.Area; import org.apache.fop.area.BlockParent; import org.apache.fop.fo.pagination.Flow; import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager; +import org.apache.fop.layoutmgr.inline.WrapperLayoutManager; /** * LayoutManager for an fo:flow object. @@ -75,7 +76,8 @@ public class FlowLayoutManager extends BlockStackingLayoutManager LinkedList returnList = new LinkedList(); while ((curLM = getChildLM()) != null) { - if (curLM instanceof InlineLevelLayoutManager) { + if (!(curLM instanceof WrapperLayoutManager) + && curLM instanceof InlineLevelLayoutManager) { log.error("inline area not allowed under flow - ignoring"); curLM.setFinished(true); continue; diff --git a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java index 09e22d481..8108bbf40 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java @@ -20,7 +20,12 @@ package org.apache.fop.layoutmgr.inline; import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.area.inline.InlineParent; +import org.apache.fop.area.Block; +import org.apache.fop.area.LineArea; import org.apache.fop.fo.flow.Wrapper; +import org.apache.fop.layoutmgr.BlockLayoutManager; +import org.apache.fop.layoutmgr.BlockStackingLayoutManager; import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.PositionIterator; import org.apache.fop.layoutmgr.TraitSetter; @@ -66,7 +71,19 @@ public class WrapperLayoutManager extends LeafNodeLayoutManager { if (fobj.hasId()) { addId(); InlineArea area = getEffectiveArea(); - parentLM.addChildArea(area); + if (parentLM instanceof BlockStackingLayoutManager + && !(parentLM instanceof BlockLayoutManager)) { + Block helperBlock = new Block(); + LineArea helperLine = new LineArea(); + InlineParent helperInline = new InlineParent(); + helperInline.addChildArea(area); + helperLine.addInlineArea(helperInline); + helperLine.updateExtentsFromChildren(); + helperBlock.addLineArea(helperLine); + parentLM.addChildArea(helperBlock); + } else { + parentLM.addChildArea(area); + } } while (posIter.hasNext()) { posIter.next(); -- cgit v1.2.3