Add conditionals notification for content nestes in list-items. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_SpaceResolution@321073 13f79535-47bb-0310-9956-ffa450edef68Temp_SpaceResolution
@@ -379,7 +379,7 @@ public abstract class AbstractBreaker { | |||
/* *** *** non-standard extension *** *** */ | |||
// Handle SpaceHandling(Break)Positions, see SpaceResolver! | |||
performConditionalsNotification(effectiveList, | |||
SpaceResolver.performConditionalsNotification(effectiveList, | |||
startElementIndex, endElementIndex, lastBreak); | |||
// Add areas now! | |||
@@ -404,43 +404,6 @@ public abstract class AbstractBreaker { | |||
* @param endElementIndex end index of the part | |||
* @param lastBreak index of the last break element | |||
*/ | |||
private void performConditionalsNotification(BlockSequence effectiveList, | |||
int startElementIndex, int endElementIndex, int lastBreak) { | |||
KnuthElement el = null; | |||
if (lastBreak > 0) { | |||
el = effectiveList.getElement(lastBreak); | |||
} | |||
SpaceResolver.SpaceHandlingBreakPosition beforeBreak = null; | |||
SpaceResolver.SpaceHandlingBreakPosition afterBreak = null; | |||
if (el != null && el.isPenalty()) { | |||
Position pos = el.getPosition(); | |||
if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) { | |||
beforeBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; | |||
beforeBreak.notifyBreakSituation(true, RelSide.BEFORE); | |||
} | |||
} | |||
el = effectiveList.getElement(endElementIndex); | |||
if (el != null && el.isPenalty()) { | |||
Position pos = el.getPosition(); | |||
if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) { | |||
afterBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; | |||
afterBreak.notifyBreakSituation(true, RelSide.AFTER); | |||
} | |||
} | |||
for (int i = startElementIndex; i <= endElementIndex; i++) { | |||
Position pos = effectiveList.getElement(i).getPosition(); | |||
if (pos instanceof SpaceResolver.SpaceHandlingPosition) { | |||
((SpaceResolver.SpaceHandlingPosition)pos).notifySpaceSituation(); | |||
} else if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) { | |||
SpaceResolver.SpaceHandlingBreakPosition noBreak; | |||
noBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; | |||
if (noBreak != beforeBreak && noBreak != afterBreak) { | |||
noBreak.notifyBreakSituation(false, null); | |||
} | |||
} | |||
} | |||
} | |||
/** | |||
* Handles span changes reported through the <code>LayoutContext</code>. | |||
* Only used by the PSLM and called by <code>getNextBlockList()</code>. |
@@ -631,5 +631,53 @@ public class SpaceResolver { | |||
first = false; | |||
} | |||
} | |||
/** | |||
* Inspects an effective element list and notifies all layout managers about the state of | |||
* the spaces and conditional lengths. | |||
* @param effectiveList the effective element list | |||
* @param startElementIndex index of the first element in the part to be processed | |||
* @param endElementIndex index of the last element in the part to be processed | |||
* @param lastBreak index of the the break possibility just before this part (used to | |||
* identify a break condition, lastBreak <= 0 represents a no-break condition) | |||
*/ | |||
public static void performConditionalsNotification(List effectiveList, | |||
int startElementIndex, int endElementIndex, int lastBreak) { | |||
KnuthElement el = null; | |||
if (lastBreak > 0) { | |||
el = (KnuthElement)effectiveList.get(lastBreak); | |||
} | |||
SpaceResolver.SpaceHandlingBreakPosition beforeBreak = null; | |||
SpaceResolver.SpaceHandlingBreakPosition afterBreak = null; | |||
if (el != null && el.isPenalty()) { | |||
Position pos = el.getPosition(); | |||
if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) { | |||
beforeBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; | |||
beforeBreak.notifyBreakSituation(true, RelSide.BEFORE); | |||
} | |||
} | |||
el = (KnuthElement)effectiveList.get(endElementIndex); | |||
if (el != null && el.isPenalty()) { | |||
Position pos = el.getPosition(); | |||
if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) { | |||
afterBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; | |||
afterBreak.notifyBreakSituation(true, RelSide.AFTER); | |||
} | |||
} | |||
for (int i = startElementIndex; i <= endElementIndex; i++) { | |||
Position pos = ((KnuthElement)effectiveList.get(i)).getPosition(); | |||
if (pos instanceof SpaceResolver.SpaceHandlingPosition) { | |||
((SpaceResolver.SpaceHandlingPosition)pos).notifySpaceSituation(); | |||
} else if (pos instanceof SpaceResolver.SpaceHandlingBreakPosition) { | |||
SpaceResolver.SpaceHandlingBreakPosition noBreak; | |||
noBreak = (SpaceResolver.SpaceHandlingBreakPosition)pos; | |||
if (noBreak != beforeBreak && noBreak != afterBreak) { | |||
noBreak.notifyBreakSituation(false, null); | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -470,6 +470,31 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager | |||
int bodyFirstIndex = ((ListItemPosition) positionList.getFirst()).getBodyFirstIndex(); | |||
int bodyLastIndex = ((ListItemPosition) positionList.getLast()).getBodyLastIndex(); | |||
int lastBreak; | |||
//Determine last break if any | |||
lastBreak = labelFirstIndex - 1; | |||
while (lastBreak >= 0) { | |||
KnuthElement el = (KnuthElement)labelList.get(lastBreak); | |||
if (el.isPenalty() && el.getP() < KnuthElement.INFINITE) { | |||
break; | |||
} | |||
lastBreak--; | |||
} | |||
SpaceResolver.performConditionalsNotification(labelList, | |||
labelFirstIndex, labelLastIndex, lastBreak); | |||
//Determine last break if any | |||
lastBreak = bodyFirstIndex - 1; | |||
while (lastBreak >= 0) { | |||
KnuthElement el = (KnuthElement)bodyList.get(lastBreak); | |||
if (el.isPenalty() && el.getP() < KnuthElement.INFINITE) { | |||
break; | |||
} | |||
lastBreak--; | |||
} | |||
SpaceResolver.performConditionalsNotification(bodyList, | |||
bodyFirstIndex, bodyLastIndex, lastBreak); | |||
// add label areas | |||
if (labelFirstIndex <= labelLastIndex) { | |||
KnuthPossPosIter labelIter = new KnuthPossPosIter(labelList, |
@@ -17,7 +17,6 @@ inline_word-spacing_text-align_justify.xml | |||
leader-alignment.xml | |||
list-block_keep-with-previous.xml | |||
list-item_block_keep-with-previous.xml | |||
list-item_space-before_space-after_3.xml | |||
page-breaking_4.xml | |||
page-breaking_6.xml | |||
page-height_indefinite_simple.xml |