From a30a33e730322c69fc72198885d01b0e42b1f9e9 Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Fri, 6 Feb 2015 15:48:44 +0000 Subject: [PATCH] FOP-2443: Repeated Table headers and footers with markers are not being treated as artifacts git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1657872 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/layoutmgr/LocalBreaker.java | 24 +++++++++++++++++++ .../table/TableCellLayoutManager.java | 10 ++++++++ .../table/TableContentLayoutManager.java | 3 +++ .../layoutmgr/table/TableLayoutManager.java | 9 +++++++ 4 files changed, 46 insertions(+) diff --git a/src/java/org/apache/fop/layoutmgr/LocalBreaker.java b/src/java/org/apache/fop/layoutmgr/LocalBreaker.java index a37f82643..f5882f119 100644 --- a/src/java/org/apache/fop/layoutmgr/LocalBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/LocalBreaker.java @@ -31,6 +31,17 @@ public abstract class LocalBreaker extends AbstractBreaker { private int displayAlign; private int ipd; private int overflow; + private boolean repeatedHeader; + private boolean isDescendantOfTableFooter; + private boolean repeatedFooter; + + public void setRepeatedFooter(boolean repeatedFooter) { + this.repeatedFooter = repeatedFooter; + } + + public void setDescendantOfTableFooter(boolean isDescendantOfTableFooter) { + this.isDescendantOfTableFooter = isDescendantOfTableFooter; + } public LocalBreaker(BlockStackingLayoutManager lm, int ipd, int displayAlign) { this.lm = lm; @@ -38,6 +49,10 @@ public abstract class LocalBreaker extends AbstractBreaker { this.displayAlign = displayAlign; } + public void setRepeatedHeader(boolean repeatedHeader) { + this.repeatedHeader = repeatedHeader; + } + /** {@inheritDoc} */ protected boolean isPartOverflowRecoveryActivated() { // For side regions, this must be disabled because of wanted overflow. @@ -109,6 +124,15 @@ public abstract class LocalBreaker extends AbstractBreaker { } protected void addAreas(PositionIterator posIter, LayoutContext context) { + if (isDescendantOfTableFooter) { + if (repeatedHeader) { + context.setTreatAsArtifact(true); + } + } else { + if (repeatedFooter) { + context.setTreatAsArtifact(true); + } + } AreaAdditionUtil.addAreas(lm, posIter, context); } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index b8d5c063a..e667049fa 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -88,6 +88,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager { private boolean isDescendantOfTableFooter; private boolean isDescendantOfTableHeader; private boolean hasRetrieveTableMarker; + private boolean hasRepeatedHeader; // place holder for the addAreas arguments private boolean savedAddAreasArguments; @@ -140,6 +141,9 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager { return getTableCell().getTable(); } + public void setHasRepeatedHeader(boolean hasRepeatedHeader) { + this.hasRepeatedHeader = hasRepeatedHeader; + } /** {@inheritDoc} */ protected int getIPIndents() { @@ -534,6 +538,12 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager { recreateChildrenLMs(); int displayAlign = ((TableCell) this.getFObj()).getDisplayAlign(); TableCellBreaker breaker = new TableCellBreaker(this, cellIPD, displayAlign); + breaker.setDescendantOfTableFooter(isDescendantOfTableHeader); + if (isDescendantOfTableHeader) { + breaker.setRepeatedHeader(hasRepeatedHeader); + } else { + breaker.setRepeatedFooter(layoutContext.treatAsArtifact()); + } breaker.doLayout(usedBPD, false); // this is needed so the next time the LMs are recreated they look like the originals; this // is due to the fact that during the doLayout() above the FO tree changes when the diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index f15ef74ed..eb82a0538 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -78,6 +78,7 @@ public class TableContentLayoutManager implements PercentBaseContext { private TableStepper stepper; private boolean headerIsBeingRepeated; + private boolean atLeastOnce; /** * Main constructor @@ -478,7 +479,9 @@ public class TableContentLayoutManager implements PercentBaseContext { // if there are TCLMs saved because they have a RetrieveTableMarker, we repeat the header areas now; // this can also be done after the areas for the footer are added but should be the same as here + tableLM.setRepeateHeader(atLeastOnce); tableLM.repeatAddAreasForSavedTableHeaderTableCellLayoutManagers(); + atLeastOnce = true; if (footerElements != null) { boolean ancestorTreatAsArtifact = layoutContext.treatAsArtifact(); diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index c733d1d7e..e343d72f3 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -99,6 +99,8 @@ public class TableLayoutManager extends SpacedBorderedPaddedBlockLayoutManager private boolean hasRetrieveTableMarker; + private boolean repeatedHeader; + private List> headerFootnotes = Collections.emptyList(); private List> footerFootnotes = Collections.emptyList(); @@ -558,6 +560,9 @@ public class TableLayoutManager extends SpacedBorderedPaddedBlockLayoutManager areAllTCLMsSaved = true; for (int i = 0; i < savedTCLMs.size(); i++) { TableCellLayoutManager tclm = savedTCLMs.get(i); + if (this.repeatedHeader) { + tclm.setHasRepeatedHeader(true); + } tclm.repeatAddAreas(); } } @@ -652,6 +657,10 @@ public class TableLayoutManager extends SpacedBorderedPaddedBlockLayoutManager this.footerFootnotes = footnotes; } + public void setRepeateHeader(boolean repeateHeader) { + this.repeatedHeader = repeateHeader; + } + List> getFooterFootnotes() { return footerFootnotes; } -- 2.39.5