Sfoglia il codice sorgente

Decommission InlineStackingLM.StackingIter (+ minor fixups)

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1067371 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_1rc1old
Andreas L. Delmelle 13 anni fa
parent
commit
58d1c60f10

+ 11
- 10
src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java Vedi File

import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.ListElement; import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.NonLeafPosition; import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator; import org.apache.fop.layoutmgr.PositionIterator;


/** /**
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void initialize() { public void initialize() {
// create an InlineStackingLM handling the fo:inline child of fo:footnote // create an InlineStackingLM handling the fo:inline child of fo:footnote
citationLM = new InlineLayoutManager(footnote.getFootnoteCitation()); citationLM = new InlineLayoutManager(footnote.getFootnoteCitation());
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public List getNextKnuthElements(LayoutContext context, public List getNextKnuthElements(LayoutContext context,
int alignment) { int alignment) {
// for the moment, this LM is set as the citationLM's parent // for the moment, this LM is set as the citationLM's parent
return returnedList; return returnedList;
} }


/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public List getChangedKnuthElements(List oldList, int alignment, int depth) { public List getChangedKnuthElements(List oldList, int alignment, int depth) {
List returnedList = super.getChangedKnuthElements(oldList, alignment, depth); List returnedList = super.getChangedKnuthElements(oldList, alignment, depth);
addAnchor(returnedList); addAnchor(returnedList);
} }




/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void addAreas(PositionIterator posIter, LayoutContext context) { public void addAreas(PositionIterator posIter, LayoutContext context) {
// "Unwrap" the NonLeafPositions stored in posIter and put // "Unwrap" the NonLeafPositions stored in posIter and put
// them in a new list, that will be given to the citationLM // them in a new list, that will be given to the citationLM
LinkedList positionList = new LinkedList();
NonLeafPosition pos = null;
LinkedList<Position> positionList = new LinkedList<Position>();
Position pos;
while (posIter.hasNext()) { while (posIter.hasNext()) {
pos = (NonLeafPosition) posIter.next();
pos = posIter.next();
if (pos != null && pos.getPosition() != null) { if (pos != null && pos.getPosition() != null) {
positionList.add(pos.getPosition()); positionList.add(pos.getPosition());
} }


// make the citationLM add its areas // make the citationLM add its areas
LayoutContext childContext = new LayoutContext(context); LayoutContext childContext = new LayoutContext(context);
StackingIter childPosIter = new StackingIter(positionList.listIterator());
PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
LayoutManager childLM; LayoutManager childLM;
while ((childLM = childPosIter.getNextChildLM()) != null) { while ((childLM = childPosIter.getNextChildLM()) != null) {
childLM.addAreas(childPosIter, childContext); childLM.addAreas(childPosIter, childContext);

+ 27
- 26
src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java Vedi File

private boolean areaCreated = false; private boolean areaCreated = false;
private LayoutManager lastChildLM = null; // Set when return last breakposs; private LayoutManager lastChildLM = null; // Set when return last breakposs;


private Position auxiliaryPosition;

private Font font; private Font font;


/** The alignment adjust property */ /** The alignment adjust property */
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void initialize() { public void initialize() {
InlineLevel fobj = (InlineLevel) this.fobj; InlineLevel fobj = (InlineLevel) this.fobj;


} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
protected MinOptMax getExtraIPD(boolean isNotFirst, boolean isNotLast) { protected MinOptMax getExtraIPD(boolean isNotFirst, boolean isNotLast) {
int borderAndPadding = 0; int borderAndPadding = 0;
if (borderProps != null) { if (borderProps != null) {




/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
protected boolean hasLeadingFence(boolean isNotFirst) { protected boolean hasLeadingFence(boolean isNotFirst) {
return borderProps != null return borderProps != null
&& (borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this) > 0 && (borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this) > 0
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
protected boolean hasTrailingFence(boolean isNotLast) { protected boolean hasTrailingFence(boolean isNotLast) {
return borderProps != null return borderProps != null
&& (borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this) > 0 && (borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this) > 0
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
protected SpaceProperty getSpaceStart() { protected SpaceProperty getSpaceStart() {
return inlineProps != null ? inlineProps.spaceStart : null; return inlineProps != null ? inlineProps.spaceStart : null;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
protected SpaceProperty getSpaceEnd() { protected SpaceProperty getSpaceEnd() {
return inlineProps != null ? inlineProps.spaceEnd : null; return inlineProps != null ? inlineProps.spaceEnd : null;
} }
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
protected void setTraits(boolean isNotFirst, boolean isNotLast) { protected void setTraits(boolean isNotFirst, boolean isNotLast) {
if (borderProps != null) { if (borderProps != null) {
// Add border and padding to current area and set flags (FIRST, LAST ...) // Add border and padding to current area and set flags (FIRST, LAST ...)
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public List getNextKnuthElements // CSOK: MethodLength public List getNextKnuthElements // CSOK: MethodLength
(LayoutContext context, int alignment) { (LayoutContext context, int alignment) {
LayoutManager curLM; LayoutManager curLM;


// the list returned by child LM // the list returned by child LM
List returnedList;
List<KnuthSequence> returnedList;


// the list which will be returned to the parent LM // the list which will be returned to the parent LM
List returnList = new LinkedList();
List<KnuthSequence> returnList = new LinkedList<KnuthSequence>();
KnuthSequence lastSequence = null; KnuthSequence lastSequence = null;


if (fobj instanceof Title) { if (fobj instanceof Title) {
sequence.wrapPositions(this); sequence.wrapPositions(this);
} }
int insertionStartIndex = 0; int insertionStartIndex = 0;
if (lastSequence != null && lastSequence.appendSequenceOrClose
((KnuthSequence) returnedList.get(0))) {
if (lastSequence != null
&& lastSequence.appendSequenceOrClose(returnedList.get(0))) {
insertionStartIndex = 1; insertionStartIndex = 1;
} }
// add border and padding to the first complete sequence of this LM // add border and padding to the first complete sequence of this LM
if (!borderAdded && !returnedList.isEmpty()) { if (!borderAdded && !returnedList.isEmpty()) {
addKnuthElementsForBorderPaddingStart((KnuthSequence) returnedList.get(0));
addKnuthElementsForBorderPaddingStart(returnedList.get(0));
borderAdded = true; borderAdded = true;
} }
for (Iterator iter = returnedList.listIterator(insertionStartIndex);
for (Iterator<KnuthSequence> iter = returnedList.listIterator(insertionStartIndex);
iter.hasNext();) { iter.hasNext();) {
returnList.add(iter.next()); returnList.add(iter.next());
} }
context.updateKeepWithNextPending(childLC.getKeepWithNextPending()); context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
childLC.clearKeepsPending(); childLC.clearKeepsPending();
} }
lastSequence = (KnuthSequence) ListUtil.getLast(returnList);
lastSequence = ListUtil.getLast(returnList);
lastChildLM = curLM; lastChildLM = curLM;
} }


* by this LayoutManager. * by this LayoutManager.
* @param context layout context. * @param context layout context.
*/ */
@Override
public void addAreas(PositionIterator parentIter, public void addAreas(PositionIterator parentIter,
LayoutContext context) { LayoutContext context) {


// set in the layout context, it must be also set in the // set in the layout context, it must be also set in the
// layout context given to lastLM, but must be cleared in the // layout context given to lastLM, but must be cleared in the
// layout context given to the other LMs. // layout context given to the other LMs.
List positionList = new LinkedList();
NonLeafPosition pos;
List<Position> positionList = new LinkedList<Position>();
Position pos;
LayoutManager lastLM = null; // last child LM in this iterator LayoutManager lastLM = null; // last child LM in this iterator
Position lastPos = null; Position lastPos = null;
while (parentIter.hasNext()) { while (parentIter.hasNext()) {
pos = (NonLeafPosition) parentIter.next();
pos = parentIter.next();
if (pos != null && pos.getPosition() != null) { if (pos != null && pos.getPosition() != null) {
positionList.add(pos.getPosition()); positionList.add(pos.getPosition());
lastLM = pos.getPosition().getLM(); lastLM = pos.getPosition().getLM();
lastPos = pos; lastPos = pos;
} }
} }
/*if (pos != null) {
lastLM = pos.getPosition().getLM();
}*/


addMarkersToPage( addMarkersToPage(
true, true,
} }
setCurrentArea(parent); setCurrentArea(parent);


StackingIter childPosIter
= new StackingIter(positionList.listIterator());
PositionIterator childPosIter
= new PositionIterator(positionList.listIterator());


LayoutManager prevLM = null; LayoutManager prevLM = null;
LayoutManager childLM; LayoutManager childLM;
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void addChildArea(Area childArea) { public void addChildArea(Area childArea) {
Area parent = getCurrentArea(); Area parent = getCurrentArea();
if (getContext().resolveLeadingSpace()) { if (getContext().resolveLeadingSpace()) {
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public List getChangedKnuthElements(List oldList, int alignment, int depth) { public List getChangedKnuthElements(List oldList, int alignment, int depth) {
List returnedList = new LinkedList(); List returnedList = new LinkedList();
addKnuthElementsForBorderPaddingStart(returnedList); addKnuthElementsForBorderPaddingStart(returnedList);
*/ */
protected void addKnuthElementsForBorderPaddingStart(List returnList) { protected void addKnuthElementsForBorderPaddingStart(List returnList) {
//Border and Padding (start) //Border and Padding (start)
/**
/*
* If the returnlist is a BlockKnuthSequence, the border and padding should be added * If the returnlist is a BlockKnuthSequence, the border and padding should be added
* to the first paragraph inside it, but it is too late to do that now. * to the first paragraph inside it, but it is too late to do that now.
* At least, avoid adding it to the bpd sequence. * At least, avoid adding it to the bpd sequence.
*/ */
protected void addKnuthElementsForBorderPaddingEnd(List returnList) { protected void addKnuthElementsForBorderPaddingEnd(List returnList) {
//Border and Padding (after) //Border and Padding (after)
/**
/*
* If the returnlist is a BlockKnuthSequence, the border and padding should be added * If the returnlist is a BlockKnuthSequence, the border and padding should be added
* to the last paragraph inside it, but it is too late to do that now. * to the last paragraph inside it, but it is too late to do that now.
* At least, avoid adding it to the bpd sequence. * At least, avoid adding it to the bpd sequence.
} }
} }


/** @return a cached auxiliary Position instance used for things like spaces. */
/** @return an auxiliary {@link Position} instance used for things like spaces. */
protected Position getAuxiliaryPosition() { protected Position getAuxiliaryPosition() {
//if (this.auxiliaryPosition == null) {
//this.auxiliaryPosition = new NonLeafPosition(this, new LeafPosition(this, -1));
this.auxiliaryPosition = new NonLeafPosition(this, null);
//}
return this.auxiliaryPosition;
return new NonLeafPosition(this, null);
} }

} }

+ 1
- 30
src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java Vedi File



package org.apache.fop.layoutmgr.inline; package org.apache.fop.layoutmgr.inline;


import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import org.apache.fop.layoutmgr.AbstractLayoutManager; import org.apache.fop.layoutmgr.AbstractLayoutManager;
import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.NonLeafPosition; import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.Position; import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.traits.MinOptMax; import org.apache.fop.traits.MinOptMax;


/** /**
public abstract class InlineStackingLayoutManager extends AbstractLayoutManager public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
implements InlineLevelLayoutManager { implements InlineLevelLayoutManager {



/**
* A stacking iterator.
*/
protected static class StackingIter extends PositionIterator {

StackingIter(Iterator parentIter) {
super(parentIter);
}

/**
* @param nextObj the next object
* @return layout manager of next object
*/
protected LayoutManager getLM(Object nextObj) {
return ((Position) nextObj).getLM();
}

/**
* @param nextObj the next object
* @return position of next object
*/
protected Position getPos(Object nextObj) {
return ((Position) nextObj);
}
}

/** /**
* Size of border and padding in BPD (ie, before and after). * Size of border and padding in BPD (ie, before and after).
*/ */
} else { } else {
currLM = (InlineLevelLayoutManager) pos.getLM(depth); currLM = (InlineLevelLayoutManager) pos.getLM(depth);
} }

// initialize prevLM // initialize prevLM
if (prevLM == null) { if (prevLM == null) {
prevLM = currLM; prevLM = currLM;

+ 1
- 1
src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Vedi File

lc.setAlignmentContext(alignmentContext); lc.setAlignmentContext(alignmentContext);
setChildContext(lc); setChildContext(lc);


PositionIterator childPosIter = new StackingIter(positionList.listIterator());
PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
LayoutContext blocklc = new LayoutContext(0); LayoutContext blocklc = new LayoutContext(0);
blocklc.setLeadingSpace(new SpaceSpecifier(true)); blocklc.setLeadingSpace(new SpaceSpecifier(true));
blocklc.setTrailingSpace(new SpaceSpecifier(false)); blocklc.setTrailingSpace(new SpaceSpecifier(false));

Loading…
Annulla
Salva