From d8d40c99b9654e0974f4939a2028137253cfeea5 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Wed, 18 May 2005 16:03:38 +0000 Subject: Bugfix for a ClassCastException on autoheight block-containers where Position instances come through for normal penalties between blocks. Additional fix so a distinction is made between space-related positions and the penalties that caused the problem above. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198655 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/BlockContainerLayoutManager.java | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/java/org') diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index 8a1c3c86d..d9e06a5ff 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -585,7 +585,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { while (parentIter.hasNext()) { pos = (Position) parentIter.next(); /* LF *///System.out.println("pos = " + pos.getClass().getName()); - Position innerPosition = ((NonLeafPosition) pos).getPosition(); + Position innerPosition = null; + if (pos instanceof NonLeafPosition) { + innerPosition = ((NonLeafPosition)pos).getPosition(); + } if (pos instanceof BlockContainerPosition) { if (bcpos != null) { throw new IllegalStateException("Only one BlockContainerPosition allowed"); @@ -594,17 +597,19 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { //Add child areas inside the reference area //bcpos.getBreaker().addContainedAreas(); } else if (innerPosition == null) { - // pos was created by this BCLM and was inside an element - // representing space before or after - // this means the space was not discarded - if (positionList.size() == 0 && bcpos == null) { - // pos was in the element representing space-before - bSpaceBefore = true; - /* LF *///System.out.println(" space-before"); + if (pos instanceof NonLeafPosition) { + // pos was created by this BCLM and was inside an element + // representing space before or after + // this means the space was not discarded + if (positionList.size() == 0 && bcpos == null) { + // pos was in the element representing space-before + bSpaceBefore = true; + } else { + // pos was in the element representing space-after + bSpaceAfter = true; + } } else { - // pos was in the element representing space-after - bSpaceAfter = true; - /* LF *///System.out.println(" space-after"); + //ignore (probably a Position for a simple penalty between blocks) } } else if (innerPosition.getLM() == this && !(innerPosition instanceof MappingPosition)) { -- cgit v1.2.3