Index: src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java =================================================================== --- src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (Revision 368630) +++ src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (Arbeitskopie) @@ -37,6 +37,7 @@ import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthBox; +import org.apache.fop.layoutmgr.KnuthBlockBox; import org.apache.fop.layoutmgr.KnuthPenalty; import org.apache.fop.layoutmgr.KnuthPossPosIter; import org.apache.fop.area.Area; @@ -62,6 +63,7 @@ private LinkedList labelList = null; private LinkedList bodyList = null; + private LinkedList footnoteList; private int listItemHeight; @@ -221,7 +223,7 @@ // "wrap" the Position inside each element wrapPositionElements(returnedList, returnList, true); - + addKnuthElementsForSpaceAfter(returnList, alignment); if (keepWithNextPendingOnLabel || keepWithNextPendingOnBody || mustKeepWithNext()) { @@ -256,7 +258,7 @@ LinkedList returnList = new LinkedList(); while ((step = getNextStep(elementLists, start, end, partialHeights)) > 0) { - + if (end[0] + 1 == elementLists[0].size()) { if (keepWithNextPendingOnLabel) { keepWithNextActive = true; @@ -278,7 +280,12 @@ addedBoxHeight += boxHeight; ListItemPosition stepPosition = new ListItemPosition(this, start[0], end[0], start[1], end[1]); - returnList.add(new KnuthBox(boxHeight, stepPosition, false)); + if (footnoteList.size() > 0) { + returnList.add(new KnuthBlockBox(boxHeight, footnoteList, stepPosition, false)); + } else { + returnList.add(new KnuthBox(boxHeight, stepPosition, false)); + } + footnoteList = null; if (addedBoxHeight < totalHeight) { int p = 0; if (keepWithNextActive || mustKeepTogether()) { @@ -300,12 +307,23 @@ start[0] = end[0] + 1; start[1] = end[1] + 1; + // empty list for footnote-transport + footnoteList = new LinkedList(); + // get next possible sequence for label and body int seqCount = 0; for (int i = 0; i < start.length; i++) { while (end[i] + 1 < elementLists[i].size()) { end[i]++; KnuthElement el = (KnuthElement)elementLists[i].get(end[i]); + + // receive footnotes + if (el instanceof KnuthBlockBox) { + if (((KnuthBlockBox)el).hasAnchors()) { + footnoteList.addAll(((KnuthBlockBox)el).getFootnoteBodyLMs()); + } + } + if (el.isPenalty()) { if (el.getP() < KnuthElement.INFINITE) { //First legal break point Index: src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java =================================================================== --- src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (Revision 368630) +++ src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (Arbeitskopie) @@ -41,6 +41,7 @@ import org.apache.fop.layoutmgr.ElementListObserver; import org.apache.fop.layoutmgr.ElementListUtils; import org.apache.fop.layoutmgr.KnuthBox; +import org.apache.fop.layoutmgr.KnuthBlockBox; import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthPenalty; import org.apache.fop.layoutmgr.KnuthPossPosIter; @@ -139,6 +140,9 @@ KnuthBox headerAsFirst = null; KnuthBox headerAsSecondToLast = null; KnuthBox footerAsLast = null; + LinkedList footnoteList; + Iterator iter; + ListElement el; if (headerIter != null && headerList == null) { this.headerList = getKnuthElementsForRowIterator( headerIter, context, alignment, TableRowIterator.HEADER); @@ -149,7 +153,24 @@ } TableHeaderFooterPosition pos = new TableHeaderFooterPosition( getTableLM(), true, this.headerList); - KnuthBox box = new KnuthBox(headerNetHeight, pos, false); + // preserve footnotes + footnoteList = new LinkedList(); + iter = this.headerList.iterator(); + while (iter.hasNext()) { + el = (ListElement)iter.next(); + if (el instanceof KnuthBlockBox) { + if (((KnuthBlockBox)el).hasAnchors()) { + footnoteList.addAll(((KnuthBlockBox)el).getFootnoteBodyLMs()); + } + } + } + KnuthBox box; + if (footnoteList.size() > 0) { + box = (KnuthBox)(new KnuthBlockBox(headerNetHeight, footnoteList, pos, false)); + } else { + box = new KnuthBox(headerNetHeight, pos, false); + } + footnoteList = null; if (getTableLM().getTable().omitHeaderAtBreak()) { //We can simply add the table header at the beginning of the whole list headerAsFirst = box; @@ -169,7 +190,24 @@ //We can simply add the table header at the end of the whole list TableHeaderFooterPosition pos = new TableHeaderFooterPosition( getTableLM(), false, this.footerList); - KnuthBox box = new KnuthBox(footerNetHeight, pos, false); + // preserve footnotes + footnoteList = new LinkedList(); + iter = this.footerList.iterator(); + while (iter.hasNext()) { + el = (ListElement)iter.next(); + if (el instanceof KnuthBlockBox) { + if (((KnuthBlockBox)el).hasAnchors()) { + footnoteList.addAll(((KnuthBlockBox)el).getFootnoteBodyLMs()); + } + } + } + KnuthBox box; + if (footnoteList.size() > 0) { + box = (KnuthBox) new KnuthBlockBox(footerNetHeight, footnoteList, pos, false); + } else { + box = new KnuthBox(footerNetHeight, pos, false); + } + footnoteList = null; footerAsLast = box; } } Index: src/java/org/apache/fop/layoutmgr/table/TableStepper.java =================================================================== --- src/java/org/apache/fop/layoutmgr/table/TableStepper.java (Revision 368630) +++ src/java/org/apache/fop/layoutmgr/table/TableStepper.java (Arbeitskopie) @@ -30,6 +30,7 @@ import org.apache.fop.layoutmgr.BreakElement; import org.apache.fop.layoutmgr.ElementListUtils; import org.apache.fop.layoutmgr.KnuthBox; +import org.apache.fop.layoutmgr.KnuthBlockBox; import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthPenalty; import org.apache.fop.layoutmgr.LayoutContext; @@ -64,6 +65,7 @@ private boolean skippedStep; private boolean[] keepWithNextSignals; private boolean[] forcedBreaks; + private LinkedList footnoteList; /** * Main constructor @@ -315,7 +317,14 @@ log.debug(" - backtrack=" + rowBacktrackForLastStep + " - row=" + activeRow + " - " + tcpos); } - returnList.add(new KnuthBox(boxLen, tcpos, false)); + + if (footnoteList.size() > 0) { + returnList.add(new KnuthBlockBox(boxLen, footnoteList, tcpos, false)); + } else { + returnList.add(new KnuthBox(boxLen, tcpos, false)); + } + footnoteList = null; + TableHFPenaltyPosition penaltyPos = new TableHFPenaltyPosition(getTableLM()); if (bodyType == TableRowIterator.BODY) { if (!getTableLM().getTable().omitHeaderAtBreak()) { @@ -441,6 +450,9 @@ } } + // empty list for footnote-transport + footnoteList = new LinkedList(); + //Get next possible sequence for each cell int seqCount = 0; for (int i = 0; i < start.length; i++) { @@ -450,6 +462,12 @@ while (end[i] + 1 < elementLists[i].size()) { end[i]++; KnuthElement el = (KnuthElement)elementLists[i].get(end[i]); + // receive footnotes + if (el instanceof KnuthBlockBox) { + if (((KnuthBlockBox)el).hasAnchors()) { + footnoteList.addAll(((KnuthBlockBox)el).getFootnoteBodyLMs()); + } + } if (el.isPenalty()) { if (el.getP() <= -KnuthElement.INFINITE) { log.debug("FORCED break encountered!");