From 2a79fb9d8047c3b6bea4e3a557a8df05f3d3bf6a Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Sat, 7 Oct 2006 13:25:32 +0000 Subject: [PATCH] Bugfix: Nested tables with headers and footers were not handled correctly and could overlap with the region-after. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@453900 13f79535-47bb-0310-9956-ffa450edef68 --- .../table/TableContentLayoutManager.java | 11 ++ .../fop/layoutmgr/table/TableStepper.java | 28 ++- status.xml | 4 + .../table-header_table-footer_4.xml | 179 ++++++++++++++++++ 4 files changed, 216 insertions(+), 6 deletions(-) create mode 100644 test/layoutengine/standard-testcases/table-header_table-footer_4.xml diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index 8b07f6956..e0eaf079e 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -619,6 +619,7 @@ public class TableContentLayoutManager implements PercentBaseContext { List positions = new java.util.ArrayList(); List headerElements = null; List footerElements = null; + int nestedPenaltyArea = 0; Position firstPos = null; Position lastPos = null; Position lastCheckPos = null; @@ -668,6 +669,7 @@ public class TableContentLayoutManager implements PercentBaseContext { if (penaltyPos.footerElements != null) { footerElements = penaltyPos.footerElements; } + nestedPenaltyArea = penaltyPos.nestedPenaltyLength; } Map markers = getTableLM().getTable().getMarkers(); @@ -689,6 +691,7 @@ public class TableContentLayoutManager implements PercentBaseContext { iterateAndPaintPositions(posIter, painter); painter.addAreasAndFlushRow(true); + painter.notifyNestedPenaltyArea(nestedPenaltyArea); if (footerElements != null) { //Positions for footers are simply added at the end PositionIterator nestedIter = new KnuthPossPosIter(footerElements); @@ -792,6 +795,10 @@ public class TableContentLayoutManager implements PercentBaseContext { this.accumulatedBPD += lastRowHeight; //for last row } + public void notifyNestedPenaltyArea(int length) { + this.lastRowHeight += length; + } + public void handleTableContentPosition(TableContentPosition tcpos) { if (lastRow != tcpos.row && lastRow != null) { addAreasAndFlushRow(false); @@ -1208,6 +1215,8 @@ public class TableContentLayoutManager implements PercentBaseContext { protected List headerElements; /** Element list for the footer */ protected List footerElements; + /** Penalty length to be respected for nested content */ + protected int nestedPenaltyLength; /** * Creates a new TableHFPenaltyPosition @@ -1225,6 +1234,8 @@ public class TableContentLayoutManager implements PercentBaseContext { sb.append(headerElements); sb.append(", footer:"); sb.append(footerElements); + sb.append(", inner penalty length:"); + sb.append(nestedPenaltyLength); sb.append(")"); return sb.toString(); } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index 9d77293ed..6763f8b08 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -65,6 +65,7 @@ public class TableStepper { private boolean skippedStep; private boolean[] keepWithNextSignals; private boolean[] forcedBreaks; + private int lastMaxPenalty; /** * Main constructor @@ -261,7 +262,7 @@ public class TableStepper { int penaltyLen = step + getMaxRemainingHeight() - totalHeight; int boxLen = step - addedBoxLen - penaltyLen; addedBoxLen += boxLen; - + //Put all involved grid units into a list List gridUnitParts = new java.util.ArrayList(maxColumnCount); for (int i = 0; i < start.length; i++) { @@ -328,6 +329,18 @@ public class TableStepper { penaltyPos.footerElements = tclm.getFooterElements(); } } + + //Handle a penalty length coming from nested content + //Example: nested table with header/footer + if (this.lastMaxPenalty != 0) { + penaltyPos.nestedPenaltyLength = this.lastMaxPenalty; + if (log.isDebugEnabled()) { + log.debug("Additional penalty length from table-cell break: " + + this.lastMaxPenalty); + } + } + effPenaltyLen += this.lastMaxPenalty; + int p = 0; boolean allCellsHaveContributed = true; signalKeepWithNext = false; @@ -359,13 +372,14 @@ public class TableStepper { p = -KnuthPenalty.INFINITE; //Overrides any keeps (see 4.8 in XSL 1.0) clearBreakCondition(); } - //returnList.add(new KnuthPenalty(effPenaltyLen, p, false, penaltyPos, false)); returnList.add(new BreakElement(penaltyPos, effPenaltyLen, p, -1, context)); - log.debug("step=" + step + " (+" + increase + ")" - + " box=" + boxLen - + " penalty=" + penaltyLen - + " effPenalty=" + effPenaltyLen); + if (log.isDebugEnabled()) { + log.debug("step=" + step + " (+" + increase + ")" + + " box=" + boxLen + + " penalty=" + penaltyLen + + " effPenalty=" + effPenaltyLen); + } laststep = step; if (rowBacktrackForLastStep) { @@ -388,6 +402,7 @@ public class TableStepper { } private int getNextStep(int lastStep) { + this.lastMaxPenalty = 0; //Check for forced break conditions /* if (isBreakCondition()) { @@ -452,6 +467,7 @@ public class TableStepper { end[i]++; KnuthElement el = (KnuthElement)elementLists[i].get(end[i]); if (el.isPenalty()) { + this.lastMaxPenalty = Math.max(this.lastMaxPenalty, el.getW()); if (el.getP() <= -KnuthElement.INFINITE) { log.debug("FORCED break encountered!"); forcedBreaks[i] = true; diff --git a/status.xml b/status.xml index 93894917c..aad3e3d58 100644 --- a/status.xml +++ b/status.xml @@ -28,6 +28,10 @@ + + Bugfix: Nested tables with headers and footers were not handled correctly and could + overlap with the region-after. + Added support for CCITT compression in the TIFFRenderer by switching to the ImageWriter abstraction from XML Graphics Commons. diff --git a/test/layoutengine/standard-testcases/table-header_table-footer_4.xml b/test/layoutengine/standard-testcases/table-header_table-footer_4.xml new file mode 100644 index 000000000..26f305663 --- /dev/null +++ b/test/layoutengine/standard-testcases/table-header_table-footer_4.xml @@ -0,0 +1,179 @@ + + + + + +

+ This test checks tables, especially headers and footers. Focus is on respect for after + regions when headers and footers are used. +

+
+ + + + + + + + + + + + + + + + + Outer header + + + + + + + Outer footer + + + + + + + + + + + + Inner header + + + + + + + Inner footer + + + + + + + content content content + + + + + content content content + + + + + content content content + + + + + content content content + + + + + content content content + + + + + content content content + + + + + content content content + + + + + content content content + + + + + content content content + + + + + content content content + + + + + content content content + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + + + + + + + + + + + + + + +
-- 2.39.5