View | Details | Raw Unified | Return to bug 37579
Collapse All | Expand All

(-)src/java/org/apache/fop/layoutmgr/ElementListUtils.java (+38 lines)
Lines 225-228 Link Here
225
        return prevBreak;
225
        return prevBreak;
226
    }
226
    }
227
227
228
    /**
229
     * Scan element lists and collect footnotes information.
230
     * @param elementLists the array of element lists
231
     * @param start the array of start indices
232
     * @param end the array of end indices
233
     * @return the list of FootnoteBodyLMs met, or null if there is none
234
     */
235
    public static LinkedList collectFootnoteBodyLMs(List[] elementLists, int[] start, int[] end) {
236
        LinkedList footnoteList = new LinkedList();
237
238
        for (int i = 0; i < elementLists.length; i ++) {
239
            for (int j = start[i]; j <= end[i]; j ++) {
240
                ListElement element = (ListElement) elementLists[i].get(j);
241
                if (element instanceof KnuthBlockBox
242
                    && ((KnuthBlockBox) element).hasAnchors()) {
243
                    footnoteList.addAll(((KnuthBlockBox) element).getFootnoteBodyLMs());
244
                }
245
            }
246
        }
247
248
        return footnoteList.size() > 0 ? footnoteList : null;
249
    }
250
251
    /**
252
     * Scan a single element list and collect footnotes information.
253
     * @param elementList the element lists
254
     * @param start the start index
255
     * @param end the end index
256
     * @return the list of FootnoteBodyLMs met, or null if there is none
257
     */
258
    public static LinkedList collectFootnoteBodyLMs(List elementList, int start, int end) {
259
        List[] listArray = {elementList};
260
        int[] startArray = {start};
261
        int[] endArray = {end};
262
                                
263
        return collectFootnoteBodyLMs(listArray, startArray, endArray);
264
    }
265
228
}
266
}
(-)src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (-1 / +10 lines)
Lines 39-50 Link Here
39
import org.apache.fop.layoutmgr.ElementListObserver;
39
import org.apache.fop.layoutmgr.ElementListObserver;
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.KnuthBlockBox;
42
import org.apache.fop.layoutmgr.KnuthBox;
43
import org.apache.fop.layoutmgr.KnuthBox;
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 312-322 Link Here
312
            int boxHeight = step - addedBoxHeight - penaltyHeight;
314
            int boxHeight = step - addedBoxHeight - penaltyHeight;
313
            penaltyHeight += additionalPenaltyHeight; //Add AFTER calculating boxHeight!
315
            penaltyHeight += additionalPenaltyHeight; //Add AFTER calculating boxHeight!
314
316
317
            // collect footnote information
318
            LinkedList footnoteList = ElementListUtils.collectFootnoteBodyLMs(elementLists, start, end);
319
315
            // add the new elements
320
            // add the new elements
316
            addedBoxHeight += boxHeight;
321
            addedBoxHeight += boxHeight;
317
            ListItemPosition stepPosition = new ListItemPosition(this, 
322
            ListItemPosition stepPosition = new ListItemPosition(this, 
318
                    start[0], end[0], start[1], end[1]);
323
                    start[0], end[0], start[1], end[1]);
319
            returnList.add(new KnuthBox(boxHeight, stepPosition, false));
324
            if (footnoteList == null) {
325
                returnList.add(new KnuthBox(boxHeight, stepPosition, false));
326
            } else {
327
                returnList.add(new KnuthBlockBox(boxHeight, footnoteList, stepPosition, false));
328
            }
