Lines 40-50
Link Here
|
40 |
import org.apache.fop.layoutmgr.ElementListUtils; |
40 |
import org.apache.fop.layoutmgr.ElementListUtils; |
41 |
import org.apache.fop.layoutmgr.KeepUtil; |
41 |
import org.apache.fop.layoutmgr.KeepUtil; |
42 |
import org.apache.fop.layoutmgr.KnuthBox; |
42 |
import org.apache.fop.layoutmgr.KnuthBox; |
|
|
43 |
import org.apache.fop.layoutmgr.KnuthBlockBox; |
43 |
import org.apache.fop.layoutmgr.KnuthElement; |
44 |
import org.apache.fop.layoutmgr.KnuthElement; |
44 |
import org.apache.fop.layoutmgr.KnuthPenalty; |
45 |
import org.apache.fop.layoutmgr.KnuthPenalty; |
45 |
import org.apache.fop.layoutmgr.KnuthPossPosIter; |
46 |
import org.apache.fop.layoutmgr.KnuthPossPosIter; |
46 |
import org.apache.fop.layoutmgr.LayoutContext; |
47 |
import org.apache.fop.layoutmgr.LayoutContext; |
47 |
import org.apache.fop.layoutmgr.LayoutManager; |
48 |
import org.apache.fop.layoutmgr.LayoutManager; |
|
|
49 |
import org.apache.fop.layoutmgr.ListElement; |
48 |
import org.apache.fop.layoutmgr.NonLeafPosition; |
50 |
import org.apache.fop.layoutmgr.NonLeafPosition; |
49 |
import org.apache.fop.layoutmgr.Position; |
51 |
import org.apache.fop.layoutmgr.Position; |
50 |
import org.apache.fop.layoutmgr.PositionIterator; |
52 |
import org.apache.fop.layoutmgr.PositionIterator; |
Lines 264-274
Link Here
|
264 |
private LinkedList getCombinedKnuthElementsForListItem(LinkedList labelElements, |
266 |
private LinkedList getCombinedKnuthElementsForListItem(LinkedList labelElements, |
265 |
LinkedList bodyElements, |
267 |
LinkedList bodyElements, |
266 |
LayoutContext context) { |
268 |
LayoutContext context) { |
267 |
//Copy elements to array lists to improve element access performance |
269 |
//Copy elements to arrays to improve element access performance |
268 |
List[] elementLists = {new ArrayList(labelElements), |
270 |
ListElement[][] elementLists = new ListElement[2][]; |
269 |
new ArrayList(bodyElements)}; |
271 |
elementLists[0] = (ListElement[])labelElements.toArray(new ListElement[1]); |
270 |
int[] fullHeights = {ElementListUtils.calcContentLength(elementLists[0]), |
272 |
elementLists[1] = (ListElement[])bodyElements.toArray(new ListElement[1]); |
271 |
ElementListUtils.calcContentLength(elementLists[1])}; |
273 |
|
|
|
274 |
int[] fullHeights = { |
275 |
ElementListUtils.calcContentLength(labelElements), |
276 |
ElementListUtils.calcContentLength(bodyElements)}; |
272 |
int[] partialHeights = {0, 0}; |
277 |
int[] partialHeights = {0, 0}; |
273 |
int[] start = {-1, -1}; |
278 |
int[] start = {-1, -1}; |
274 |
int[] end = {-1, -1}; |
279 |
int[] end = {-1, -1}; |
Lines 282-291
Link Here
|
282 |
while ((step = getNextStep(elementLists, start, end, partialHeights)) |
287 |
while ((step = getNextStep(elementLists, start, end, partialHeights)) |
283 |
> 0) { |
288 |
> 0) { |
284 |
|
289 |
|
285 |
if (end[0] + 1 == elementLists[0].size()) { |
290 |
if (end[0] + 1 == elementLists[0].length) { |
286 |
keepWithNextActive = Math.max(keepWithNextActive, keepWithNextPendingOnLabel); |
291 |
keepWithNextActive = Math.max(keepWithNextActive, keepWithNextPendingOnLabel); |
287 |
} |
292 |
} |
288 |
if (end[1] + 1 == elementLists[1].size()) { |
293 |
if (end[1] + 1 == elementLists[1].length) { |
289 |
keepWithNextActive = Math.max(keepWithNextActive, keepWithNextPendingOnBody); |
294 |
keepWithNextActive = Math.max(keepWithNextActive, keepWithNextPendingOnBody); |
290 |
} |
295 |
} |
291 |
|
296 |
|
Lines 297-308
Link Here
|
297 |
//Additional penalty height from penalties in the source lists |
302 |
//Additional penalty height from penalties in the source lists |
298 |
int additionalPenaltyHeight = 0; |
303 |
int additionalPenaltyHeight = 0; |
299 |
int stepPenalty = 0; |
304 |
int stepPenalty = 0; |
300 |
KnuthElement endEl = (KnuthElement)elementLists[0].get(end[0]); |
305 |
KnuthElement endEl = (KnuthElement)elementLists[0][end[0]]; |
301 |
if (endEl instanceof KnuthPenalty) { |
306 |
if (endEl instanceof KnuthPenalty) { |
302 |
additionalPenaltyHeight = endEl.getW(); |
307 |
additionalPenaltyHeight = endEl.getW(); |
303 |
stepPenalty = Math.max(stepPenalty, endEl.getP()); |
308 |
stepPenalty = Math.max(stepPenalty, endEl.getP()); |
304 |
} |
309 |
} |
305 |
endEl = (KnuthElement)elementLists[1].get(end[1]); |
310 |
endEl = (KnuthElement)elementLists[1][end[1]]; |
306 |
if (endEl instanceof KnuthPenalty) { |
311 |
if (endEl instanceof KnuthPenalty) { |
307 |
additionalPenaltyHeight = Math.max( |
312 |
additionalPenaltyHeight = Math.max( |
308 |
additionalPenaltyHeight, endEl.getW()); |
313 |
additionalPenaltyHeight, endEl.getW()); |
Lines 312-322
Link Here
|
312 |
int boxHeight = step - addedBoxHeight - penaltyHeight; |
317 |
int boxHeight = step - addedBoxHeight - penaltyHeight; |
313 |
penaltyHeight += additionalPenaltyHeight; //Add AFTER calculating boxHeight! |
318 |
penaltyHeight += additionalPenaltyHeight; //Add AFTER calculating boxHeight! |
314 |
|
319 |
|
|
|
320 |
// collect footnote information |
321 |
LinkedList footnoteList = null; |
322 |
ListElement el; |
323 |
for (int i = 0; i < elementLists.length; i ++) { |
324 |
for (int j = start[i]; j <= end[i]; j ++) { |
325 |
el = elementLists[i][j]; |
326 |
if (el instanceof KnuthBlockBox |
327 |
&& ((KnuthBlockBox) el).hasAnchors()) { |
328 |
if (footnoteList == null) { |
329 |
footnoteList = new LinkedList(); |
330 |
} |
331 |
footnoteList.addAll( |
332 |
((KnuthBlockBox) el).getFootnoteBodyLMs()); |
333 |
} |
334 |
} |
335 |
} |
336 |
|
315 |
// add the new elements |
337 |
// add the new elements |
316 |
addedBoxHeight += boxHeight; |
338 |
addedBoxHeight += boxHeight; |
317 |
ListItemPosition stepPosition = new ListItemPosition(this, |
339 |
ListItemPosition stepPosition = new ListItemPosition(this, |
318 |
start[0], end[0], start[1], end[1]); |
340 |
start[0], end[0], start[1], end[1]); |
319 |
returnList.add(new KnuthBox(boxHeight, stepPosition, false)); |
341 |
if (footnoteList == null) { |
|
|
342 |
returnList.add(new KnuthBox(boxHeight, stepPosition, false)); |
343 |
} else { |
344 |
returnList.add(new KnuthBlockBox(boxHeight, footnoteList, stepPosition, false)); |
345 |
} |
320 |
if (addedBoxHeight < totalHeight) { |
346 |
if (addedBoxHeight < totalHeight) { |
321 |
int strength = BlockLevelLayoutManager.KEEP_AUTO; |
347 |
int strength = BlockLevelLayoutManager.KEEP_AUTO; |
322 |
strength = Math.max(strength, keepWithNextActive); |
348 |
strength = Math.max(strength, keepWithNextActive); |
Lines 332-338
Link Here
|
332 |
return returnList; |
358 |
return returnList; |
333 |
} |
359 |
} |
334 |
|
360 |
|
335 |
private int getNextStep(List[] elementLists, int[] start, int[] end, int[] partialHeights) { |
361 |
private int getNextStep(ListElement[][] elementLists, int[] start, int[] end, int[] partialHeights) { |
336 |
// backup of partial heights |
362 |
// backup of partial heights |
337 |
int[] backupHeights = {partialHeights[0], partialHeights[1]}; |
363 |
int[] backupHeights = {partialHeights[0], partialHeights[1]}; |
338 |
|
364 |
|
Lines 343-351
Link Here
|
343 |
// get next possible sequence for label and body |
369 |
// get next possible sequence for label and body |
344 |
int seqCount = 0; |
370 |
int seqCount = 0; |
345 |
for (int i = 0; i < start.length; i++) { |
371 |
for (int i = 0; i < start.length; i++) { |
346 |
while (end[i] + 1 < elementLists[i].size()) { |
372 |
while (end[i] + 1 < elementLists[i].length) { |
347 |
end[i]++; |
373 |
end[i]++; |
348 |
KnuthElement el = (KnuthElement)elementLists[i].get(end[i]); |
374 |
KnuthElement el = (KnuthElement)elementLists[i][end[i]]; |
349 |
if (el.isPenalty()) { |
375 |
if (el.isPenalty()) { |
350 |
if (el.getP() < KnuthElement.INFINITE) { |
376 |
if (el.getP() < KnuthElement.INFINITE) { |
351 |
//First legal break point |
377 |
//First legal break point |
Lines 353-359
Link Here
|
353 |
} |
379 |
} |
354 |
} else if (el.isGlue()) { |
380 |
} else if (el.isGlue()) { |
355 |
if (end[i] > 0) { |
381 |
if (end[i] > 0) { |
356 |
KnuthElement prev = (KnuthElement)elementLists[i].get(end[i] - 1); |
382 |
KnuthElement prev = (KnuthElement)elementLists[i][end[i] - 1]; |
357 |
if (prev.isBox()) { |
383 |
if (prev.isBox()) { |
358 |
//Second legal break point |
384 |
//Second legal break point |
359 |
break; |
385 |
break; |