From 2b6273e76dd7a93a6b38734078e86bce8ebd7bb3 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 10 Feb 2005 19:40:47 +0000 Subject: [PATCH] Table headers/footers need to be recalculated for each page (for dynamic elements like page-numbers and changing page-masters together with auto layout). Therefore a new LM is created for each page. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198416 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/LayoutManagerMapping.java | 6 -- .../layoutmgr/table/TableLayoutManager.java | 82 ++++++++----------- 2 files changed, 33 insertions(+), 55 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java index 247d6d026..534af3e9d 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java @@ -354,12 +354,6 @@ public class LayoutManagerMapping implements LayoutManagerMaker { if (columnLMs != null) { tlm.setColumns(columnLMs); } - if (table.getTableHeader() != null) { - tlm.setTableHeader(new Body(table.getTableHeader())); - } - if (table.getTableFooter() != null) { - tlm.setTableFooter(new Body(table.getTableFooter())); - } lms.add(tlm); } } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index 89188f907..0a2a767de 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -21,8 +21,6 @@ package org.apache.fop.layoutmgr.table; import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.PercentBase; import org.apache.fop.fo.flow.Table; -import org.apache.fop.fo.flow.TableBody; -import org.apache.fop.fo.flow.TableRow; import org.apache.fop.fo.properties.TableColLength; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; import org.apache.fop.layoutmgr.LayoutManager; @@ -38,7 +36,6 @@ import org.apache.fop.area.Block; import org.apache.fop.traits.MinOptMax; import org.apache.fop.traits.SpaceVal; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -54,12 +51,10 @@ public class TableLayoutManager extends BlockStackingLayoutManager { private Table fobj; private List columns = null; - private Body tableHeader = null; - private Body tableFooter = null; private Block curBlockArea; - private List bodyBreaks = new ArrayList(); + private List bodyBreaks = new java.util.ArrayList(); private BreakPoss headerBreak; private BreakPoss footerBreak; @@ -102,26 +97,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager { columns = cols; } - /** - * Set the table header. - * - * @param th the table header layout manager - */ - public void setTableHeader(Body th) { - tableHeader = th; - tableHeader.setParent(this); - } - - /** - * Set the table footer. - * - * @param tf the table footer layout manager - */ - public void setTableFooter(Body tf) { - tableFooter = tf; - tableFooter.setParent(this); - } - /** @see org.apache.fop.layoutmgr.AbstractLayoutManager#initProperties() */ protected void initProperties() { super.initProperties(); @@ -202,31 +177,40 @@ public class TableLayoutManager extends BlockStackingLayoutManager { (contentIPD - sumCols) / factors); } } - MinOptMax headerSize = null; - if (tableHeader != null) { - tableHeader.resetPosition(null); - headerBreak = getHeight(tableHeader, context); - headerSize = headerBreak.getStackingSize(); - stackSize.add(headerSize); - } + + boolean headerFooterBuilt = false; - MinOptMax footerSize = null; - if (tableFooter != null) { - tableFooter.resetPosition(null); - footerBreak = getHeight(tableFooter, context); - footerSize = footerBreak.getStackingSize(); - stackSize.add(footerSize); - } + while ((curLM = (Body)getChildLM()) != null) { + if (!headerFooterBuilt) { + //Calculate the headers and footers only when needed + MinOptMax headerSize = null; + if (getTable().getTableHeader() != null) { + Body tableHeader = new Body(getTable().getTableHeader()); + tableHeader.setParent(this); + headerBreak = getHeight(tableHeader, context); + headerSize = headerBreak.getStackingSize(); + stackSize.add(headerSize); + } - if (stackSize.opt > context.getStackLimit().max) { - BreakPoss breakPoss = new BreakPoss( - new LeafPosition(this, 0)); - breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true); - breakPoss.setStackingSize(stackSize); - return breakPoss; - } + MinOptMax footerSize = null; + if (getTable().getTableFooter() != null) { + Body tableFooter = new Body(getTable().getTableFooter()); + tableFooter.setParent(this); + footerBreak = getHeight(tableFooter, context); + footerSize = footerBreak.getStackingSize(); + stackSize.add(footerSize); + } - while ((curLM = (Body)getChildLM()) != null) { + if (stackSize.opt > context.getStackLimit().max) { + BreakPoss breakPoss = new BreakPoss( + new LeafPosition(this, 0)); + breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true); + breakPoss.setStackingSize(stackSize); + return breakPoss; + } + headerFooterBuilt = true; + } + // Make break positions // Set up a LayoutContext int ipd = context.getRefIPD(); @@ -314,7 +298,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager { lm.setColumns(columns); - List breaks = new ArrayList(); + List breaks = new java.util.ArrayList(); while (!lm.isFinished()) { if ((bp = lm.getNextBreakPoss(childLC)) != null) { stackSize.add(bp.getStackingSize()); -- 2.39.5