320
            if (addedBoxHeight < totalHeight) {
329
            if (addedBoxHeight < totalHeight) {
321
                int strength = BlockLevelLayoutManager.KEEP_AUTO;
330
                int strength = BlockLevelLayoutManager.KEEP_AUTO;
322
                strength = Math.max(strength, keepWithNextActive);
331
                strength = Math.max(strength, keepWithNextActive);
(-)src/java/org/apache/fop/layoutmgr/table/ActiveCell.java (-1 / +8 lines)
Lines 541-548 Link Here
541
    int getKeepWithNextStrength() {
541
    int getKeepWithNextStrength() {
542
        return keepWithNextStrength;
542
        return keepWithNextStrength;
543
    }
543
    }
544
545
    
544
    
545
    /**
546
     * Return the list of elements representing the content of this cell.
547
     * @return the list of elements
548
     */
549
    public List getElementList(){
550
        return elementList;
551
    }
552
    
546
    /** {@inheritDoc} */
553
    /** {@inheritDoc} */
547
    public String toString() {
554
    public String toString() {
548
        return "Cell " + (pgu.getRowIndex() + 1) + "." + (pgu.getColIndex() + 1);
555
        return "Cell " + (pgu.getRowIndex() + 1) + "." + (pgu.getColIndex() + 1);
(-)src/java/org/apache/fop/layoutmgr/table/CellPart.java (+16 lines)
Lines 115-120 Link Here
115
    int getConditionalAfterContentLength() {
115
    int getConditionalAfterContentLength() {
116
        return condAfterContentLength;
116
        return condAfterContentLength;
117
    }
117
    }
118
    
119
    /**
120
     * Return the index of the first element in this cell part.
121
     * @return the start index
122
     */
123
    public int getStartIndex() {
124
        return start;
125
    }
126
    
127
    /**
128
     * Return the index of the last element in this cell part.
129
     * @return the end index
130
     */
131
    public int getEndIndex() {
132
        return end;
133
    }
118
134
119
    /** {@inheritDoc} */
135
    /** {@inheritDoc} */
120
    public String toString() {
136
    public String toString() {
(-)src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (-2 / +17 lines)
Lines 39-44 Link Here
39
import org.apache.fop.layoutmgr.BreakElement;
39
import org.apache.fop.layoutmgr.BreakElement;
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.KnuthBlockBox;
42
import org.apache.fop.layoutmgr.KnuthBox;
43
import org.apache.fop.layoutmgr.KnuthBox;
43
import org.apache.fop.layoutmgr.KnuthElement;
44
import org.apache.fop.layoutmgr.KnuthElement;
44
import org.apache.fop.layoutmgr.KnuthPossPosIter;
45
import org.apache.fop.layoutmgr.KnuthPossPosIter;
Lines 146-152 Link Here
146
            }
147
            }
147
            TableHeaderFooterPosition pos = new TableHeaderFooterPosition(
148
            TableHeaderFooterPosition pos = new TableHeaderFooterPosition(
148
                    getTableLM(), true, this.headerList);
149
                    getTableLM(), true, this.headerList);
149
            KnuthBox box = new KnuthBox(headerNetHeight, pos, false);
150
            // collect footnote information
151
            LinkedList footnoteList = ElementListUtils.collectFootnoteBodyLMs(headerList, 0, headerList.size() - 1);
152
            KnuthBox box = null;
153
            if (footnoteList == null) {
154
                box = new KnuthBox(headerNetHeight, pos, false);
155
            } else {
156
                box = new KnuthBlockBox(headerNetHeight, footnoteList, pos, false);
157
            }
150
            if (getTableLM().getTable().omitHeaderAtBreak()) {
158
            if (getTableLM().getTable().omitHeaderAtBreak()) {
151
                //We can simply add the table header at the start 
159
                //We can simply add the table header at the start 
152
                //of the whole list
160
                //of the whole list
Lines 167-173 Link Here
167
            //We can simply add the table footer at the end of the whole list
175
            //We can simply add the table footer at the end of the whole list
168
            TableHeaderFooterPosition pos = new TableHeaderFooterPosition(
176
            TableHeaderFooterPosition pos = new TableHeaderFooterPosition(
169
                    getTableLM(), false, this.footerList);
177
                    getTableLM(), false, this.footerList);
170
            KnuthBox box = new KnuthBox(footerNetHeight, pos, false);
178
            // collect footnote information
179
            LinkedList footnoteList = ElementListUtils.collectFootnoteBodyLMs(footerList, 0, footerList.size() - 1);
180
            KnuthBox box = null;
181
            if (footnoteList == null) {
182
                box = new KnuthBox(footerNetHeight, pos, false);
183
            } else {
184
                box = new KnuthBlockBox(footerNetHeight, footnoteList, pos, false);
185
            }
171
            footerAsLast = box;
186
            footerAsLast = box;
172
        }
187
        }
173
        LinkedList returnList = getKnuthElementsForRowIterator(
188
        LinkedList returnList = getKnuthElementsForRowIterator(
(-)src/java/org/apache/fop/layoutmgr/table/TableStepper.java (-1 / +20 lines)
Lines 32-38 Link Here
32
import org.apache.fop.fo.flow.table.PrimaryGridUnit;
32
import org.apache.fop.fo.flow.table.PrimaryGridUnit;
33
import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
33
import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
34
import org.apache.fop.layoutmgr.BreakElement;
34
import org.apache.fop.layoutmgr.BreakElement;
35
import org.apache.fop.layoutmgr.ElementListUtils;
35
import org.apache.fop.layoutmgr.KeepUtil;
36
import org.apache.fop.layoutmgr.KeepUtil;
37
import org.apache.fop.layoutmgr.KnuthBlockBox;
36
import org.apache.fop.layoutmgr.KnuthBox;
38
import org.apache.fop.layoutmgr.KnuthBox;
37
import org.apache.fop.layoutmgr.KnuthElement;
39
import org.apache.fop.layoutmgr.KnuthElement;
38
import org.apache.fop.layoutmgr.KnuthGlue;
40
import org.apache.fop.layoutmgr.KnuthGlue;
Lines 226-232 Link Here
226
                tcpos.setFlag(TableContentPosition.FIRST_IN_ROWGROUP, true);
228
                tcpos.setFlag(TableContentPosition.FIRST_IN_ROWGROUP, true);
227
            }
229
            }
228
            lastTCPos = tcpos;
230
            lastTCPos = tcpos;
229
            returnList.add(new KnuthBox(boxLen, tcpos, false));
231
            
232
            // collect footnote information
233
            List[] elementLists = new LinkedList[columnCount];
234
            int[] start = new int[columnCount];
235
            int[] end = new int[columnCount];
236
            for (int i = 0; i < columnCount; i ++) {
237
                elementLists[i] = ((ActiveCell) activeCells.get(i)).getElementList();
238
                CellPart part = (CellPart) cellParts.get(i);
239
                start[i] = part.getStartIndex();
240
                end[i] = part.getEndIndex();
241
            }
242
            LinkedList footnoteList = ElementListUtils.collectFootnoteBodyLMs(elementLists, start, end);
243
            
244
            if (footnoteList == null) {
245
                returnList.add(new KnuthBox(boxLen, tcpos, false));
246
            } else {
247
                returnList.add(new KnuthBlockBox(boxLen, footnoteList, tcpos, false));
248
            }
230
249
231
            int effPenaltyLen = Math.max(0, penaltyOrGlueLen);
250
            int effPenaltyLen = Math.max(0, penaltyOrGlueLen);
232
            TableHFPenaltyPosition penaltyPos = new TableHFPenaltyPosition(getTableLM());
251
            TableHFPenaltyPosition penaltyPos = new TableHFPenaltyPosition(getTableLM());

Return to bug 37579