|
|
@@ -30,31 +30,6 @@ import org.apache.fop.traits.MinOptMax; |
|
|
|
*/ |
|
|
|
public class ElementListUtils { |
|
|
|
|
|
|
|
/** |
|
|
|
* Removes all legal breaks in an element list. |
|
|
|
* @param elements the element list |
|
|
|
*/ |
|
|
|
public static void removeLegalBreaks(LinkedList elements) { |
|
|
|
ListIterator i = elements.listIterator(); |
|
|
|
while (i.hasNext()) { |
|
|
|
ListElement el = (ListElement)i.next(); |
|
|
|
if (el.isPenalty()) { |
|
|
|
BreakElement breakPoss = (BreakElement)el; |
|
|
|
//Convert all penalties no break inhibitors |
|
|
|
if (breakPoss.getPenaltyValue() < KnuthPenalty.INFINITE) { |
|
|
|
breakPoss.setPenaltyValue(KnuthPenalty.INFINITE); |
|
|
|
} |
|
|
|
} else if (el.isGlue()) { |
|
|
|
i.previous(); |
|
|
|
if (el.isBox()) { |
|
|
|
i.next(); |
|
|
|
i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, |
|
|
|
null, false)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Removes legal breaks in an element list. A constraint can be specified to limit the |
|
|
|
* range in which the breaks are removed. Legal breaks occuring before at least |
|
|
@@ -66,7 +41,7 @@ public class ElementListUtils { |
|
|
|
public static boolean removeLegalBreaks(LinkedList elements, MinOptMax constraint) { |
|
|
|
return removeLegalBreaks(elements, constraint.opt); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Removes legal breaks in an element list. A constraint can be specified to limit the |
|
|
|
* range in which the breaks are removed. Legal breaks occuring before at least |
|
|
@@ -84,7 +59,7 @@ public class ElementListUtils { |
|
|
|
KnuthPenalty penalty = (KnuthPenalty)el; |
|
|
|
//Convert all penalties to break inhibitors |
|
|
|
if (penalty.getP() < KnuthPenalty.INFINITE) { |
|
|
|
iter.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE, |
|
|
|
iter.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE, |
|
|
|
penalty.isFlagged(), penalty.getPosition(), penalty.isAuxiliary())); |
|
|
|
} |
|
|
|
} else if (el.isGlue()) { |
|
|
@@ -94,7 +69,7 @@ public class ElementListUtils { |
|
|
|
el = (ListElement)iter.previous(); |
|
|
|
iter.next(); |
|
|
|
if (el.isBox()) { |
|
|
|
iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, |
|
|
|
iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, |
|
|
|
null, false)); |
|
|
|
} |
|
|
|
iter.next(); |
|
|
@@ -131,7 +106,7 @@ public class ElementListUtils { |
|
|
|
KnuthPenalty penalty = (KnuthPenalty)el; |
|
|
|
//Convert all penalties to break inhibitors |
|
|
|
if (penalty.getP() < KnuthPenalty.INFINITE) { |
|
|
|
i.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE, |
|
|
|
i.set(new KnuthPenalty(penalty.getW(), KnuthPenalty.INFINITE, |
|
|
|
penalty.isFlagged(), penalty.getPosition(), penalty.isAuxiliary())); |
|
|
|
} |
|
|
|
} else if (el.isGlue()) { |
|
|
@@ -140,7 +115,7 @@ public class ElementListUtils { |
|
|
|
el = (ListElement)i.previous(); |
|
|
|
i.next(); |
|
|
|
if (el.isBox()) { |
|
|
|
i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, |
|
|
|
i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, |
|
|
|
null, false)); |
|
|
|
} |
|
|
|
} else if (el.isUnresolvedElement()) { |
|
|
@@ -163,7 +138,7 @@ public class ElementListUtils { |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Calculates the content length of the given element list. Warning: It doesn't take any |
|
|
|
* stretch and shrink possibilities into account. |
|
|
@@ -193,7 +168,7 @@ public class ElementListUtils { |
|
|
|
} |
|
|
|
return len; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Calculates the content length of the given element list. Warning: It doesn't take any |
|
|
|
* stretch and shrink possibilities into account. |
|
|
@@ -203,7 +178,7 @@ public class ElementListUtils { |
|
|
|
public static int calcContentLength(List elems) { |
|
|
|
return calcContentLength(elems, 0, elems.size() - 1); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Indicates whether the given element list ends with a forced break. |
|
|
|
* @param elems the element list |
|
|
@@ -213,7 +188,7 @@ public class ElementListUtils { |
|
|
|
ListElement last = (ListElement)elems.getLast(); |
|
|
|
return last.isForcedBreak(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Determines the position of the previous break before the start index on an |
|
|
|
* element list. |
|
|
@@ -232,5 +207,5 @@ public class ElementListUtils { |
|
|
|
} |
|
|
|
return prevBreak; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |