Author: vhennebert
Date: Wed Jun 18 09:59:19 2014
New Revision: 1603386
URL: http://svn.apache.org/r1603386
Log:
FOP-1099: when table headers/footers are repeated at page breaks, also repeat
the footnotes they may contain
Added:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/footnote_in_table-heading.xml
- copied, changed from r1603381,
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/footnote_in_table-header.xml
Removed:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/footnote_in_table-header.xml
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootenoteUtil.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootenoteUtil.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootenoteUtil.java?rev=1603386&r1=1603385&r2=1603386&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootenoteUtil.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootenoteUtil.java
Wed Jun 18 09:59:19 2014
@@ -34,7 +34,7 @@ public final class FootenoteUtil {
/**
* Returns the footnotes contained in the given element list.
*/
- public static List<LayoutManager> getFootnotes(List<ListElement>
elemenList) {
+ public static List<FootnoteBodyLayoutManager>
getFootnotes(List<ListElement> elemenList) {
return getFootnotes(elemenList, 0, elemenList.size() - 1);
}
@@ -44,9 +44,10 @@ public final class FootenoteUtil {
* @param startIndex index in the element list from which to start the
scan, inclusive
* @param endIndex index in the element list at which to stop the scan,
inclusive
*/
- public static List<LayoutManager> getFootnotes(List<ListElement>
elemenList, int startIndex, int endIndex) {
+ public static List<FootnoteBodyLayoutManager> getFootnotes(
+ List<ListElement> elemenList, int startIndex, int endIndex) {
ListIterator<ListElement> iter = elemenList.listIterator(startIndex);
- List<LayoutManager> footnotes = null;
+ List<FootnoteBodyLayoutManager> footnotes = null;
while (iter.nextIndex() <= endIndex) {
ListElement element = iter.next();
if (element instanceof KnuthInlineBox && ((KnuthInlineBox)
element).isAnchor()) {
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java?rev=1603386&r1=1603385&r2=1603386&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FootnoteBodyLayoutManager.java
Wed Jun 18 09:59:19 2014
@@ -20,6 +20,7 @@
package org.apache.fop.layoutmgr;
import java.util.LinkedList;
+import java.util.List;
import org.apache.fop.area.Area;
import org.apache.fop.fo.flow.FootnoteBody;
@@ -29,6 +30,8 @@ import org.apache.fop.fo.flow.FootnoteBo
*/
public class FootnoteBodyLayoutManager extends BlockStackingLayoutManager {
+ private List<KnuthElement> knuthElements;
+
/**
* Creates a new FootnoteBodyLayoutManager.
* @param body the footnote-body element
@@ -37,6 +40,14 @@ public class FootnoteBodyLayoutManager e
super(body);
}
+ @Override
+ public List<KnuthElement> getNextKnuthElements(LayoutContext context, int
alignment) {
+ if (knuthElements == null) {
+ knuthElements = super.getNextKnuthElements(context, alignment);
+ }
+ return knuthElements;
+ }
+
/** {@inheritDoc} */
@Override
public void addAreas(PositionIterator parentIter, LayoutContext
layoutContext) {
@@ -108,4 +119,10 @@ public class FootnoteBodyLayoutManager e
return Keep.KEEP_AUTO;
}
+ @Override
+ public void reset() {
+ super.reset();
+ knuthElements = null;
+ }
+
}
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java?rev=1603386&r1=1603385&r2=1603386&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/KnuthBlockBox.java
Wed Jun 18 09:59:19 2014
@@ -35,7 +35,7 @@ public class KnuthBlockBox extends Knuth
* it isn't possible to get the opt value stored in a MinOptMax object.
*/
private int bpd;
- private List footnoteList;
+ private List<FootnoteBodyLayoutManager> footnoteList;
/** List of Knuth elements. This is a list of LinkedList elements. */
private List elementLists = null;
@@ -52,7 +52,7 @@ public class KnuthBlockBox extends Knuth
super(width, pos, auxiliary);
ipdRange = range;
bpd = bpdim;
- footnoteList = new LinkedList();
+ footnoteList = new LinkedList<FootnoteBodyLayoutManager>();
}
/**
@@ -68,13 +68,13 @@ public class KnuthBlockBox extends Knuth
super(width, pos, auxiliary);
ipdRange = MinOptMax.ZERO;
bpd = 0;
- footnoteList = new LinkedList(list);
+ footnoteList = new LinkedList<FootnoteBodyLayoutManager>(list);
}
/**
* @return the LMs for the footnotes cited in this box.
*/
- public List getFootnoteBodyLMs() {
+ public List<FootnoteBodyLayoutManager> getFootnoteBodyLMs() {
return footnoteList;
}
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java?rev=1603386&r1=1603385&r2=1603386&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreaker.java
Wed Jun 18 09:59:19 2014
@@ -19,6 +19,7 @@
package org.apache.fop.layoutmgr;
+import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
@@ -156,7 +157,6 @@ public class PageBreaker extends Abstrac
}
private boolean containsFootnotes(List contentList, LayoutContext context)
{
-
boolean containsFootnotes = false;
if (contentList != null) {
ListIterator contentListIterator = contentList.listIterator();
@@ -166,21 +166,11 @@ public class PageBreaker extends Abstrac
&& ((KnuthBlockBox) element).hasAnchors()) {
// element represents a line with footnote citations
containsFootnotes = true;
- LayoutContext footnoteContext =
LayoutContext.copyOf(context);
- footnoteContext.setStackLimitBP(context.getStackLimitBP());
- footnoteContext.setRefIPD(pslm.getCurrentPV()
-
.getRegionReference(Constants.FO_REGION_BODY).getIPD());
- List footnoteBodyLMs = ((KnuthBlockBox)
element).getFootnoteBodyLMs();
- ListIterator footnoteBodyIterator =
footnoteBodyLMs.listIterator();
- // store the lists of elements representing the footnote
bodies
- // in the box representing the line containing their
references
- while (footnoteBodyIterator.hasNext()) {
- FootnoteBodyLayoutManager fblm
- = (FootnoteBodyLayoutManager)
footnoteBodyIterator.next();
- fblm.setParent(childFLM);
- fblm.initialize();
- ((KnuthBlockBox) element).addElementList(
- fblm.getNextKnuthElements(footnoteContext,
alignment));
+ KnuthBlockBox box = (KnuthBlockBox) element;
+ List<List<KnuthElement>> footnotes =
getFootnoteKnuthElements(childFLM, context,
+ box.getFootnoteBodyLMs());
+ for (List<KnuthElement> footnote : footnotes) {
+ box.addElementList(footnote);
}
}
}
@@ -188,6 +178,24 @@ public class PageBreaker extends Abstrac
return containsFootnotes;
}
+ public static List<List<KnuthElement>>
getFootnoteKnuthElements(FlowLayoutManager flowLM, LayoutContext context,
+ List<FootnoteBodyLayoutManager> footnoteBodyLMs) {
+ List<List<KnuthElement>> footnotes = new
ArrayList<List<KnuthElement>>();
+ LayoutContext footnoteContext = LayoutContext.copyOf(context);
+ footnoteContext.setStackLimitBP(context.getStackLimitBP());
+ footnoteContext.setRefIPD(flowLM.getPSLM()
+
.getCurrentPV().getRegionReference(Constants.FO_REGION_BODY).getIPD());
+ for (FootnoteBodyLayoutManager fblm : footnoteBodyLMs) {
+ fblm.setParent(flowLM);
+ fblm.initialize();
+ List<KnuthElement> footnote =
fblm.getNextKnuthElements(footnoteContext, Constants.EN_START);
+ // TODO this does not respect possible stacking constraints
between footnotes
+ SpaceResolver.resolveElementList(footnote);
+ footnotes.add(footnote);
+ }
+ return footnotes;
+ }
+
private void handleFootnoteSeparator() {
StaticContent footnoteSeparator;
footnoteSeparator =
pslm.getPageSequence().getStaticContent("xsl-footnote-separator");
@@ -460,8 +468,13 @@ public class PageBreaker extends Abstrac
/** {@inheritDoc} */
protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition
pbp) {
// add footnote areas
- if (pbp.footnoteFirstListIndex < pbp.footnoteLastListIndex
- || pbp.footnoteFirstElementIndex <= pbp.footnoteLastElementIndex) {
+ if (!pslm.getTableHeaderFootnotes().isEmpty()
+ || pbp.footnoteFirstListIndex < pbp.footnoteLastListIndex
+ || pbp.footnoteFirstElementIndex <=
pbp.footnoteLastElementIndex
+ || !pslm.getTableFooterFootnotes().isEmpty()) {
+ for (List<KnuthElement> footnote : pslm.getTableHeaderFootnotes())
{
+ addFootnoteAreas(footnote);
+ }
// call addAreas() for each FootnoteBodyLM
for (int i = pbp.footnoteFirstListIndex; i <=
pbp.footnoteLastListIndex; i++) {
List elementList = alg.getFootnoteList(i);
@@ -469,13 +482,10 @@ public class PageBreaker extends Abstrac
? pbp.footnoteFirstElementIndex : 0);
int lastIndex = (i == pbp.footnoteLastListIndex
? pbp.footnoteLastElementIndex : elementList.size() -
1);
-
- SpaceResolver.performConditionalsNotification(elementList,
- firstIndex, lastIndex, -1);
- LayoutContext childLC = LayoutContext.newInstance();
- AreaAdditionUtil.addAreas(null,
- new KnuthPossPosIter(elementList, firstIndex,
lastIndex + 1),
- childLC);
+ addFootnoteAreas(elementList, firstIndex, lastIndex + 1);
+ }
+ for (List<KnuthElement> footnote : pslm.getTableFooterFootnotes())
{
+ addFootnoteAreas(footnote);
}
// set the offset from the top margin
Footnote parentArea =
pslm.getCurrentPV().getBodyRegion().getFootnote();
@@ -487,10 +497,21 @@ public class PageBreaker extends Abstrac
parentArea.setSeparator(separatorArea);
}
pslm.getCurrentPV().getCurrentSpan().notifyFlowsFinished();
+ pslm.clearTableHeadingFootnotes();
+ }
+
+ private void addFootnoteAreas(List<KnuthElement> footnote) {
+ addFootnoteAreas(footnote, 0, footnote.size());
+ }
+
+ private void addFootnoteAreas(List<KnuthElement> footnote, int startIndex,
int endIndex) {
+ SpaceResolver.performConditionalsNotification(footnote, startIndex,
endIndex - 1, -1);
+ LayoutContext childLC = LayoutContext.newInstance();
+ AreaAdditionUtil.addAreas(null, new KnuthPossPosIter(footnote,
startIndex, endIndex), childLC);
}
/** {@inheritDoc} */
- protected LayoutManager getCurrentChildLM() {
+ protected FlowLayoutManager getCurrentChildLM() {
return childFLM;
}
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=1603386&r1=1603385&r2=1603386&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
Wed Jun 18 09:59:19 2014
@@ -398,11 +398,6 @@ class PageBreakingAlgorithm extends Brea
// compute the total length of the footnotes
for (List<KnuthElement> noteList : elementLists) {
-
- //Space resolution (Note: this does not respect possible stacking
constraints
- //between footnotes!)
- SpaceResolver.resolveElementList(noteList);
-
int noteLength = 0;
footnotesList.add(noteList);
for (KnuthElement element : noteList) {
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java?rev=1603386&r1=1603385&r2=1603386&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
Wed Jun 18 09:59:19 2014
@@ -19,6 +19,10 @@
package org.apache.fop.layoutmgr;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -44,6 +48,14 @@ public class PageSequenceLayoutManager e
private PageProvider pageProvider;
+ private PageBreaker pageBreaker;
+
+ /** Footnotes coming from repeated table headers, to be added before any
other footnote. */
+ private List<List<KnuthElement>> tableHeaderFootnotes;
+
+ /** Footnotes coming from repeated table footers, to be added after any
other footnote. */
+ private List<List<KnuthElement>> tableFooterFootnotes;
+
/**
* Constructor
*
@@ -75,6 +87,13 @@ public class PageSequenceLayoutManager e
return this;
}
+ public FlowLayoutManager getFlowLayoutManager() {
+ if (pageBreaker == null) {
+ throw new IllegalStateException("This method can be called only
during layout");
+ }
+ return pageBreaker.getCurrentChildLM();
+ }
+
/** {@inheritDoc} */
public void activateLayout() {
initialize();
@@ -107,9 +126,9 @@ public class PageSequenceLayoutManager e
curPage = makeNewPage(false);
- PageBreaker breaker = new PageBreaker(this);
+ pageBreaker = new PageBreaker(this);
int flowBPD = getCurrentPV().getBodyRegion().getRemainingBPD();
- breaker.doLayout(flowBPD);
+ pageBreaker.doLayout(flowBPD);
finishPage();
}
@@ -219,4 +238,58 @@ public class PageSequenceLayoutManager e
return pageProvider.isOnFirstPage(partIndex);
}
+ /**
+ * Registers the given footnotes so that they can be added to the current
page, before any other footnote.
+ *
+ * @param headerFootnotes footnotes coming from a repeated table header
+ */
+ public void addTableHeaderFootnotes(List<List<KnuthElement>>
headerFootnotes) {
+ if (tableHeaderFootnotes == null) {
+ tableHeaderFootnotes = new ArrayList<List<KnuthElement>>();
+ }
+ tableHeaderFootnotes.addAll(headerFootnotes);
+ }
+
+ public List<List<KnuthElement>> getTableHeaderFootnotes() {
+ return getTableFootnotes(tableHeaderFootnotes);
+ }
+
+ /**
+ * Registers the given footnotes so that they can be added to the current
page, after any other footnote.
+ *
+ * @param footerFootnotes footnotes coming from a repeated table footer
+ */
+ public void addTableFooterFootnotes(List<List<KnuthElement>>
footerFootnotes) {
+ if (tableFooterFootnotes == null) {
+ tableFooterFootnotes = new ArrayList<List<KnuthElement>>();
+ }
+ tableFooterFootnotes.addAll(footerFootnotes);
+ }
+
+ public List<List<KnuthElement>> getTableFooterFootnotes() {
+ return getTableFootnotes(tableFooterFootnotes);
+ }
+
+ private List<List<KnuthElement>>
getTableFootnotes(List<List<KnuthElement>> tableFootnotes) {
+ if (tableFootnotes == null) {
+ List<List<KnuthElement>> emptyList = Collections.emptyList();
+ return emptyList;
+ } else {
+ return tableFootnotes;
+ }
+ }
+
+ /**
+ * Clears the footnotes coming from repeated table headers/footers, in
order to start
+ * afresh for a new page.
+ */
+ public void clearTableHeadingFootnotes() {
+ if (tableHeaderFootnotes != null) {
+ tableHeaderFootnotes.clear();
+ }
+ if (tableFooterFootnotes != null) {
+ tableFooterFootnotes.clear();
+ }
+ }
+
}
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=1603386&r1=1603385&r2=1603386&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
Wed Jun 18 09:59:19 2014
@@ -51,6 +51,7 @@ import org.apache.fop.layoutmgr.BreakEle
import org.apache.fop.layoutmgr.BreakingAlgorithm;
import org.apache.fop.layoutmgr.ElementListObserver;
import org.apache.fop.layoutmgr.FootenoteUtil;
+import org.apache.fop.layoutmgr.FootnoteBodyLayoutManager;
import org.apache.fop.layoutmgr.InlineKnuthSequence;
import org.apache.fop.layoutmgr.Keep;
import org.apache.fop.layoutmgr.KnuthBlockBox;
@@ -980,7 +981,8 @@ public class LineLayoutManager extends I
endIndex = ((LineBreakPosition)
llPoss.getChosenPosition(i)).getLeafPos();
// create a list of the FootnoteBodyLM handling footnotes
// whose citations are in this line
- List<LayoutManager> footnoteList =
FootenoteUtil.getFootnotes(seq, startIndex, endIndex);
+ List<FootnoteBodyLayoutManager> footnoteList =
FootenoteUtil.getFootnotes(
+ seq, startIndex, endIndex);
startIndex = endIndex + 1;
LineBreakPosition lbp = (LineBreakPosition)
llPoss.getChosenPosition(i);
if (baselineOffset < 0) {
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java?rev=1603386&r1=1603385&r2=1603386&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
Wed Jun 18 09:59:19 2014
@@ -40,6 +40,7 @@ import org.apache.fop.fo.flow.table.Tabl
import org.apache.fop.layoutmgr.BreakElement;
import org.apache.fop.layoutmgr.ElementListUtils;
import org.apache.fop.layoutmgr.FootenoteUtil;
+import org.apache.fop.layoutmgr.FootnoteBodyLayoutManager;
import org.apache.fop.layoutmgr.Keep;
import org.apache.fop.layoutmgr.KnuthBlockBox;
import org.apache.fop.layoutmgr.KnuthBox;
@@ -47,8 +48,8 @@ import org.apache.fop.layoutmgr.KnuthEle
import org.apache.fop.layoutmgr.KnuthGlue;
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.PageBreaker;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition;
@@ -151,6 +152,7 @@ public class TableContentLayoutManager i
KnuthBox headerAsSecondToLast = null;
KnuthBox footerAsLast = null;
LinkedList returnList = new LinkedList();
+ int headerFootnoteBPD = 0;
if (headerIter != null && headerList == null) {
this.headerList = getKnuthElementsForRowIterator(
headerIter, context, alignment, TableRowIterator.HEADER);
@@ -162,7 +164,7 @@ public class TableContentLayoutManager i
}
TableHeaderFooterPosition pos = new TableHeaderFooterPosition(
getTableLM(), true, this.headerList);
- List<LayoutManager> footnoteList =
FootenoteUtil.getFootnotes(headerList);
+ List<FootnoteBodyLayoutManager> footnoteList =
FootenoteUtil.getFootnotes(headerList);
KnuthBox box = (footnoteList.isEmpty() ||
!getTableLM().getTable().omitHeaderAtBreak())
? new KnuthBox(headerNetHeight, pos, false)
: new KnuthBlockBox(headerNetHeight, footnoteList, pos,
false);
@@ -172,7 +174,13 @@ public class TableContentLayoutManager i
headerAsFirst = box;
} else {
if (!footnoteList.isEmpty()) {
- returnList.add(new KnuthBlockBox(0, footnoteList, new
Position(getTableLM()), true));
+ List<List<KnuthElement>> footnotes =
PageBreaker.getFootnoteKnuthElements(
+ getTableLM().getPSLM().getFlowLayoutManager(),
context, footnoteList);
+ getTableLM().setHeaderFootnotes(footnotes);
+ headerFootnoteBPD = getFootnotesBPD(footnotes);
+ returnList.add(new KnuthBlockBox(-headerFootnoteBPD,
footnoteList,
+ new Position(getTableLM()), true));
+ headerNetHeight += headerFootnoteBPD;
}
headerAsSecondToLast = box;
}
@@ -189,10 +197,16 @@ public class TableContentLayoutManager i
//We can simply add the table footer at the end of the whole list
TableHeaderFooterPosition pos = new TableHeaderFooterPosition(
getTableLM(), false, this.footerList);
- List<LayoutManager> footnoteList =
FootenoteUtil.getFootnotes(footerList);
+ List<FootnoteBodyLayoutManager> footnoteList =
FootenoteUtil.getFootnotes(footerList);
footerAsLast = footnoteList.isEmpty()
? new KnuthBox(footerNetHeight, pos, false)
: new KnuthBlockBox(footerNetHeight, footnoteList, pos,
false);
+ if (!(getTableLM().getTable().omitFooterAtBreak() ||
footnoteList.isEmpty())) {
+ List<List<KnuthElement>> footnotes =
PageBreaker.getFootnoteKnuthElements(
+ getTableLM().getPSLM().getFlowLayoutManager(),
context, footnoteList);
+ getTableLM().setFooterFootnotes(footnotes);
+ footerNetHeight += getFootnotesBPD(footnotes);
+ }
}
returnList.addAll(getKnuthElementsForRowIterator(
bodyIter, context, alignment, TableRowIterator.BODY));
@@ -216,9 +230,20 @@ public class TableContentLayoutManager i
}
returnList.add(insertionPoint, footerAsLast);
}
+ if (headerFootnoteBPD != 0) {
+ returnList.add(new KnuthBox(headerFootnoteBPD, new
Position(getTableLM()), true));
+ }
return returnList;
}
+ private int getFootnotesBPD(List<List<KnuthElement>> footnotes) {
+ int bpd = 0;
+ for (List<KnuthElement> footnote : footnotes) {
+ bpd += ElementListUtils.calcContentLength(footnote);
+ }
+ return bpd;
+ }
+
/**
* Creates Knuth elements by iterating over a TableRowIterator.
* @param iter TableRowIterator instance to fetch rows from
@@ -428,6 +453,9 @@ public class TableContentLayoutManager i
boolean ancestorTreatAsArtifact = layoutContext.treatAsArtifact();
if (headerIsBeingRepeated) {
layoutContext.setTreatAsArtifact(true);
+ if (!getTableLM().getHeaderFootnotes().isEmpty()) {
+
getTableLM().getPSLM().addTableHeaderFootnotes(getTableLM().getHeaderFootnotes());
+ }
}
//header positions for the last part are the second-to-last
element and need to
//be handled first before all other TableContentPositions
@@ -456,8 +484,10 @@ public class TableContentLayoutManager i
boolean ancestorTreatAsArtifact = layoutContext.treatAsArtifact();
layoutContext.setTreatAsArtifact(treatFooterAsArtifact);
//Positions for footers are simply added at the end
- addHeaderFooterAreas(footerElements,
tableLM.getTable().getTableFooter(), painter,
- true);
+ addHeaderFooterAreas(footerElements,
tableLM.getTable().getTableFooter(), painter, true);
+ if (lastPos instanceof TableHFPenaltyPosition &&
!tableLM.getFooterFootnotes().isEmpty()) {
+
tableLM.getPSLM().addTableFooterFootnotes(getTableLM().getFooterFootnotes());
+ }
layoutContext.setTreatAsArtifact(ancestorTreatAsArtifact);
}
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java?rev=1603386&r1=1603385&r2=1603386&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
Wed Jun 18 09:59:19 2014
@@ -20,6 +20,7 @@
package org.apache.fop.layoutmgr.table;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -98,6 +99,10 @@ public class TableLayoutManager extends
private boolean hasRetrieveTableMarker;
+ private List<List<KnuthElement>> headerFootnotes = Collections.emptyList();
+
+ private List<List<KnuthElement>> footerFootnotes = Collections.emptyList();
+
/**
* Temporary holder of column background informations for a table-cell's
area.
*
@@ -635,4 +640,20 @@ public class TableLayoutManager extends
super.possiblyRegisterMarkersForTables(markers, isStarting, isFirst,
isLast);
}
+ void setHeaderFootnotes(List<List<KnuthElement>> footnotes) {
+ this.headerFootnotes = footnotes;
+ }
+
+ List<List<KnuthElement>> getHeaderFootnotes() {
+ return headerFootnotes;
+ }
+
+ void setFooterFootnotes(List<List<KnuthElement>> footnotes) {
+ this.footerFootnotes = footnotes;
+ }
+
+ List<List<KnuthElement>> getFooterFootnotes() {
+ return footerFootnotes;
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]