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) @@ -48,6 +48,7 @@ import org.apache.fop.layoutmgr.BreakElement; import org.apache.fop.layoutmgr.InlineKnuthSequence; import org.apache.fop.layoutmgr.KnuthBox; +import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthSequence; import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.LayoutManager; @@ -74,7 +75,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 +96,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,9 +398,20 @@ } } - return returnList.isEmpty() ? null : returnList; + boolean isEmpty = returnList.isEmpty(); + + if (!isEmpty) + storeFirstPosition((List)returnList.get(0)); + + return isEmpty ? null : returnList; } + private void storeFirstPosition(List knuthSequence) { + firstPosition = null; + if (!knuthSequence.isEmpty()) + firstPosition = ((KnuthElement)knuthSequence.get(0)).getPosition(); + } + /** * Generate and add areas to parent area. * Set size of each area. This should only create and return one @@ -415,18 +428,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 +443,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(); }*/ @@ -537,6 +556,7 @@ addKnuthElementsForBorderPaddingStart(returnedList); returnedList.addAll(super.getChangedKnuthElements(oldList, alignment)); addKnuthElementsForBorderPaddingEnd(returnedList); + storeFirstPosition(returnedList); return returnedList; }