git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@665699 13f79535-47bb-0310-9956-ffa450edef68pull/37/head
/** Cell layout manager. */ | /** Cell layout manager. */ | ||||
private TableCellLayoutManager cellLM; | private TableCellLayoutManager cellLM; | ||||
/** List of Knuth elements representing the contents of the cell. */ | /** List of Knuth elements representing the contents of the cell. */ | ||||
private LinkedList elements; | |||||
private List elements; | |||||
/** Index of the row where this cell starts. */ | /** Index of the row where this cell starts. */ | ||||
private int rowIndex; | private int rowIndex; | ||||
* | * | ||||
* @param elements a list of ListElement (?) | * @param elements a list of ListElement (?) | ||||
*/ | */ | ||||
public void setElements(LinkedList elements) { | |||||
public void setElements(List elements) { | |||||
this.elements = elements; | this.elements = elements; | ||||
} | } | ||||
public LinkedList getElements() { | |||||
public List getElements() { | |||||
return this.elements; | return this.elements; | ||||
} | } | ||||
* getNextKnuthElements() implementation(s) that are to be called. | * getNextKnuthElements() implementation(s) that are to be called. | ||||
* @return LinkedList of Knuth elements. | * @return LinkedList of Knuth elements. | ||||
*/ | */ | ||||
protected abstract LinkedList getNextKnuthElements(LayoutContext context, int alignment); | |||||
protected abstract List getNextKnuthElements(LayoutContext context, int alignment); | |||||
/** @return true if there's no content that could be handled. */ | /** @return true if there's no content that could be handled. */ | ||||
public boolean isEmpty() { | public boolean isEmpty() { | ||||
childLC.signalSpanChange(Constants.NOT_SET); | childLC.signalSpanChange(Constants.NOT_SET); | ||||
BlockSequence blockList; | BlockSequence blockList; | ||||
LinkedList returnedList = getNextKnuthElements(childLC, alignment); | |||||
List returnedList = getNextKnuthElements(childLC, alignment); | |||||
if (returnedList != null) { | if (returnedList != null) { | ||||
if (returnedList.size() == 0) { | if (returnedList.size() == 0) { | ||||
nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn); | nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn); | ||||
nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn); | nextSequenceStartsOn = handleSpanChange(childLC, nextSequenceStartsOn); | ||||
Position breakPosition = null; | Position breakPosition = null; | ||||
if (((KnuthElement) returnedList.getLast()).isForcedBreak()) { | |||||
KnuthPenalty breakPenalty = (KnuthPenalty)returnedList.removeLast(); | |||||
if (((KnuthElement) returnedList.get(returnedList.size() - 1)) | |||||
.isForcedBreak()) { | |||||
KnuthPenalty breakPenalty = (KnuthPenalty) returnedList | |||||
.remove(returnedList.size() - 1); | |||||
breakPosition = breakPenalty.getPosition(); | breakPosition = breakPenalty.getPosition(); | ||||
switch (breakPenalty.getBreakClass()) { | switch (breakPenalty.getBreakClass()) { | ||||
case Constants.EN_PAGE: | case Constants.EN_PAGE: |
package org.apache.fop.layoutmgr; | package org.apache.fop.layoutmgr; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.LinkedList; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.ListIterator; | import java.util.ListIterator; | ||||
import java.util.Map; | import java.util.Map; | ||||
import org.apache.commons.logging.Log; | import org.apache.commons.logging.Log; | ||||
import org.apache.commons.logging.LogFactory; | import org.apache.commons.logging.LogFactory; | ||||
import org.apache.fop.area.Area; | import org.apache.fop.area.Area; | ||||
import org.apache.fop.area.PageViewport; | import org.apache.fop.area.PageViewport; | ||||
import org.apache.fop.fo.Constants; | import org.apache.fop.fo.Constants; | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, | |||||
public List getNextKnuthElements(LayoutContext context, | |||||
int alignment) { | int alignment) { | ||||
log.warn("null implementation of getNextKnuthElements() called!"); | log.warn("null implementation of getNextKnuthElements() called!"); | ||||
setFinished(true); | setFinished(true); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getChangedKnuthElements(List oldList, | |||||
public List getChangedKnuthElements(List oldList, | |||||
int alignment) { | int alignment) { | ||||
log.warn("null implementation of getChangeKnuthElement() called!"); | log.warn("null implementation of getChangeKnuthElement() called!"); | ||||
return null; | return null; |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
resetSpaces(); | resetSpaces(); | ||||
if (isAbsoluteOrFixed()) { | if (isAbsoluteOrFixed()) { | ||||
return getNextKnuthElementsAbsolute(context, alignment); | return getNextKnuthElementsAbsolute(context, alignment); | ||||
MinOptMax stackLimit = new MinOptMax(relDims.bpd); | MinOptMax stackLimit = new MinOptMax(relDims.bpd); | ||||
LinkedList returnedList; | |||||
LinkedList contentList = new LinkedList(); | |||||
LinkedList returnList = new LinkedList(); | |||||
List returnedList; | |||||
List contentList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
if (!breakBeforeServed) { | if (!breakBeforeServed) { | ||||
try { | try { | ||||
childLC.clearKeepWithPreviousPending(); | childLC.clearKeepWithPreviousPending(); | ||||
} | } | ||||
if (returnedList.size() == 1 | if (returnedList.size() == 1 | ||||
&& ((ListElement)returnedList.getFirst()).isForcedBreak()) { | |||||
&& ((ListElement)returnedList.get(0)).isForcedBreak()) { | |||||
// a descendant of this block has break-before | // a descendant of this block has break-before | ||||
/* | /* | ||||
if (returnList.size() == 0) { | if (returnList.size() == 0) { | ||||
//Avoid NoSuchElementException below (happens with empty blocks) | //Avoid NoSuchElementException below (happens with empty blocks) | ||||
continue; | continue; | ||||
} | } | ||||
if (((ListElement)returnedList.getLast()).isForcedBreak()) { | |||||
if (((ListElement) returnedList | |||||
.get(returnedList.size() - 1)).isForcedBreak()) { | |||||
// a descendant of this block has break-after | // a descendant of this block has break-after | ||||
if (curLM.isFinished()) { | if (curLM.isFinished()) { | ||||
// there is no other content in this block; | // there is no other content in this block; | ||||
return returnList; | return returnList; | ||||
} | } | ||||
private LinkedList getNextKnuthElementsAbsolute(LayoutContext context, int alignment) { | |||||
private List getNextKnuthElementsAbsolute(LayoutContext context, int alignment) { | |||||
autoHeight = false; | autoHeight = false; | ||||
boolean switchedProgressionDirection | boolean switchedProgressionDirection | ||||
} | } | ||||
updateRelDims(0, 0, false); | updateRelDims(0, 0, false); | ||||
} | } | ||||
LinkedList returnList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
if (!breaker.isEmpty()) { | if (!breaker.isEmpty()) { | ||||
Position bcPosition = new BlockContainerPosition(this, breaker); | Position bcPosition = new BlockContainerPosition(this, breaker); | ||||
returnList.add(new KnuthBox(0, notifyPos(bcPosition), false)); | returnList.add(new KnuthBox(0, notifyPos(bcPosition), false)); | ||||
return lc; | return lc; | ||||
} | } | ||||
protected LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
protected List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
LayoutManager curLM; // currently active LM | LayoutManager curLM; // currently active LM | ||||
LinkedList returnList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
while ((curLM = getChildLM()) != null) { | while ((curLM = getChildLM()) != null) { | ||||
LayoutContext childLC = new LayoutContext(0); | LayoutContext childLC = new LayoutContext(0); | ||||
childLC.setRefIPD(context.getRefIPD()); | childLC.setRefIPD(context.getRefIPD()); | ||||
childLC.setWritingMode(getBlockContainerFO().getWritingMode()); | childLC.setWritingMode(getBlockContainerFO().getWritingMode()); | ||||
LinkedList returnedList = null; | |||||
List returnedList = null; | |||||
if (!curLM.isFinished()) { | if (!curLM.isFinished()) { | ||||
returnedList = curLM.getNextKnuthElements(childLC, alignment); | returnedList = curLM.getNextKnuthElements(childLC, alignment); | ||||
} | } | ||||
// "unwrap" the NonLeafPositions stored in parentIter | // "unwrap" the NonLeafPositions stored in parentIter | ||||
// and put them in a new list; | // and put them in a new list; | ||||
LinkedList positionList = new LinkedList(); | |||||
List positionList = new LinkedList(); | |||||
Position pos; | Position pos; | ||||
boolean bSpaceBefore = false; | boolean bSpaceBefore = false; | ||||
boolean bSpaceAfter = false; | boolean bSpaceAfter = false; | ||||
// // the last item inside positionList is a Position; | // // the last item inside positionList is a Position; | ||||
// // this means that the paragraph has been split | // // this means that the paragraph has been split | ||||
// // between consecutive pages | // // between consecutive pages | ||||
LinkedList splitList = new LinkedList(); | |||||
List splitList = new LinkedList(); | |||||
int splitLength = 0; | int splitLength = 0; | ||||
int iFirst = ((MappingPosition) positionList.getFirst()).getFirstIndex(); | |||||
int iLast = ((MappingPosition) positionList.getLast()).getLastIndex(); | |||||
int iFirst = ((MappingPosition) positionList.get(0)).getFirstIndex(); | |||||
int iLast = ((MappingPosition) positionList.get(positionList | |||||
.size() - 1)).getLastIndex(); | |||||
// copy from storedList to splitList all the elements from | // copy from storedList to splitList all the elements from | ||||
// iFirst to iLast | // iFirst to iLast | ||||
ListIterator storedListIterator = storedList.listIterator(iFirst); | ListIterator storedListIterator = storedList.listIterator(iFirst); |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
resetSpaces(); | resetSpaces(); | ||||
return super.getNextKnuthElements(context, alignment); | return super.getNextKnuthElements(context, alignment); | ||||
} | } |
/** space-after value adjusted for block-progression-unit handling */ | /** space-after value adjusted for block-progression-unit handling */ | ||||
protected int adjustedSpaceAfter = 0; | protected int adjustedSpaceAfter = 0; | ||||
/** Only used to store the original list when createUnitElements is called */ | /** Only used to store the original list when createUnitElements is called */ | ||||
protected LinkedList storedList = null; | |||||
protected List storedList = null; | |||||
/** Indicates whether break before has been served or not */ | /** Indicates whether break before has been served or not */ | ||||
protected boolean breakBeforeServed = false; | protected boolean breakBeforeServed = false; | ||||
/** Indicates whether the first visible mark has been returned by this LM, yet */ | /** Indicates whether the first visible mark has been returned by this LM, yet */ | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
//log.debug("BLM.getNextKnuthElements> keep-together = " | //log.debug("BLM.getNextKnuthElements> keep-together = " | ||||
// + layoutProps.keepTogether.getType()); | // + layoutProps.keepTogether.getType()); | ||||
//log.debug(" keep-with-previous = " + | //log.debug(" keep-with-previous = " + | ||||
updateContentAreaIPDwithOverconstrainedAdjust(); | updateContentAreaIPDwithOverconstrainedAdjust(); | ||||
LinkedList returnedList = null; | |||||
LinkedList contentList = new LinkedList(); | |||||
LinkedList returnList = new LinkedList(); | |||||
List returnedList = null; | |||||
List contentList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
if (!breakBeforeServed) { | if (!breakBeforeServed) { | ||||
try { | try { | ||||
} | } | ||||
if (returnedList != null | if (returnedList != null | ||||
&& returnedList.size() == 1 | && returnedList.size() == 1 | ||||
&& ((ListElement) returnedList.getFirst()).isForcedBreak()) { | |||||
&& ((ListElement) returnedList.get(0)).isForcedBreak()) { | |||||
if (curLM.isFinished() && !hasNextChildLM()) { | if (curLM.isFinished() && !hasNextChildLM()) { | ||||
// a descendant of this block has break-before | // a descendant of this block has break-before | ||||
forcedBreakAfterLast = (BreakElement) returnedList.getFirst(); | |||||
forcedBreakAfterLast = (BreakElement) returnedList.get(0); | |||||
context.clearPendingMarks(); | context.clearPendingMarks(); | ||||
break; | break; | ||||
} | } | ||||
continue; | continue; | ||||
} | } | ||||
contentList.addAll(returnedList); | contentList.addAll(returnedList); | ||||
if (((ListElement) returnedList.getLast()).isForcedBreak()) { | |||||
if (((ListElement) returnedList.get(returnedList.size() - 1)) | |||||
.isForcedBreak()) { | |||||
// a descendant of this block has break-after | // a descendant of this block has break-after | ||||
if (curLM.isFinished() && !hasNextChildLM()) { | if (curLM.isFinished() && !hasNextChildLM()) { | ||||
forcedBreakAfterLast = (BreakElement)contentList.removeLast(); | |||||
forcedBreakAfterLast = (BreakElement) contentList | |||||
.remove(contentList.size() - 1); | |||||
context.clearPendingMarks(); | context.clearPendingMarks(); | ||||
break; | break; | ||||
} | } | ||||
* @param context the current layout context | * @param context the current layout context | ||||
* @param childLC the currently active child layout context | * @param childLC the currently active child layout context | ||||
*/ | */ | ||||
protected void addInBetweenBreak(LinkedList contentList, LayoutContext context, | |||||
protected void addInBetweenBreak(List contentList, LayoutContext context, | |||||
LayoutContext childLC) { | LayoutContext childLC) { | ||||
if (mustKeepTogether() | if (mustKeepTogether() | ||||
|| context.isKeepWithNextPending() | || context.isKeepWithNextPending() | ||||
return; | return; | ||||
} | } | ||||
ListElement last = (ListElement)contentList.getLast(); | |||||
ListElement last = (ListElement) contentList | |||||
.get(contentList.size() - 1); | |||||
if (last.isGlue()) { | if (last.isGlue()) { | ||||
// the last element in contentList is a glue; | // the last element in contentList is a glue; | ||||
// it is a feasible breakpoint, there is no need to add | // it is a feasible breakpoint, there is no need to add | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public LinkedList getChangedKnuthElements(List oldList, int alignment) { | |||||
public List getChangedKnuthElements(List oldList, int alignment) { | |||||
/*LF*/ //log.debug(""); | /*LF*/ //log.debug(""); | ||||
/*LF*/ //log.debug(" BLM.getChangedKnuthElements> inizio: oldList.size() = " | /*LF*/ //log.debug(" BLM.getChangedKnuthElements> inizio: oldList.size() = " | ||||
// + oldList.size()); | // + oldList.size()); | ||||
KnuthElement returnedElement; | KnuthElement returnedElement; | ||||
KnuthElement currElement = null; | KnuthElement currElement = null; | ||||
KnuthElement prevElement = null; | KnuthElement prevElement = null; | ||||
LinkedList returnedList = new LinkedList(); | |||||
LinkedList returnList = new LinkedList(); | |||||
List returnedList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
int fromIndex = 0; | int fromIndex = 0; | ||||
// "unwrap" the Positions stored in the elements | // "unwrap" the Positions stored in the elements | ||||
// add an infinite penalty to forbid a break between blocks | // add an infinite penalty to forbid a break between blocks | ||||
returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, | returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, | ||||
new Position(this), false)); | new Position(this), false)); | ||||
} else if (bSomethingAdded && !((KnuthElement) returnedList.getLast()).isGlue()) { | |||||
} else if (bSomethingAdded | |||||
&& !((KnuthElement) returnedList.get(returnedList | |||||
.size() - 1)).isGlue()) { | |||||
// add a null penalty to allow a break between blocks | // add a null penalty to allow a break between blocks | ||||
returnedList.add(new KnuthPenalty(0, 0, false, new Position(this), false)); | returnedList.add(new KnuthPenalty(0, 0, false, new Position(this), false)); | ||||
} | } | ||||
// there are no more elements to add | // there are no more elements to add | ||||
// remove the last penalty added to returnedList | // remove the last penalty added to returnedList | ||||
if (returnedList.size() > 0) { | if (returnedList.size() > 0) { | ||||
returnedList.removeLast(); | |||||
returnedList.remove(returnedList.size() - 1); | |||||
} | } | ||||
//log.debug(" BLM.getChangedKnuthElements> elementi propri, ignorati, da " | //log.debug(" BLM.getChangedKnuthElements> elementi propri, ignorati, da " | ||||
// + fromIndex + " a " + workList.size()); | // + fromIndex + " a " + workList.size()); | ||||
* @param isFirst true if this is the first time a layout manager instance needs to generate | * @param isFirst true if this is the first time a layout manager instance needs to generate | ||||
* border and padding | * border and padding | ||||
*/ | */ | ||||
protected void addKnuthElementsForBorderPaddingBefore(LinkedList returnList, boolean isFirst) { | |||||
protected void addKnuthElementsForBorderPaddingBefore(List returnList, boolean isFirst) { | |||||
//Border and Padding (before) | //Border and Padding (before) | ||||
CommonBorderPaddingBackground borderAndPadding = getBorderPaddingBackground(); | CommonBorderPaddingBackground borderAndPadding = getBorderPaddingBackground(); | ||||
if (borderAndPadding != null) { | if (borderAndPadding != null) { | ||||
* @param isLast true if this is the last time a layout manager instance needs to generate | * @param isLast true if this is the last time a layout manager instance needs to generate | ||||
* border and padding | * border and padding | ||||
*/ | */ | ||||
protected void addKnuthElementsForBorderPaddingAfter(LinkedList returnList, boolean isLast) { | |||||
protected void addKnuthElementsForBorderPaddingAfter(List returnList, boolean isLast) { | |||||
//Border and Padding (after) | //Border and Padding (after) | ||||
CommonBorderPaddingBackground borderAndPadding = getBorderPaddingBackground(); | CommonBorderPaddingBackground borderAndPadding = getBorderPaddingBackground(); | ||||
if (borderAndPadding != null) { | if (borderAndPadding != null) { | ||||
* @param context the layout context | * @param context the layout context | ||||
* @return true if an element has been added due to a break-before. | * @return true if an element has been added due to a break-before. | ||||
*/ | */ | ||||
protected boolean addKnuthElementsForBreakBefore(LinkedList returnList, | |||||
protected boolean addKnuthElementsForBreakBefore(List returnList, | |||||
LayoutContext context) { | LayoutContext context) { | ||||
int breakBefore = -1; | int breakBefore = -1; | ||||
if (fobj instanceof org.apache.fop.fo.flow.Block) { | if (fobj instanceof org.apache.fop.fo.flow.Block) { | ||||
* @param context the layout context | * @param context the layout context | ||||
* @return true if an element has been added due to a break-after. | * @return true if an element has been added due to a break-after. | ||||
*/ | */ | ||||
protected boolean addKnuthElementsForBreakAfter(LinkedList returnList, | |||||
protected boolean addKnuthElementsForBreakAfter(List returnList, | |||||
LayoutContext context) { | LayoutContext context) { | ||||
int breakAfter = -1; | int breakAfter = -1; | ||||
if (fobj instanceof org.apache.fop.fo.flow.Block) { | if (fobj instanceof org.apache.fop.fo.flow.Block) { | ||||
* @param returnList return list to add the additional elements to | * @param returnList return list to add the additional elements to | ||||
* @param alignment vertical alignment | * @param alignment vertical alignment | ||||
*/ | */ | ||||
protected void addKnuthElementsForSpaceBefore(LinkedList returnList/*, | |||||
protected void addKnuthElementsForSpaceBefore(List returnList/*, | |||||
Position returnPosition*/, int alignment) { | Position returnPosition*/, int alignment) { | ||||
SpaceProperty spaceBefore = getSpaceBeforeProperty(); | SpaceProperty spaceBefore = getSpaceBeforeProperty(); | ||||
// append elements representing space-before | // append elements representing space-before | ||||
* @param returnList return list to add the additional elements to | * @param returnList return list to add the additional elements to | ||||
* @param alignment vertical alignment | * @param alignment vertical alignment | ||||
*/ | */ | ||||
protected void addKnuthElementsForSpaceAfter(LinkedList returnList/*, Position returnPosition*/, | |||||
protected void addKnuthElementsForSpaceAfter(List returnList/*, Position returnPosition*/, | |||||
int alignment) { | int alignment) { | ||||
SpaceProperty spaceAfter = getSpaceAfterProperty(); | SpaceProperty spaceAfter = getSpaceAfterProperty(); | ||||
// append elements representing space-after | // append elements representing space-after | ||||
}*/ | }*/ | ||||
} | } | ||||
protected LinkedList createUnitElements(LinkedList oldList) { | |||||
protected List createUnitElements(List oldList) { | |||||
//log.debug("Start conversion: " + oldList.size() | //log.debug("Start conversion: " + oldList.size() | ||||
// + " elements, space-before.min=" + layoutProps.spaceBefore.getSpace().min | // + " elements, space-before.min=" + layoutProps.spaceBefore.getSpace().min | ||||
// + " space-after.min=" + layoutProps.spaceAfter.getSpace().min); | // + " space-after.min=" + layoutProps.spaceAfter.getSpace().min); | ||||
// add elements at the beginning and at the end of oldList | // add elements at the beginning and at the end of oldList | ||||
// representing minimum spaces | // representing minimum spaces | ||||
LayoutManager lm = ((KnuthElement)oldList.getFirst()).getLayoutManager(); | |||||
LayoutManager lm = ((KnuthElement)oldList.get(0)).getLayoutManager(); | |||||
boolean bAddedBoxBefore = false; | boolean bAddedBoxBefore = false; | ||||
boolean bAddedBoxAfter = false; | boolean bAddedBoxAfter = false; | ||||
if (adjustedSpaceBefore > 0) { | if (adjustedSpaceBefore > 0) { | ||||
oldList.addFirst(new KnuthBox(adjustedSpaceBefore, | |||||
oldList.add(0, new KnuthBox(adjustedSpaceBefore, | |||||
new Position(lm), true)); | new Position(lm), true)); | ||||
bAddedBoxBefore = true; | bAddedBoxBefore = true; | ||||
} | } | ||||
if (adjustedSpaceAfter > 0) { | if (adjustedSpaceAfter > 0) { | ||||
oldList.addLast(new KnuthBox(adjustedSpaceAfter, | |||||
oldList.add(new KnuthBox(adjustedSpaceAfter, | |||||
new Position(lm), true)); | new Position(lm), true)); | ||||
bAddedBoxAfter = true; | bAddedBoxAfter = true; | ||||
} | } | ||||
// remove elements at the beginning and at the end of oldList | // remove elements at the beginning and at the end of oldList | ||||
// representing minimum spaces | // representing minimum spaces | ||||
if (adjustedSpaceBefore > 0) { | if (adjustedSpaceBefore > 0) { | ||||
oldList.removeFirst(); | |||||
oldList.remove(0); | |||||
} | } | ||||
if (adjustedSpaceAfter > 0) { | if (adjustedSpaceAfter > 0) { | ||||
oldList.removeLast(); | |||||
oldList.remove(oldList.size() - 1); | |||||
} | } | ||||
// if space-before.conditionality is "discard", correct newList | // if space-before.conditionality is "discard", correct newList |
* @param constraint min/opt/max value to restrict the range in which the breaks are removed. | * @param constraint min/opt/max value to restrict the range in which the breaks are removed. | ||||
* @return true if the opt constraint is bigger than the list contents | * @return true if the opt constraint is bigger than the list contents | ||||
*/ | */ | ||||
public static boolean removeLegalBreaks(LinkedList elements, MinOptMax constraint) { | |||||
public static boolean removeLegalBreaks(List elements, MinOptMax constraint) { | |||||
return removeLegalBreaks(elements, constraint.opt); | return removeLegalBreaks(elements, constraint.opt); | ||||
} | } | ||||
* @param constraint value to restrict the range in which the breaks are removed. | * @param constraint value to restrict the range in which the breaks are removed. | ||||
* @return true if the constraint is bigger than the list contents | * @return true if the constraint is bigger than the list contents | ||||
*/ | */ | ||||
public static boolean removeLegalBreaks(LinkedList elements, int constraint) { | |||||
public static boolean removeLegalBreaks(List elements, int constraint) { | |||||
int len = 0; | int len = 0; | ||||
ListIterator iter = elements.listIterator(); | ListIterator iter = elements.listIterator(); | ||||
while (iter.hasNext()) { | while (iter.hasNext()) { | ||||
* @param constraint value to restrict the range in which the breaks are removed. | * @param constraint value to restrict the range in which the breaks are removed. | ||||
* @return true if the constraint is bigger than the list contents | * @return true if the constraint is bigger than the list contents | ||||
*/ | */ | ||||
public static boolean removeLegalBreaksFromEnd(LinkedList elements, int constraint) { | |||||
public static boolean removeLegalBreaksFromEnd(List elements, int constraint) { | |||||
int len = 0; | int len = 0; | ||||
ListIterator i = elements.listIterator(elements.size()); | ListIterator i = elements.listIterator(elements.size()); | ||||
while (i.hasPrevious()) { | while (i.hasPrevious()) { | ||||
* @param elems the element list | * @param elems the element list | ||||
* @return true if the list ends with a forced break | * @return true if the list ends with a forced break | ||||
*/ | */ | ||||
public static boolean endsWithForcedBreak(LinkedList elems) { | |||||
ListElement last = (ListElement)elems.getLast(); | |||||
public static boolean endsWithForcedBreak(List elems) { | |||||
ListElement last = (ListElement) elems.get(elems.size() - 1); | |||||
return last.isForcedBreak(); | return last.isForcedBreak(); | ||||
} | } | ||||
* @param elems the element list | * @param elems the element list | ||||
* @return true if the list ends with a non-infinite penalty | * @return true if the list ends with a non-infinite penalty | ||||
*/ | */ | ||||
public static boolean endsWithNonInfinitePenalty(LinkedList elems) { | |||||
ListElement last = (ListElement)elems.getLast(); | |||||
public static boolean endsWithNonInfinitePenalty(List elems) { | |||||
ListElement last = (ListElement) elems.get(elems.size() - 1); | |||||
if (last.isPenalty() && ((KnuthPenalty)last).getP() < KnuthElement.INFINITE) { | if (last.isPenalty() && ((KnuthPenalty)last).getP() < KnuthElement.INFINITE) { | ||||
return true; | return true; | ||||
} else if (last instanceof BreakElement | } else if (last instanceof BreakElement |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
// set layout dimensions | // set layout dimensions | ||||
int flowIPD = getCurrentPV().getCurrentSpan().getColumnWidth(); | int flowIPD = getCurrentPV().getCurrentSpan().getColumnWidth(); | ||||
// currently active LM | // currently active LM | ||||
LayoutManager curLM; | LayoutManager curLM; | ||||
LinkedList returnedList; | |||||
LinkedList returnList = new LinkedList(); | |||||
List returnedList; | |||||
List returnList = new LinkedList(); | |||||
while ((curLM = getChildLM()) != null) { | while ((curLM = getChildLM()) != null) { | ||||
if (!(curLM instanceof WrapperLayoutManager) | if (!(curLM instanceof WrapperLayoutManager) | ||||
} | } | ||||
// "wrap" the Position inside each element | // "wrap" the Position inside each element | ||||
LinkedList tempList = returnedList; | |||||
List tempList = returnedList; | |||||
returnedList = new LinkedList(); | returnedList = new LinkedList(); | ||||
wrapPositionElements(tempList, returnedList); | wrapPositionElements(tempList, returnedList); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getChangedKnuthElements(List oldList, /*int flaggedPenalty,*/ int alignment) { | |||||
public List getChangedKnuthElements(List oldList, /*int flaggedPenalty,*/ int alignment) { | |||||
ListIterator oldListIterator = oldList.listIterator(); | ListIterator oldListIterator = oldList.listIterator(); | ||||
KnuthElement returnedElement; | KnuthElement returnedElement; | ||||
LinkedList returnedList = new LinkedList(); | |||||
LinkedList returnList = new LinkedList(); | |||||
List returnedList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
KnuthElement prevElement = null; | KnuthElement prevElement = null; | ||||
KnuthElement currElement = null; | KnuthElement currElement = null; | ||||
int fromIndex = 0; | int fromIndex = 0; | ||||
// add an infinite penalty to forbid a break between blocks | // add an infinite penalty to forbid a break between blocks | ||||
returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, | returnedList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, | ||||
new Position(this), false)); | new Position(this), false)); | ||||
} else if (!((KnuthElement) returnedList.getLast()).isGlue()) { | |||||
} else if (!((KnuthElement) returnedList.get(returnedList | |||||
.size() - 1)).isGlue()) { | |||||
// add a null penalty to allow a break between blocks | // add a null penalty to allow a break between blocks | ||||
returnedList.add(new KnuthPenalty(0, 0, false, new Position(this), false)); | returnedList.add(new KnuthPenalty(0, 0, false, new Position(this), false)); | ||||
} | } |
package org.apache.fop.layoutmgr; | package org.apache.fop.layoutmgr; | ||||
import org.apache.fop.traits.MinOptMax; | |||||
import java.util.LinkedList; | import java.util.LinkedList; | ||||
import java.util.List; | |||||
import org.apache.fop.traits.MinOptMax; | |||||
/** | /** | ||||
* Knuth box used to represent a line in block-progression-dimension (i.e. the width is its height). | * Knuth box used to represent a line in block-progression-dimension (i.e. the width is its height). | ||||
* it isn't possible to get the opt value stored in a MinOptMax object. | * it isn't possible to get the opt value stored in a MinOptMax object. | ||||
*/ | */ | ||||
private int bpd; | private int bpd; | ||||
private LinkedList footnoteList; | |||||
private List footnoteList; | |||||
/** List of Knuth elements. This is a list of LinkedList elements. */ | /** List of Knuth elements. This is a list of LinkedList elements. */ | ||||
private LinkedList elementLists = null; | |||||
private List elementLists = null; | |||||
/** | /** | ||||
* Creates a new box. | * Creates a new box. | ||||
* @param pos the Position stored in this box | * @param pos the Position stored in this box | ||||
* @param bAux is this box auxiliary? | * @param bAux is this box auxiliary? | ||||
*/ | */ | ||||
public KnuthBlockBox(int w, LinkedList list, Position pos, boolean bAux) { | |||||
public KnuthBlockBox(int w, List list, Position pos, boolean bAux) { | |||||
super(w, pos, bAux); | super(w, pos, bAux); | ||||
ipdRange = new MinOptMax(0); | ipdRange = new MinOptMax(0); | ||||
bpd = 0; | bpd = 0; | ||||
/** | /** | ||||
* @return the LMs for the footnotes cited in this box. | * @return the LMs for the footnotes cited in this box. | ||||
*/ | */ | ||||
public LinkedList getFootnoteBodyLMs() { | |||||
public List getFootnoteBodyLMs() { | |||||
return footnoteList; | return footnoteList; | ||||
} | } | ||||
* Adds the given list of Knuth elements to this box' list of elements. | * Adds the given list of Knuth elements to this box' list of elements. | ||||
* @param list elements corresponding to a footnote body | * @param list elements corresponding to a footnote body | ||||
*/ | */ | ||||
public void addElementList(LinkedList list) { | |||||
public void addElementList(List list) { | |||||
if (elementLists == null) { | if (elementLists == null) { | ||||
elementLists = new LinkedList(); | elementLists = new LinkedList(); | ||||
} | } | ||||
* @return a list of KnuthElement sequences corresponding to footnotes cited in this | * @return a list of KnuthElement sequences corresponding to footnotes cited in this | ||||
* box | * box | ||||
*/ | */ | ||||
public LinkedList getElementLists() { | |||||
public List getElementLists() { | |||||
return elementLists; | return elementLists; | ||||
} | } | ||||
package org.apache.fop.layoutmgr; | package org.apache.fop.layoutmgr; | ||||
import java.util.LinkedList; | |||||
import java.util.List; | import java.util.List; | ||||
import org.apache.fop.area.Area; | import org.apache.fop.area.Area; | ||||
* @param alignment the desired text alignement | * @param alignment the desired text alignement | ||||
* @return the list of KnuthElements | * @return the list of KnuthElements | ||||
*/ | */ | ||||
LinkedList getNextKnuthElements(LayoutContext context, int alignment); | |||||
List getNextKnuthElements(LayoutContext context, int alignment); | |||||
/** | /** | ||||
* Get a sequence of KnuthElements representing the content | * Get a sequence of KnuthElements representing the content | ||||
* @param alignment the desired text alignment | * @param alignment the desired text alignment | ||||
* @return the updated list of KnuthElements | * @return the updated list of KnuthElements | ||||
*/ | */ | ||||
LinkedList getChangedKnuthElements(List oldList, int alignment); | |||||
List getChangedKnuthElements(List oldList, int alignment); | |||||
/** | /** | ||||
* Returns the IPD of the content area | * Returns the IPD of the content area |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
protected LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
LinkedList contentList = null; | |||||
protected List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
List contentList = null; | |||||
while (!childFLM.isFinished() && contentList == null) { | while (!childFLM.isFinished() && contentList == null) { | ||||
contentList = childFLM.getNextKnuthElements(context, alignment); | contentList = childFLM.getNextKnuthElements(context, alignment); | ||||
footnoteContext.setStackLimitBP(context.getStackLimitBP()); | footnoteContext.setStackLimitBP(context.getStackLimitBP()); | ||||
footnoteContext.setRefIPD(pslm.getCurrentPV() | footnoteContext.setRefIPD(pslm.getCurrentPV() | ||||
.getRegionReference(Constants.FO_REGION_BODY).getIPD()); | .getRegionReference(Constants.FO_REGION_BODY).getIPD()); | ||||
LinkedList footnoteBodyLMs = ((KnuthBlockBox) element).getFootnoteBodyLMs(); | |||||
List footnoteBodyLMs = ((KnuthBlockBox) element).getFootnoteBodyLMs(); | |||||
ListIterator footnoteBodyIterator = footnoteBodyLMs.listIterator(); | ListIterator footnoteBodyIterator = footnoteBodyLMs.listIterator(); | ||||
// store the lists of elements representing the footnote bodies | // store the lists of elements representing the footnote bodies | ||||
// in the box representing the line containing their references | // in the box representing the line containing their references |
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.LinkedList; | import java.util.LinkedList; | ||||
import java.util.List; | |||||
import java.util.ListIterator; | import java.util.ListIterator; | ||||
import org.apache.commons.logging.Log; | import org.apache.commons.logging.Log; | ||||
import org.apache.commons.logging.LogFactory; | import org.apache.commons.logging.LogFactory; | ||||
import org.apache.fop.fo.Constants; | import org.apache.fop.fo.Constants; | ||||
import org.apache.fop.fo.FObj; | import org.apache.fop.fo.FObj; | ||||
import org.apache.fop.layoutmgr.AbstractBreaker.PageBreakPosition; | import org.apache.fop.layoutmgr.AbstractBreaker.PageBreakPosition; | ||||
* @param elementLists list of KnuthElement sequences corresponding to the footnotes | * @param elementLists list of KnuthElement sequences corresponding to the footnotes | ||||
* bodies | * bodies | ||||
*/ | */ | ||||
private void handleFootnotes(LinkedList elementLists) { | |||||
private void handleFootnotes(List elementLists) { | |||||
// initialization | // initialization | ||||
if (!footnotesPending) { | if (!footnotesPending) { | ||||
footnotesPending = true; | footnotesPending = true; | ||||
return returnValue; | return returnValue; | ||||
} | } | ||||
private void resetFootnotes(LinkedList elementLists) { | |||||
private void resetFootnotes(List elementLists) { | |||||
for (int i = 0; i < elementLists.size(); i++) { | for (int i = 0; i < elementLists.size(); i++) { | ||||
/*LinkedList removedList = (LinkedList)*/footnotesList.remove(footnotesList.size() - 1); | /*LinkedList removedList = (LinkedList)*/footnotesList.remove(footnotesList.size() - 1); | ||||
lengthList.remove(lengthList.size() - 1); | lengthList.remove(lengthList.size() - 1); |
* Resolves unresolved elements applying the space resolution rules defined in 4.3.1. | * Resolves unresolved elements applying the space resolution rules defined in 4.3.1. | ||||
* @param elems the element list | * @param elems the element list | ||||
*/ | */ | ||||
public static void resolveElementList(LinkedList elems) { | |||||
public static void resolveElementList(List elems) { | |||||
if (log.isTraceEnabled()) { | if (log.isTraceEnabled()) { | ||||
log.trace(elems); | log.trace(elems); | ||||
} | } |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
if (true) { | if (true) { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"Shouldn't this method be emptied because it's never called at all?"); | "Shouldn't this method be emptied because it's never called at all?"); | ||||
BlockLevelLayoutManager curLM; | BlockLevelLayoutManager curLM; | ||||
BlockLevelLayoutManager prevLM = null; | BlockLevelLayoutManager prevLM = null; | ||||
MinOptMax stackSize = new MinOptMax(); | MinOptMax stackSize = new MinOptMax(); | ||||
LinkedList returnedList; | |||||
LinkedList returnList = new LinkedList(); | |||||
List returnedList; | |||||
List returnList = new LinkedList(); | |||||
while ((curLM = ((BlockLevelLayoutManager) getChildLM())) != null) { | while ((curLM = ((BlockLevelLayoutManager) getChildLM())) != null) { | ||||
if (curLM instanceof InlineLevelLayoutManager) { | if (curLM instanceof InlineLevelLayoutManager) { | ||||
// + returnedList.size()); | // + returnedList.size()); | ||||
// "wrap" the Position inside each element | // "wrap" the Position inside each element | ||||
LinkedList tempList = returnedList; | |||||
List tempList = returnedList; | |||||
KnuthElement tempElement; | KnuthElement tempElement; | ||||
returnedList = new LinkedList(); | returnedList = new LinkedList(); | ||||
ListIterator listIter = tempList.listIterator(); | ListIterator listIter = tempList.listIterator(); | ||||
} | } | ||||
if (returnedList.size() == 1 | if (returnedList.size() == 1 | ||||
&& ((KnuthElement)returnedList.getFirst()).isPenalty() | |||||
&& ((KnuthPenalty)returnedList.getFirst()).getP() == -KnuthElement.INFINITE) { | |||||
&& ((KnuthElement)returnedList.get(0)).isPenalty() | |||||
&& ((KnuthPenalty)returnedList.get(0)).getP() == -KnuthElement.INFINITE) { | |||||
// a descendant of this flow has break-before | // a descendant of this flow has break-before | ||||
returnList.addAll(returnedList); | returnList.addAll(returnedList); | ||||
return returnList; | return returnList; | ||||
returnList.add(new KnuthPenalty(0, | returnList.add(new KnuthPenalty(0, | ||||
KnuthElement.INFINITE, false, | KnuthElement.INFINITE, false, | ||||
new Position(this), false)); | new Position(this), false)); | ||||
} else if (!((KnuthElement) returnList.getLast()).isGlue()) { | |||||
} else if (!((KnuthElement) returnList.get(returnList | |||||
.size() - 1)).isGlue()) { | |||||
// add a null penalty to allow a break between blocks | // add a null penalty to allow a break between blocks | ||||
returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false)); | returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false)); | ||||
} | } | ||||
} | } | ||||
/*LF*/ if (returnedList.size() > 0) { // controllare! | /*LF*/ if (returnedList.size() > 0) { // controllare! | ||||
returnList.addAll(returnedList); | returnList.addAll(returnedList); | ||||
if (((KnuthElement)returnedList.getLast()).isPenalty() | |||||
&& ((KnuthPenalty)returnedList.getLast()).getP() | |||||
== -KnuthElement.INFINITE) { | |||||
final KnuthElement last = (KnuthElement) returnedList | |||||
.get(returnedList.size() - 1); | |||||
if (last.isPenalty() | |||||
&& ((KnuthPenalty) last).getP() == -KnuthElement.INFINITE) { | |||||
// a descendant of this flow has break-after | // a descendant of this flow has break-after | ||||
/*LF*/ //log.debug("FLM - break after!!"); | /*LF*/ //log.debug("FLM - break after!!"); | ||||
return returnList; | return returnList; | ||||
return lc; | return lc; | ||||
} | } | ||||
protected LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
protected List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
LayoutManager curLM; // currently active LM | LayoutManager curLM; // currently active LM | ||||
LinkedList returnList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
while ((curLM = getChildLM()) != null) { | while ((curLM = getChildLM()) != null) { | ||||
LayoutContext childLC = new LayoutContext(0); | LayoutContext childLC = new LayoutContext(0); | ||||
childLC.setRefIPD(context.getRefIPD()); | childLC.setRefIPD(context.getRefIPD()); | ||||
childLC.setWritingMode(context.getWritingMode()); | childLC.setWritingMode(context.getWritingMode()); | ||||
LinkedList returnedList = null; | |||||
List returnedList = null; | |||||
//The following is a HACK! Ignore leading and trailing white space | //The following is a HACK! Ignore leading and trailing white space | ||||
boolean ignore = curLM instanceof TextLayoutManager; | boolean ignore = curLM instanceof TextLayoutManager; | ||||
if (!curLM.isFinished()) { | if (!curLM.isFinished()) { |
import java.awt.Dimension; | import java.awt.Dimension; | ||||
import java.awt.Rectangle; | import java.awt.Rectangle; | ||||
import java.util.LinkedList; | |||||
import java.util.List; | |||||
import org.apache.fop.area.Area; | import org.apache.fop.area.Area; | ||||
import org.apache.fop.area.inline.Viewport; | import org.apache.fop.area.inline.Viewport; | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, | |||||
public List getNextKnuthElements(LayoutContext context, | |||||
int alignment) { | int alignment) { | ||||
Viewport areaCurrent = getInlineArea(); | Viewport areaCurrent = getInlineArea(); | ||||
setCurrentArea(areaCurrent); | setCurrentArea(areaCurrent); |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
MinOptMax ipd; | MinOptMax ipd; | ||||
curArea = get(context); | curArea = get(context); | ||||
KnuthSequence seq = new InlineKnuthSequence(); | KnuthSequence seq = new InlineKnuthSequence(); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getChangedKnuthElements(List oldList, int alignment) { | |||||
public List getChangedKnuthElements(List oldList, int alignment) { | |||||
if (isFinished()) { | if (isFinished()) { | ||||
return null; | return null; | ||||
} | } |
import org.apache.commons.logging.Log; | import org.apache.commons.logging.Log; | ||||
import org.apache.commons.logging.LogFactory; | import org.apache.commons.logging.LogFactory; | ||||
import org.apache.fop.apps.FOUserAgent; | |||||
import org.apache.fop.area.Area; | import org.apache.fop.area.Area; | ||||
import org.apache.fop.area.Block; | import org.apache.fop.area.Block; | ||||
import org.apache.fop.area.LineArea; | import org.apache.fop.area.LineArea; | ||||
stackSize = 0; | stackSize = 0; | ||||
LinkedList contentList = | |||||
List contentList = | |||||
getNextKnuthElements(childLC, Constants.EN_START); | getNextKnuthElements(childLC, Constants.EN_START); | ||||
ListIterator contentIter = contentList.listIterator(); | ListIterator contentIter = contentList.listIterator(); | ||||
while (contentIter.hasNext()) { | while (contentIter.hasNext()) { | ||||
} | } | ||||
} | } | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
LinkedList contentList = new LinkedList(); | |||||
LinkedList returnedList; | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
List contentList = new LinkedList(); | |||||
List returnedList; | |||||
childLM.initialize(); | childLM.initialize(); | ||||
while (!childLM.isFinished()) { | while (!childLM.isFinished()) { | ||||
// move elements to contentList, and accumulate their size | // move elements to contentList, and accumulate their size | ||||
KnuthElement contentElement; | KnuthElement contentElement; | ||||
while (returnedList.size() > 0) { | while (returnedList.size() > 0) { | ||||
Object obj = returnedList.removeFirst(); | |||||
Object obj = returnedList.remove(0); | |||||
if (obj instanceof KnuthSequence) { | if (obj instanceof KnuthSequence) { | ||||
KnuthSequence ks = (KnuthSequence)obj; | KnuthSequence ks = (KnuthSequence)obj; | ||||
for (Iterator it = ks.iterator(); it.hasNext(); ) { | for (Iterator it = ks.iterator(); it.hasNext(); ) { | ||||
return false; | return false; | ||||
} | } | ||||
public LinkedList getChangedKnuthElements(List oldList, | |||||
public List getChangedKnuthElements(List oldList, | |||||
/*int flaggedPenalty,*/ | /*int flaggedPenalty,*/ | ||||
int alignment) { | int alignment) { | ||||
return null; | return null; |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList 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 | ||||
// later on, when this LM will have nothing more to do, the citationLM's parent | // later on, when this LM will have nothing more to do, the citationLM's parent | ||||
bodyLM.initialize(); | bodyLM.initialize(); | ||||
// get Knuth elements representing the footnote citation | // get Knuth elements representing the footnote citation | ||||
LinkedList returnedList = new LinkedList(); | |||||
List returnedList = new LinkedList(); | |||||
while (!citationLM.isFinished()) { | while (!citationLM.isFinished()) { | ||||
LinkedList partialList = citationLM.getNextKnuthElements(context, alignment); | |||||
List partialList = citationLM.getNextKnuthElements(context, alignment); | |||||
if (partialList != null) { | if (partialList != null) { | ||||
returnedList.addAll(partialList); | returnedList.addAll(partialList); | ||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public LinkedList getChangedKnuthElements(List oldList, | |||||
public List getChangedKnuthElements(List oldList, | |||||
int alignment) { | int alignment) { | ||||
LinkedList returnedList = super.getChangedKnuthElements(oldList, alignment); | |||||
List returnedList = super.getChangedKnuthElements(oldList, alignment); | |||||
addAnchor(returnedList); | addAnchor(returnedList); | ||||
return returnedList; | return returnedList; | ||||
} | } | ||||
* Find the last box in the sequence, and add a reference to the FootnoteBodyLM | * Find the last box in the sequence, and add a reference to the FootnoteBodyLM | ||||
* @param citationList the list of elements representing the footnote citation | * @param citationList the list of elements representing the footnote citation | ||||
*/ | */ | ||||
private void addAnchor(LinkedList citationList) { | |||||
private void addAnchor(List citationList) { | |||||
KnuthInlineBox lastBox = null; | KnuthInlineBox lastBox = null; | ||||
// the list of elements is searched backwards, until we find a box | // the list of elements is searched backwards, until we find a box | ||||
ListIterator citationIterator = citationList.listIterator(citationList.size()); | ListIterator citationIterator = citationList.listIterator(citationList.size()); |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
LayoutManager curLM; | LayoutManager curLM; | ||||
// the list returned by child LM | // the list returned by child LM | ||||
LinkedList returnedList; | |||||
List returnedList; | |||||
// the list which will be returned to the parent LM | // the list which will be returned to the parent LM | ||||
LinkedList returnList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
KnuthSequence lastSequence = null; | KnuthSequence lastSequence = null; | ||||
SpaceSpecifier leadingSpace = context.getLeadingSpace(); | SpaceSpecifier leadingSpace = context.getLeadingSpace(); | ||||
context.updateKeepWithNextPending(childLC.getKeepWithNextPending()); | context.updateKeepWithNextPending(childLC.getKeepWithNextPending()); | ||||
childLC.clearKeepsPending(); | childLC.clearKeepsPending(); | ||||
} | } | ||||
lastSequence = (KnuthSequence) returnList.getLast(); | |||||
lastSequence = (KnuthSequence) returnList | |||||
.get(returnList.size() - 1); | |||||
lastChildLM = curLM; | lastChildLM = curLM; | ||||
} | } | ||||
// 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. | ||||
LinkedList positionList = new LinkedList(); | |||||
List positionList = new LinkedList(); | |||||
NonLeafPosition pos; | NonLeafPosition 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; | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getChangedKnuthElements(List oldList, int alignment) { | |||||
LinkedList returnedList = new LinkedList(); | |||||
public List getChangedKnuthElements(List oldList, int alignment) { | |||||
List returnedList = new LinkedList(); | |||||
addKnuthElementsForBorderPaddingStart(returnedList); | addKnuthElementsForBorderPaddingStart(returnedList); | ||||
returnedList.addAll(super.getChangedKnuthElements(oldList, alignment)); | returnedList.addAll(super.getChangedKnuthElements(oldList, alignment)); | ||||
addKnuthElementsForBorderPaddingEnd(returnedList); | addKnuthElementsForBorderPaddingEnd(returnedList); |
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public LinkedList getChangedKnuthElements(List oldList, int alignment) { | |||||
public List getChangedKnuthElements(List oldList, int alignment) { | |||||
// "unwrap" the Positions stored in the elements | // "unwrap" the Positions stored in the elements | ||||
ListIterator oldListIterator = oldList.listIterator(); | ListIterator oldListIterator = oldList.listIterator(); | ||||
KnuthElement oldElement; | KnuthElement oldElement; |
private Leader fobj; | private Leader fobj; | ||||
private Font font = null; | private Font font = null; | ||||
private LinkedList contentList = null; | |||||
private List contentList = null; | |||||
private ContentLayoutManager clm = null; | private ContentLayoutManager clm = null; | ||||
private int contentAreaIPD = 0; | private int contentAreaIPD = 0; | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, | |||||
public List getNextKnuthElements(LayoutContext context, | |||||
int alignment) { | int alignment) { | ||||
MinOptMax ipd; | MinOptMax ipd; | ||||
curArea = get(context); | curArea = get(context); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getChangedKnuthElements(List oldList, | |||||
public List getChangedKnuthElements(List oldList, | |||||
int alignment) { | int alignment) { | ||||
if (isFinished()) { | if (isFinished()) { | ||||
return null; | return null; | ||||
} | } | ||||
LinkedList returnList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
addKnuthElementsForBorderPaddingStart(returnList); | addKnuthElementsForBorderPaddingStart(returnList); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
curArea = get(context); | curArea = get(context); | ||||
if (curArea == null) { | if (curArea == null) { | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getChangedKnuthElements(List oldList, | |||||
public List getChangedKnuthElements(List oldList, | |||||
int alignment) { | int alignment) { | ||||
if (isFinished()) { | if (isFinished()) { | ||||
return null; | return null; |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
FontInfo fi = fobj.getFOEventHandler().getFontInfo(); | FontInfo fi = fobj.getFOEventHandler().getFontInfo(); | ||||
FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi); | FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi); | ||||
Font fs = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this)); | Font fs = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this)); | ||||
LayoutContext inlineLC = new LayoutContext(context); | LayoutContext inlineLC = new LayoutContext(context); | ||||
InlineLevelLayoutManager curLM; | InlineLevelLayoutManager curLM; | ||||
LinkedList returnedList = null; | |||||
List returnedList = null; | |||||
iLineWidth = context.getStackLimitIP().opt; | iLineWidth = context.getStackLimitIP().opt; | ||||
// convert all the text in a sequence of paragraphs made | // convert all the text in a sequence of paragraphs made | ||||
} | } | ||||
if (lastPar != null) { | if (lastPar != null) { | ||||
KnuthSequence firstSeq = (KnuthSequence) returnedList.getFirst(); | |||||
KnuthSequence firstSeq = (KnuthSequence) returnedList.get(0); | |||||
// finish last paragraph before a new block sequence | // finish last paragraph before a new block sequence | ||||
if (!firstSeq.isInlineSequence()) { | if (!firstSeq.isInlineSequence()) { | ||||
* @param context the layout context | * @param context the layout context | ||||
* @return a list of Knuth elements representing broken lines | * @return a list of Knuth elements representing broken lines | ||||
*/ | */ | ||||
private LinkedList createLineBreaks(int alignment, LayoutContext context) { | |||||
private List createLineBreaks(int alignment, LayoutContext context) { | |||||
// find the optimal line breaking points for each paragraph | // find the optimal line breaking points for each paragraph | ||||
ListIterator paragraphsIterator | ListIterator paragraphsIterator | ||||
* @param context the layout context | * @param context the layout context | ||||
* @return the newly built element list | * @return the newly built element list | ||||
*/ | */ | ||||
private LinkedList postProcessLineBreaks(int alignment, LayoutContext context) { | |||||
private List postProcessLineBreaks(int alignment, LayoutContext context) { | |||||
LinkedList returnList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
for (int p = 0; p < knuthParagraphs.size(); p++) { | for (int p = 0; p < knuthParagraphs.size(); p++) { | ||||
// penalty between paragraphs | // penalty between paragraphs | ||||
KnuthSequence seq = (KnuthSequence) knuthParagraphs.get(p); | KnuthSequence seq = (KnuthSequence) knuthParagraphs.get(p); | ||||
if (!seq.isInlineSequence()) { | if (!seq.isInlineSequence()) { | ||||
LinkedList targetList = new LinkedList(); | |||||
List targetList = new LinkedList(); | |||||
ListIterator listIter = seq.listIterator(); | ListIterator listIter = seq.listIterator(); | ||||
while (listIter.hasNext()) { | while (listIter.hasNext()) { | ||||
ListElement tempElement; | ListElement tempElement; | ||||
= ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos(); | = ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos(); | ||||
// create a list of the FootnoteBodyLM handling footnotes | // create a list of the FootnoteBodyLM handling footnotes | ||||
// whose citations are in this line | // whose citations are in this line | ||||
LinkedList footnoteList = new LinkedList(); | |||||
List footnoteList = new LinkedList(); | |||||
ListIterator elementIterator = seq.listIterator(startIndex); | ListIterator elementIterator = seq.listIterator(startIndex); | ||||
while (elementIterator.nextIndex() <= endIndex) { | while (elementIterator.nextIndex() <= endIndex) { | ||||
KnuthElement element = (KnuthElement) elementIterator.next(); | KnuthElement element = (KnuthElement) elementIterator.next(); | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public LinkedList getChangedKnuthElements(List oldList, int alignment) { | |||||
LinkedList returnList = new LinkedList(); | |||||
public List getChangedKnuthElements(List oldList, int alignment) { | |||||
List returnList = new LinkedList(); | |||||
for (int p = 0; p < knuthParagraphs.size(); p++) { | for (int p = 0; p < knuthParagraphs.size(); p++) { | ||||
LineLayoutPossibilities llPoss; | LineLayoutPossibilities llPoss; | ||||
llPoss = (LineLayoutPossibilities)lineLayoutsList.get(p); | llPoss = (LineLayoutPossibilities)lineLayoutsList.get(p); | ||||
ListIterator currParIterator | ListIterator currParIterator | ||||
= currPar.listIterator(currPar.ignoreAtStart); | = currPar.listIterator(currPar.ignoreAtStart); | ||||
// list of TLM involved in hyphenation | // list of TLM involved in hyphenation | ||||
LinkedList updateList = new LinkedList(); | |||||
List updateList = new LinkedList(); | |||||
KnuthElement firstElement = null; | KnuthElement firstElement = null; | ||||
KnuthElement nextElement = null; | KnuthElement nextElement = null; | ||||
// current InlineLevelLayoutManager | // current InlineLevelLayoutManager | ||||
.applyChanges(currPar.subList(fromIndex + iAddedElements, | .applyChanges(currPar.subList(fromIndex + iAddedElements, | ||||
toIndex + iAddedElements))) { | toIndex + iAddedElements))) { | ||||
// insert the new KnuthElements | // insert the new KnuthElements | ||||
LinkedList newElements = null; | |||||
List newElements = null; | |||||
newElements | newElements | ||||
= currUpdate.inlineLM.getChangedKnuthElements | = currUpdate.inlineLM.getChangedKnuthElements | ||||
(currPar.subList(fromIndex + iAddedElements, | (currPar.subList(fromIndex + iAddedElements, |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(final LayoutContext context, final int alignment) { | |||||
public List getNextKnuthElements(final LayoutContext context, final int alignment) { | |||||
this.lineStartBAP = context.getLineStartBorderAndPaddingWidth(); | this.lineStartBAP = context.getLineStartBorderAndPaddingWidth(); | ||||
this.lineEndBAP = context.getLineEndBorderAndPaddingWidth(); | this.lineEndBAP = context.getLineEndBorderAndPaddingWidth(); | ||||
this.alignmentContext = context.getAlignmentContext(); | this.alignmentContext = context.getAlignmentContext(); | ||||
final LinkedList returnList = new LinkedList(); | |||||
final List returnList = new LinkedList(); | |||||
KnuthSequence sequence = new InlineKnuthSequence(); | KnuthSequence sequence = new InlineKnuthSequence(); | ||||
AreaInfo ai = null; | AreaInfo ai = null; | ||||
AreaInfo prevAi = null; | AreaInfo prevAi = null; | ||||
sequence = this.processLinebreak(returnList, sequence); | sequence = this.processLinebreak(returnList, sequence); | ||||
} | } | ||||
if (((List)returnList.getLast()).size() == 0) { | |||||
if (((List) returnList.get(returnList.size() - 1)).isEmpty()) { | |||||
//Remove an empty sequence because of a trailing newline | //Remove an empty sequence because of a trailing newline | ||||
returnList.removeLast(); | |||||
returnList.remove(returnList.size() - 1); | |||||
} | } | ||||
this.setFinished(true); | this.setFinished(true); | ||||
} | } | ||||
} | } | ||||
private KnuthSequence processLinebreak(final LinkedList returnList, | |||||
private KnuthSequence processLinebreak(final List returnList, | |||||
KnuthSequence sequence) { | KnuthSequence sequence) { | ||||
if (this.lineEndBAP != 0) { | if (this.lineEndBAP != 0) { | ||||
sequence.add( | sequence.add( | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getChangedKnuthElements(final List oldList, | |||||
public List getChangedKnuthElements(final List oldList, | |||||
final int alignment) { | final int alignment) { | ||||
if (this.isFinished()) { | if (this.isFinished()) { | ||||
return null; | return null; |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
resetSpaces(); | resetSpaces(); | ||||
LinkedList returnList = super.getNextKnuthElements(context, alignment); | |||||
List returnList = super.getNextKnuthElements(context, alignment); | |||||
//fox:widow-content-limit | //fox:widow-content-limit | ||||
int widowRowLimit = getListBlockFO().getWidowContentLimit().getValue(); | int widowRowLimit = getListBlockFO().getWidowContentLimit().getValue(); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getChangedKnuthElements(List oldList, int alignment) { | |||||
public List getChangedKnuthElements(List oldList, int alignment) { | |||||
//log.debug("LBLM.getChangedKnuthElements>"); | //log.debug("LBLM.getChangedKnuthElements>"); | ||||
return super.getChangedKnuthElements(oldList, alignment); | return super.getChangedKnuthElements(oldList, alignment); | ||||
} | } |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getChangedKnuthElements(List oldList, int alignment) { | |||||
public List getChangedKnuthElements(List oldList, int alignment) { | |||||
//log.debug(" ListItemContentLayoutManager.getChanged>"); | //log.debug(" ListItemContentLayoutManager.getChanged>"); | ||||
return super.getChangedKnuthElements(oldList, alignment); | return super.getChangedKnuthElements(oldList, alignment); | ||||
} | } |
private Block curBlockArea = null; | private Block curBlockArea = null; | ||||
private LinkedList labelList = null; | |||||
private LinkedList bodyList = null; | |||||
private List labelList = null; | |||||
private List bodyList = null; | |||||
private boolean discardBorderBefore; | private boolean discardBorderBefore; | ||||
private boolean discardBorderAfter; | private boolean discardBorderAfter; | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
referenceIPD = context.getRefIPD(); | referenceIPD = context.getRefIPD(); | ||||
LayoutContext childLC; | LayoutContext childLC; | ||||
LinkedList returnList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
if (!breakBeforeServed) { | if (!breakBeforeServed) { | ||||
try { | try { | ||||
this.keepWithNextPendingOnBody = childLC.getKeepWithNextPending(); | this.keepWithNextPendingOnBody = childLC.getKeepWithNextPending(); | ||||
// create a combined list | // create a combined list | ||||
LinkedList returnedList = getCombinedKnuthElementsForListItem(labelList, bodyList, context); | |||||
List returnedList = getCombinedKnuthElementsForListItem(labelList, bodyList, context); | |||||
// "wrap" the Position inside each element | // "wrap" the Position inside each element | ||||
wrapPositionElements(returnedList, returnList, true); | wrapPositionElements(returnedList, returnList, true); | ||||
return returnList; | return returnList; | ||||
} | } | ||||
private LinkedList getCombinedKnuthElementsForListItem(LinkedList labelElements, | |||||
LinkedList bodyElements, | |||||
LayoutContext context) { | |||||
//Copy elements to array lists to improve element access performance | |||||
private List getCombinedKnuthElementsForListItem(List labelElements, | |||||
List bodyElements, LayoutContext context) { | |||||
// Copy elements to array lists to improve element access performance | |||||
List[] elementLists = {new ArrayList(labelElements), | List[] elementLists = {new ArrayList(labelElements), | ||||
new ArrayList(bodyElements)}; | new ArrayList(bodyElements)}; | ||||
int[] fullHeights = {ElementListUtils.calcContentLength(elementLists[0]), | int[] fullHeights = {ElementListUtils.calcContentLength(elementLists[0]), | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public LinkedList getChangedKnuthElements(List oldList, int alignment) { | |||||
public List getChangedKnuthElements(List oldList, int alignment) { | |||||
//log.debug(" LILM.getChanged> label"); | //log.debug(" LILM.getChanged> label"); | ||||
// label | // label | ||||
labelList = label.getChangedKnuthElements(labelList, alignment); | labelList = label.getChangedKnuthElements(labelList, alignment); | ||||
} | } | ||||
} | } | ||||
LinkedList returnedList = body.getChangedKnuthElements(oldList, alignment); | |||||
List returnedList = body.getChangedKnuthElements(oldList, alignment); | |||||
// "wrap" the Position inside each element | // "wrap" the Position inside each element | ||||
LinkedList tempList = returnedList; | |||||
List tempList = returnedList; | |||||
KnuthElement tempElement; | KnuthElement tempElement; | ||||
returnedList = new LinkedList(); | returnedList = new LinkedList(); | ||||
ListIterator listIter = tempList.listIterator(); | ListIterator listIter = tempList.listIterator(); |
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.LinkedList; | import java.util.LinkedList; | ||||
import java.util.List; | |||||
import org.apache.commons.logging.Log; | import org.apache.commons.logging.Log; | ||||
import org.apache.commons.logging.LogFactory; | import org.apache.commons.logging.LogFactory; | ||||
import org.apache.fop.fo.Constants; | import org.apache.fop.fo.Constants; | ||||
import org.apache.fop.fo.flow.table.EffRow; | import org.apache.fop.fo.flow.table.EffRow; | ||||
import org.apache.fop.fo.flow.table.GridUnit; | import org.apache.fop.fo.flow.table.GridUnit; | ||||
childLC.setRefIPD(spanWidth); | childLC.setRefIPD(spanWidth); | ||||
//Get the element list for the cell contents | //Get the element list for the cell contents | ||||
LinkedList elems = primary.getCellLM().getNextKnuthElements( | |||||
List elems = primary.getCellLM().getNextKnuthElements( | |||||
childLC, alignment); | childLC, alignment); | ||||
ElementListObserver.observe(elems, "table-cell", primary.getCell().getId()); | ElementListObserver.observe(elems, "table-cell", primary.getCell().getId()); | ||||
primary.setElements(elems); | primary.setElements(elems); | ||||
} | } | ||||
} | } | ||||
computeRowHeights(); | computeRowHeights(); | ||||
LinkedList elements = tableStepper.getCombinedKnuthElementsForRowGroup(context, | |||||
List elements = tableStepper.getCombinedKnuthElementsForRowGroup(context, | |||||
rowGroup, bodyType); | rowGroup, bodyType); | ||||
returnList.addAll(elements); | returnList.addAll(elements); | ||||
} | } |
package org.apache.fop.layoutmgr.table; | package org.apache.fop.layoutmgr.table; | ||||
import java.util.LinkedList; | import java.util.LinkedList; | ||||
import java.util.List; | |||||
import org.apache.commons.logging.Log; | import org.apache.commons.logging.Log; | ||||
import org.apache.commons.logging.LogFactory; | import org.apache.commons.logging.LogFactory; | ||||
import org.apache.fop.area.Area; | import org.apache.fop.area.Area; | ||||
import org.apache.fop.area.Block; | import org.apache.fop.area.Block; | ||||
import org.apache.fop.area.Trait; | import org.apache.fop.area.Trait; | ||||
import org.apache.fop.fo.flow.ListItem; | |||||
import org.apache.fop.fo.flow.table.ConditionalBorder; | import org.apache.fop.fo.flow.table.ConditionalBorder; | ||||
import org.apache.fop.fo.flow.table.GridUnit; | import org.apache.fop.fo.flow.table.GridUnit; | ||||
import org.apache.fop.fo.flow.table.PrimaryGridUnit; | import org.apache.fop.fo.flow.table.PrimaryGridUnit; | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
MinOptMax stackLimit = new MinOptMax(context.getStackLimitBP()); | MinOptMax stackLimit = new MinOptMax(context.getStackLimitBP()); | ||||
referenceIPD = context.getRefIPD(); | referenceIPD = context.getRefIPD(); | ||||
cellIPD = referenceIPD; | cellIPD = referenceIPD; | ||||
cellIPD -= getIPIndents(); | cellIPD -= getIPIndents(); | ||||
LinkedList returnedList; | |||||
LinkedList contentList = new LinkedList(); | |||||
LinkedList returnList = new LinkedList(); | |||||
List returnedList; | |||||
List contentList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
BlockLevelLayoutManager curLM; // currently active LM | BlockLevelLayoutManager curLM; // currently active LM | ||||
BlockLevelLayoutManager prevLM = null; // previously active LM | BlockLevelLayoutManager prevLM = null; // previously active LM | ||||
} | } | ||||
//Space resolution | //Space resolution | ||||
SpaceResolver.resolveElementList(returnList); | SpaceResolver.resolveElementList(returnList); | ||||
if (((KnuthElement) returnList.getFirst()).isForcedBreak()) { | |||||
primaryGridUnit.setBreakBefore(((KnuthPenalty) returnList.getFirst()).getBreakClass()); | |||||
returnList.removeFirst(); | |||||
if (((KnuthElement) returnList.get(0)).isForcedBreak()) { | |||||
primaryGridUnit.setBreakBefore(((KnuthPenalty) returnList.get(0)).getBreakClass()); | |||||
returnList.remove(0); | |||||
assert !returnList.isEmpty(); | assert !returnList.isEmpty(); | ||||
} | } | ||||
if (((KnuthElement) returnList.getLast()).isForcedBreak()) { | |||||
KnuthPenalty p = (KnuthPenalty) returnList.getLast(); | |||||
final KnuthElement lastItem = (KnuthElement) returnList | |||||
.get(returnList.size() - 1); | |||||
if (((KnuthElement) lastItem).isForcedBreak()) { | |||||
KnuthPenalty p = (KnuthPenalty) lastItem; | |||||
primaryGridUnit.setBreakAfter(p.getBreakClass()); | primaryGridUnit.setBreakAfter(p.getBreakClass()); | ||||
p.setP(0); | p.setP(0); | ||||
} | } |
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { | |||||
public List getNextKnuthElements(LayoutContext context, int alignment) { | |||||
LinkedList returnList = new LinkedList(); | |||||
List returnList = new LinkedList(); | |||||
/* | /* | ||||
* Compute the IPD and adjust it if necessary (overconstrained) | * Compute the IPD and adjust it if necessary (overconstrained) | ||||
int breakBefore = BreakUtil.compareBreakClasses(getTable().getBreakBefore(), | int breakBefore = BreakUtil.compareBreakClasses(getTable().getBreakBefore(), | ||||
childLC.getBreakBefore()); | childLC.getBreakBefore()); | ||||
if (breakBefore != Constants.EN_AUTO) { | if (breakBefore != Constants.EN_AUTO) { | ||||
returnList.addFirst(new BreakElement(getAuxiliaryPosition(), | |||||
0, -KnuthElement.INFINITE, breakBefore, context)); | |||||
returnList.add(0, new BreakElement(getAuxiliaryPosition(), 0, | |||||
-KnuthElement.INFINITE, breakBefore, context)); | |||||
} | } | ||||
//addKnuthElementsForBreakAfter(returnList, context); | //addKnuthElementsForBreakAfter(returnList, context); |