removes a number of ClassCastExceptions in some files with inline block content. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@359189 13f79535-47bb-0310-9956-ffa450edef68tags/fop-0_92-beta
@@ -332,7 +332,7 @@ public abstract class AbstractBreaker { | |||
if (p == 0) { | |||
lastBreakClass = effectiveList.getStartOn(); | |||
} else { | |||
KnuthElement lastBreakElement = effectiveList.getElement(endElementIndex); | |||
ListElement lastBreakElement = effectiveList.getElement(endElementIndex); | |||
if (lastBreakElement.isPenalty()) { | |||
KnuthPenalty pen = (KnuthPenalty)lastBreakElement; | |||
lastBreakClass = pen.getBreakClass(); |
@@ -79,9 +79,9 @@ public class BlockKnuthSequence extends KnuthSequence { | |||
*/ | |||
public static boolean mustKeepTogether(BlockKnuthSequence sequence1, | |||
BlockKnuthSequence sequence2) { | |||
KnuthElement element1 = (KnuthElement) sequence1.get(sequence1.size() - 1); | |||
ListElement element1 = (ListElement) sequence1.get(sequence1.size() - 1); | |||
LayoutManager lm1 = (LayoutManager) element1.getLayoutManager(); | |||
KnuthElement element2 = (KnuthElement) sequence2.get(0); | |||
ListElement element2 = (ListElement) sequence2.get(0); | |||
LayoutManager lm2 = (LayoutManager) element2.getLayoutManager(); | |||
if (!lm1.equals(lm2)) { | |||
throw new IllegalStateException |
@@ -474,7 +474,7 @@ public abstract class BreakingAlgorithm { | |||
* @return the requested context FO note or null, if no context node could be determined | |||
*/ | |||
private FONode findContextFO(KnuthSequence seq, int position) { | |||
KnuthElement el = seq.getElement(position); | |||
ListElement el = seq.getElement(position); | |||
while (el.getLayoutManager() == null && position < seq.size() - 1) { | |||
position++; | |||
el = seq.getElement(position); |
@@ -70,11 +70,11 @@ public class InlineKnuthSequence extends KnuthSequence { | |||
return false; | |||
} | |||
// does the first element of the first paragraph add to an existing word? | |||
KnuthElement lastOldElement, firstNewElement; | |||
ListElement lastOldElement, firstNewElement; | |||
lastOldElement = getLast(); | |||
firstNewElement = sequence.getElement(0); | |||
if (firstNewElement.isBox() && !firstNewElement.isAuxiliary() | |||
&& lastOldElement.isBox() && lastOldElement.getW() != 0) { | |||
if (firstNewElement.isBox() && !((KnuthElement) firstNewElement).isAuxiliary() | |||
&& lastOldElement.isBox() && ((KnuthElement) lastOldElement).getW() != 0) { | |||
addALetterSpace(); | |||
} | |||
addAll(sequence); |
@@ -88,9 +88,9 @@ public abstract class KnuthSequence extends ArrayList { | |||
*/ | |||
public void wrapPositions(LayoutManager lm) { | |||
ListIterator listIter = listIterator(); | |||
KnuthElement element; | |||
ListElement element; | |||
while (listIter.hasNext()) { | |||
element = (KnuthElement) listIter.next(); | |||
element = (ListElement) listIter.next(); | |||
element.setPosition | |||
(lm.notifyPos(new NonLeafPosition(lm, element.getPosition()))); | |||
} | |||
@@ -99,32 +99,32 @@ public abstract class KnuthSequence extends ArrayList { | |||
/** | |||
* @return the last element of this sequence. | |||
*/ | |||
public KnuthElement getLast() { | |||
public ListElement getLast() { | |||
int idx = size(); | |||
if (idx == 0) { | |||
return null; | |||
} | |||
return (KnuthElement) get(idx - 1); | |||
return (ListElement) get(idx - 1); | |||
} | |||
/** | |||
* Remove the last element of this sequence. | |||
* @return the removed element. | |||
*/ | |||
public KnuthElement removeLast() { | |||
public ListElement removeLast() { | |||
int idx = size(); | |||
if (idx == 0) { | |||
return null; | |||
} | |||
return (KnuthElement) remove(idx - 1); | |||
return (ListElement) remove(idx - 1); | |||
} | |||
/** | |||
* @param index The index of the element to be returned | |||
* @return the element at index index. | |||
*/ | |||
public KnuthElement getElement(int index) { | |||
return (KnuthElement) get(index); | |||
public ListElement getElement(int index) { | |||
return (ListElement) get(index); | |||
} | |||
/** |
@@ -367,7 +367,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { | |||
index ++) { | |||
if (par.getElement(index).isGlue() && par.getElement(index - 1).isBox() | |||
|| par.getElement(index).isPenalty() | |||
&& par.getElement(index).getP() < KnuthElement.INFINITE) { | |||
&& ((KnuthElement) par.getElement(index)).getP() < KnuthElement.INFINITE) { | |||
// break found | |||
break; | |||
} |
@@ -41,6 +41,7 @@ import org.apache.fop.layoutmgr.KnuthSequence; | |||
import org.apache.fop.layoutmgr.LayoutContext; | |||
import org.apache.fop.layoutmgr.LayoutManager; | |||
import org.apache.fop.layoutmgr.LeafPosition; | |||
import org.apache.fop.layoutmgr.ListElement; | |||
import org.apache.fop.layoutmgr.NonLeafPosition; | |||
import org.apache.fop.layoutmgr.Position; | |||
import org.apache.fop.layoutmgr.PositionIterator; | |||
@@ -735,13 +736,13 @@ public class LineLayoutManager extends InlineStackingLayoutManager | |||
// the sequence contains inline Knuth elements | |||
if (sequence.isInlineSequence()) { | |||
// look at the last element | |||
KnuthElement lastElement; | |||
lastElement = (KnuthElement) sequence.getLast(); | |||
ListElement lastElement; | |||
lastElement = sequence.getLast(); | |||
if (lastElement == null) { | |||
throw new NullPointerException( | |||
"Sequence was empty! lastElement is null"); | |||
} | |||
bPrevWasKnuthBox = lastElement.isBox() && lastElement.getW() != 0; | |||
bPrevWasKnuthBox = lastElement.isBox() && ((KnuthElement) lastElement).getW() != 0; | |||
// if last paragraph is open, add the new elements to the paragraph | |||
// else this is the last paragraph | |||
@@ -975,7 +976,11 @@ public class LineLayoutManager extends InlineStackingLayoutManager | |||
int localLineHeight = 0, lineStretch = 0, lineShrink = 0; | |||
ListIterator seqIterator = seq.listIterator(); | |||
while (seqIterator.hasNext()) { | |||
KnuthElement element = (KnuthElement) seqIterator.next(); | |||
ListElement elt = (ListElement) seqIterator.next(); | |||
if (!(elt instanceof KnuthElement)) { | |||
continue; | |||
} | |||
KnuthElement element = (KnuthElement) elt; | |||
localLineHeight += element.getW(); | |||
if (element.isGlue()) { | |||
lineStretch += element.getY(); | |||
@@ -1130,8 +1135,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager | |||
LinkedList targetList = new LinkedList(); | |||
ListIterator listIter = seq.listIterator(); | |||
while (listIter.hasNext()) { | |||
KnuthElement tempElement; | |||
tempElement = (KnuthElement) listIter.next(); | |||
ListElement tempElement; | |||
tempElement = (ListElement) listIter.next(); | |||
if (tempElement.getLayoutManager() != this) { | |||
tempElement.setPosition(notifyPos(new NonLeafPosition(this, | |||
tempElement.getPosition()))); |