Bläddra i källkod

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 år sedan
förälder
incheckning
58d1c60f10

+ 11
- 10
src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java Visa fil

@@ -34,6 +34,7 @@ import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;

/**
@@ -62,6 +63,7 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager {
}

/** {@inheritDoc} */
@Override
public void initialize() {
// create an InlineStackingLM handling the fo:inline child of fo:footnote
citationLM = new InlineLayoutManager(footnote.getFootnoteCitation());
@@ -71,6 +73,7 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager {
}

/** {@inheritDoc} */
@Override
public List getNextKnuthElements(LayoutContext context,
int alignment) {
// for the moment, this LM is set as the citationLM's parent
@@ -119,9 +122,8 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager {
return returnedList;
}

/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public List getChangedKnuthElements(List oldList, int alignment, int depth) {
List returnedList = super.getChangedKnuthElements(oldList, alignment, depth);
addAnchor(returnedList);
@@ -129,16 +131,15 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager {
}


/**
* {@inheritDoc}
*/
/** {@inheritDoc} */
@Override
public void addAreas(PositionIterator posIter, LayoutContext context) {
// "Unwrap" the NonLeafPositions stored in posIter and put
// 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()) {
pos = (NonLeafPosition) posIter.next();
pos = posIter.next();
if (pos != null && pos.getPosition() != null) {
positionList.add(pos.getPosition());
}
@@ -150,7 +151,7 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager {

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

+ 27
- 26
src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java Visa fil

@@ -77,8 +77,6 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
private boolean areaCreated = false;
private LayoutManager lastChildLM = null; // Set when return last breakposs;

private Position auxiliaryPosition;

private Font font;

/** The alignment adjust property */
@@ -113,6 +111,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}

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

@@ -150,6 +149,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}

/** {@inheritDoc} */
@Override
protected MinOptMax getExtraIPD(boolean isNotFirst, boolean isNotLast) {
int borderAndPadding = 0;
if (borderProps != null) {
@@ -167,6 +167,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {


/** {@inheritDoc} */
@Override
protected boolean hasLeadingFence(boolean isNotFirst) {
return borderProps != null
&& (borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this) > 0
@@ -175,6 +176,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}

/** {@inheritDoc} */
@Override
protected boolean hasTrailingFence(boolean isNotLast) {
return borderProps != null
&& (borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this) > 0
@@ -183,10 +185,12 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}

/** {@inheritDoc} */
@Override
protected SpaceProperty getSpaceStart() {
return inlineProps != null ? inlineProps.spaceStart : null;
}
/** {@inheritDoc} */
@Override
protected SpaceProperty getSpaceEnd() {
return inlineProps != null ? inlineProps.spaceEnd : null;
}
@@ -212,6 +216,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}

/** {@inheritDoc} */
@Override
protected void setTraits(boolean isNotFirst, boolean isNotLast) {
if (borderProps != null) {
// Add border and padding to current area and set flags (FIRST, LAST ...)
@@ -239,15 +244,16 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}

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

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

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

if (fobj instanceof Title) {
@@ -328,16 +334,16 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
sequence.wrapPositions(this);
}
int insertionStartIndex = 0;
if (lastSequence != null && lastSequence.appendSequenceOrClose
((KnuthSequence) returnedList.get(0))) {
if (lastSequence != null
&& lastSequence.appendSequenceOrClose(returnedList.get(0))) {
insertionStartIndex = 1;
}
// add border and padding to the first complete sequence of this LM
if (!borderAdded && !returnedList.isEmpty()) {
addKnuthElementsForBorderPaddingStart((KnuthSequence) returnedList.get(0));
addKnuthElementsForBorderPaddingStart(returnedList.get(0));
borderAdded = true;
}
for (Iterator iter = returnedList.listIterator(insertionStartIndex);
for (Iterator<KnuthSequence> iter = returnedList.listIterator(insertionStartIndex);
iter.hasNext();) {
returnList.add(iter.next());
}
@@ -368,7 +374,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
childLC.clearKeepsPending();
}
lastSequence = (KnuthSequence) ListUtil.getLast(returnList);
lastSequence = ListUtil.getLast(returnList);
lastChildLM = curLM;
}

@@ -408,6 +414,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
* by this LayoutManager.
* @param context layout context.
*/
@Override
public void addAreas(PositionIterator parentIter,
LayoutContext context) {

@@ -433,21 +440,18 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
// 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 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
Position lastPos = null;
while (parentIter.hasNext()) {
pos = (NonLeafPosition) parentIter.next();
pos = parentIter.next();
if (pos != null && pos.getPosition() != null) {
positionList.add(pos.getPosition());
lastLM = pos.getPosition().getLM();
lastPos = pos;
}
}
/*if (pos != null) {
lastLM = pos.getPosition().getLM();
}*/

addMarkersToPage(
true,
@@ -469,8 +473,8 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}
setCurrentArea(parent);

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

LayoutManager prevLM = null;
LayoutManager childLM;
@@ -522,6 +526,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}

/** {@inheritDoc} */
@Override
public void addChildArea(Area childArea) {
Area parent = getCurrentArea();
if (getContext().resolveLeadingSpace()) {
@@ -532,6 +537,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}

/** {@inheritDoc} */
@Override
public List getChangedKnuthElements(List oldList, int alignment, int depth) {
List returnedList = new LinkedList();
addKnuthElementsForBorderPaddingStart(returnedList);
@@ -546,7 +552,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
*/
protected void addKnuthElementsForBorderPaddingStart(List returnList) {
//Border and Padding (start)
/**
/*
* 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.
* At least, avoid adding it to the bpd sequence.
@@ -571,7 +577,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
*/
protected void addKnuthElementsForBorderPaddingEnd(List returnList) {
//Border and Padding (after)
/**
/*
* 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.
* At least, avoid adding it to the bpd sequence.
@@ -590,13 +596,8 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}
}

/** @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() {
//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 Visa fil

@@ -19,7 +19,6 @@

package org.apache.fop.layoutmgr.inline;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
@@ -31,10 +30,8 @@ import org.apache.fop.fo.properties.SpaceProperty;
import org.apache.fop.layoutmgr.AbstractLayoutManager;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.traits.MinOptMax;

/**
@@ -45,33 +42,6 @@ import org.apache.fop.traits.MinOptMax;
public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
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).
*/
@@ -296,6 +266,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
} else {
currLM = (InlineLevelLayoutManager) pos.getLM(depth);
}

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

+ 1
- 1
src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Visa fil

@@ -1562,7 +1562,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
lc.setAlignmentContext(alignmentContext);
setChildContext(lc);

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

Laddar…
Avbryt
Spara