Index: src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java =================================================================== --- src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java (revision 996712) +++ src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java (working copy) @@ -74,7 +74,6 @@ private CommonMarginInline inlineProps = null; private CommonBorderPaddingBackground borderProps = null; - private boolean areaCreated = false; private LayoutManager lastChildLM = null; // Set when return last breakposs; private Position auxiliaryPosition; @@ -96,6 +95,8 @@ private AlignmentContext alignmentContext = null; + private Position firstPosition = null; + /** * Create an inline layout manager. * This is used for fo's that create areas that @@ -396,7 +397,15 @@ } } - return returnList.isEmpty() ? null : returnList; + boolean isEmpty = returnList.isEmpty(); + + if (!isEmpty) { + KnuthSequence firstSeq = (KnuthSequence)returnList.get(0); + if (!firstSeq.isEmpty()) + firstPosition = firstSeq.getElement(0).getPosition(); + } + + return isEmpty ? null : returnList; } /** @@ -415,18 +424,9 @@ setChildContext(new LayoutContext(context)); // Store current value - // If this LM has fence, make a new leading space specifier. - if (hasLeadingFence(areaCreated)) { - getContext().setLeadingSpace(new SpaceSpecifier(false)); - getContext().setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true); - } else { - getContext().setFlags(LayoutContext.RESOLVE_LEADING_SPACE, false); - } + // should be always false + boolean areaCreated = firstPosition != null; - if (getSpaceStart() != null) { - context.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart(), this)); - } - // "Unwrap" the NonLeafPositions stored in parentIter and put // them in a new list. Set lastLM to be the LayoutManager // which created the last Position: if the LAST_AREA flag is @@ -439,12 +439,27 @@ Position lastPos = null; while (parentIter.hasNext()) { pos = (NonLeafPosition) parentIter.next(); + if (pos == firstPosition) + areaCreated = false; if (pos != null && pos.getPosition() != null) { positionList.add(pos.getPosition()); lastLM = pos.getPosition().getLM(); lastPos = pos; } } + + // If this LM has fence, make a new leading space specifier. + if (hasLeadingFence(areaCreated)) { + getContext().setLeadingSpace(new SpaceSpecifier(false)); + getContext().setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true); + } else { + getContext().setFlags(LayoutContext.RESOLVE_LEADING_SPACE, false); + } + + if (getSpaceStart() != null) { + context.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart(), this)); + } + /*if (pos != null) { lastLM = pos.getPosition().getLM(); }*/