ASF Bugzilla – Attachment 21979 Details for
Bug 37579
footnotes within tables and listsl get lost
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Updated patch, TableStepper delegating more to ActiveCell
table_list_footnotes.diff (text/plain), 11.67 KB, created by
Vincent Hennebert
on 2008-05-19 02:56:57 UTC
(
hide
)
Description:
Updated patch, TableStepper delegating more to ActiveCell
Filename:
MIME Type:
Creator:
Vincent Hennebert
Created:
2008-05-19 02:56:57 UTC
Size:
11.67 KB
patch
obsolete
>Index: src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java >=================================================================== >--- src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (revision 657749) >+++ src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (working copy) >@@ -40,11 +40,13 @@ > import org.apache.fop.layoutmgr.ElementListUtils; > import org.apache.fop.layoutmgr.KeepUtil; > 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; > import org.apache.fop.layoutmgr.LayoutContext; > import org.apache.fop.layoutmgr.LayoutManager; >+import org.apache.fop.layoutmgr.ListElement; > import org.apache.fop.layoutmgr.NonLeafPosition; > import org.apache.fop.layoutmgr.Position; > import org.apache.fop.layoutmgr.PositionIterator; >@@ -264,11 +266,14 @@ > private LinkedList getCombinedKnuthElementsForListItem(LinkedList labelElements, > LinkedList bodyElements, > LayoutContext context) { >- //Copy elements to array lists to improve element access performance >- List[] elementLists = {new ArrayList(labelElements), >- new ArrayList(bodyElements)}; >- int[] fullHeights = {ElementListUtils.calcContentLength(elementLists[0]), >- ElementListUtils.calcContentLength(elementLists[1])}; >+ //Copy elements to arrays to improve element access performance >+ ListElement[][] elementLists = new ListElement[2][]; >+ elementLists[0] = (ListElement[])labelElements.toArray(new ListElement[1]); >+ elementLists[1] = (ListElement[])bodyElements.toArray(new ListElement[1]); >+ >+ int[] fullHeights = { >+ ElementListUtils.calcContentLength(labelElements), >+ ElementListUtils.calcContentLength(bodyElements)}; > int[] partialHeights = {0, 0}; > int[] start = {-1, -1}; > int[] end = {-1, -1}; >@@ -282,10 +287,10 @@ > while ((step = getNextStep(elementLists, start, end, partialHeights)) > > 0) { > >- if (end[0] + 1 == elementLists[0].size()) { >+ if (end[0] + 1 == elementLists[0].length) { > keepWithNextActive = Math.max(keepWithNextActive, keepWithNextPendingOnLabel); > } >- if (end[1] + 1 == elementLists[1].size()) { >+ if (end[1] + 1 == elementLists[1].length) { > keepWithNextActive = Math.max(keepWithNextActive, keepWithNextPendingOnBody); > } > >@@ -297,12 +302,12 @@ > //Additional penalty height from penalties in the source lists > int additionalPenaltyHeight = 0; > int stepPenalty = 0; >- KnuthElement endEl = (KnuthElement)elementLists[0].get(end[0]); >+ KnuthElement endEl = (KnuthElement)elementLists[0][end[0]]; > if (endEl instanceof KnuthPenalty) { > additionalPenaltyHeight = endEl.getW(); > stepPenalty = Math.max(stepPenalty, endEl.getP()); > } >- endEl = (KnuthElement)elementLists[1].get(end[1]); >+ endEl = (KnuthElement)elementLists[1][end[1]]; > if (endEl instanceof KnuthPenalty) { > additionalPenaltyHeight = Math.max( > additionalPenaltyHeight, endEl.getW()); >@@ -312,11 +317,32 @@ > int boxHeight = step - addedBoxHeight - penaltyHeight; > penaltyHeight += additionalPenaltyHeight; //Add AFTER calculating boxHeight! > >+ // collect footnote information >+ LinkedList footnoteList = null; >+ ListElement el; >+ for (int i = 0; i < elementLists.length; i ++) { >+ for (int j = start[i]; j <= end[i]; j ++) { >+ el = elementLists[i][j]; >+ if (el instanceof KnuthBlockBox >+ && ((KnuthBlockBox) el).hasAnchors()) { >+ if (footnoteList == null) { >+ footnoteList = new LinkedList(); >+ } >+ footnoteList.addAll( >+ ((KnuthBlockBox) el).getFootnoteBodyLMs()); >+ } >+ } >+ } >+ > // add the new elements > addedBoxHeight += boxHeight; >- ListItemPosition stepPosition = new ListItemPosition(this, >+ ListItemPosition stepPosition = new ListItemPosition(this, > start[0], end[0], start[1], end[1]); >- returnList.add(new KnuthBox(boxHeight, stepPosition, false)); >+ if (footnoteList == null) { >+ returnList.add(new KnuthBox(boxHeight, stepPosition, false)); >+ } else { >+ returnList.add(new KnuthBlockBox(boxHeight, footnoteList, stepPosition, false)); >+ } > if (addedBoxHeight < totalHeight) { > int strength = BlockLevelLayoutManager.KEEP_AUTO; > strength = Math.max(strength, keepWithNextActive); >@@ -332,7 +358,7 @@ > return returnList; > } > >- private int getNextStep(List[] elementLists, int[] start, int[] end, int[] partialHeights) { >+ private int getNextStep(ListElement[][] elementLists, int[] start, int[] end, int[] partialHeights) { > // backup of partial heights > int[] backupHeights = {partialHeights[0], partialHeights[1]}; > >@@ -343,9 +369,9 @@ > // 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()) { >+ while (end[i] + 1 < elementLists[i].length) { > end[i]++; >- KnuthElement el = (KnuthElement)elementLists[i].get(end[i]); >+ KnuthElement el = (KnuthElement)elementLists[i][end[i]]; > if (el.isPenalty()) { > if (el.getP() < KnuthElement.INFINITE) { > //First legal break point >@@ -353,7 +379,7 @@ > } > } else if (el.isGlue()) { > if (end[i] > 0) { >- KnuthElement prev = (KnuthElement)elementLists[i].get(end[i] - 1); >+ KnuthElement prev = (KnuthElement)elementLists[i][end[i] - 1]; > if (prev.isBox()) { > //Second legal break point > break; >Index: src/java/org/apache/fop/layoutmgr/table/ActiveCell.java >=================================================================== >--- src/java/org/apache/fop/layoutmgr/table/ActiveCell.java (revision 657749) >+++ src/java/org/apache/fop/layoutmgr/table/ActiveCell.java (working copy) >@@ -19,12 +19,12 @@ > > package org.apache.fop.layoutmgr.table; > >+import java.util.LinkedList; > import java.util.List; > import java.util.ListIterator; > > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; >- > import org.apache.fop.fo.Constants; > import org.apache.fop.fo.flow.table.ConditionalBorder; > import org.apache.fop.fo.flow.table.EffRow; >@@ -32,6 +32,7 @@ > import org.apache.fop.fo.properties.CommonBorderPaddingBackground; > import org.apache.fop.layoutmgr.BlockLevelLayoutManager; > import org.apache.fop.layoutmgr.ElementListUtils; >+import org.apache.fop.layoutmgr.KnuthBlockBox; > import org.apache.fop.layoutmgr.KnuthBox; > import org.apache.fop.layoutmgr.KnuthElement; > import org.apache.fop.layoutmgr.KnuthPenalty; >@@ -101,6 +102,8 @@ > private int penaltyLength; > /** Value of the penalty ending this step, 0 if the step does not end on a penalty. */ > private int penaltyValue; >+ /** List of footnotes for this step. */ >+ private List footnoteList; > /** > * One of {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN}, > * {@link Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE}, >@@ -130,6 +133,7 @@ > this.totalLength = other.totalLength; > this.penaltyLength = other.penaltyLength; > this.penaltyValue = other.penaltyValue; >+ this.footnoteList = other.footnoteList; > this.condBeforeContentLength = other.condBeforeContentLength; > this.breakClass = other.breakClass; > } >@@ -293,6 +297,7 @@ > afterNextStep.penaltyValue = 0; > afterNextStep.condBeforeContentLength = 0; > afterNextStep.breakClass = Constants.EN_AUTO; >+ afterNextStep.footnoteList = null; > boolean breakFound = false; > boolean prevIsBox = false; > boolean boxFound = false; >@@ -322,6 +327,14 @@ > } > prevIsBox = false; > } else { >+ if (el instanceof KnuthBlockBox >+ && ((KnuthBlockBox)el).hasAnchors()) { >+ if (afterNextStep.footnoteList == null) { >+ afterNextStep.footnoteList = new LinkedList(); >+ } >+ afterNextStep.footnoteList.addAll( >+ ((KnuthBlockBox)el).getFootnoteBodyLMs()); >+ } > prevIsBox = true; > boxFound = true; > afterNextStep.contentLength += el.getW(); >@@ -543,6 +556,18 @@ > } > } > >+ /** >+ * Adds the footnotes (if any) that are part of the next step, if this cell >+ * contributes content to the next step. >+ * >+ * @param footnoteList the list to which this cell must add its footnotes >+ */ >+ void addFootnotes(List footnoteList) { >+ if (includedInLastStep() && nextStep.footnoteList != null) { >+ footnoteList.addAll(nextStep.footnoteList); >+ } >+ } >+ > int getKeepWithNextStrength() { > return keepWithNextStrength; > } >Index: src/java/org/apache/fop/layoutmgr/table/TableStepper.java >=================================================================== >--- src/java/org/apache/fop/layoutmgr/table/TableStepper.java (revision 657749) >+++ src/java/org/apache/fop/layoutmgr/table/TableStepper.java (working copy) >@@ -33,6 +33,7 @@ > import org.apache.fop.layoutmgr.BlockLevelLayoutManager; > import org.apache.fop.layoutmgr.BreakElement; > import org.apache.fop.layoutmgr.KeepUtil; >+import org.apache.fop.layoutmgr.KnuthBlockBox; > import org.apache.fop.layoutmgr.KnuthBox; > import org.apache.fop.layoutmgr.KnuthElement; > import org.apache.fop.layoutmgr.KnuthGlue; >@@ -199,12 +200,14 @@ > } > } > >+ LinkedList footnoteList = new LinkedList(); > //Put all involved grid units into a list > List cellParts = new java.util.ArrayList(columnCount); > for (Iterator iter = activeCells.iterator(); iter.hasNext();) { > ActiveCell activeCell = (ActiveCell) iter.next(); > CellPart part = activeCell.createCellPart(); > cellParts.add(part); >+ activeCell.addFootnotes(footnoteList); > } > > //Create elements for step >@@ -217,8 +220,13 @@ > tcpos.setFlag(TableContentPosition.FIRST_IN_ROWGROUP, true); > } > lastTCPos = tcpos; >- returnList.add(new KnuthBox(boxLen, tcpos, false)); > >+ if (footnoteList.isEmpty()) { >+ returnList.add(new KnuthBox(boxLen, tcpos, false)); >+ } else { >+ returnList.add(new KnuthBlockBox(boxLen, footnoteList, tcpos, false)); >+ } >+ > int effPenaltyLen = Math.max(0, penaltyOrGlueLen); > TableHFPenaltyPosition penaltyPos = new TableHFPenaltyPosition(getTableLM()); > if (bodyType == TableRowIterator.BODY) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 37579
:
17010
|
17432
|
17433
|
17434
|
21907
|
21908
|
21922
|
21976
|
21977
| 21979 |
23492
|
23561