From 2f75a4659d2cfe7f61f5a98521031d81cfb02c56 Mon Sep 17 00:00:00 2001 From: Luca Furini Date: Tue, 31 May 2005 16:19:29 +0000 Subject: [PATCH] Handling page dependent footnote separator git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198710 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/layoutmgr/AbstractBreaker.java | 2 +- .../layoutmgr/PageSequenceLayoutManager.java | 45 +++++++++---------- .../layoutmgr/StaticContentLayoutManager.java | 30 +++++++++---- 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java index e5f8f67e3..8cfa6d052 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java @@ -94,7 +94,7 @@ public abstract class AbstractBreaker { private List blockLists = null; - private int alignment; + protected int alignment; private int alignmentLast; protected MinOptMax footnoteSeparatorLength = new MinOptMax(0); diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index 54dd6e2fc..428e2d061 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -192,36 +192,23 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { StaticContent footnoteSeparator; if (bFootnotesPresent && (footnoteSeparator = pageSeq.getStaticContent("xsl-footnote-separator")) != null) { + // the footnote separator can contain page-dependent content such as + // page numbers or retrieve markers, so its areas cannot simply be + // obtained now and repeated in each page; + // we need to know in advance the separator bpd: the actual separator + // could be different from page to page, but its bpd would likely be + // always the same + // create a Block area that will contain the separator areas separatorArea = new Block(); - + separatorArea.setIPD(context.getRefIPD()); // create a StaticContentLM for the footnote separator footnoteSeparatorLM = (StaticContentLayoutManager) getLayoutManagerMaker().makeStaticContentLayoutManager( pslm, footnoteSeparator, separatorArea); + footnoteSeparatorLM.doLayout(); - // get the list of elements representing the footnote separator - footnoteSeparatorList = footnoteSeparatorLM.getNextKnuthElements(context, alignment); - - // compute the total length of the elements - footnoteSeparatorLength = new MinOptMax(0); - ListIterator separatorIterator = footnoteSeparatorList.listIterator(); - while (separatorIterator.hasNext()) { - KnuthElement element = (KnuthElement) separatorIterator.next(); - if (element.isBox()) { - footnoteSeparatorLength.add(new MinOptMax(element.getW())); - } else if (element.isGlue()) { - footnoteSeparatorLength.add(new MinOptMax(element.getW())); - footnoteSeparatorLength.max += element.getY(); - footnoteSeparatorLength.min -= element.getZ(); - } - } - - // add the footnote separator areas to the Block area - if (footnoteSeparatorList != null) { - LayoutContext childLC = new LayoutContext(0); - footnoteSeparatorLM.addAreas(new KnuthPossPosIter(footnoteSeparatorList, 0, footnoteSeparatorList.size()), childLC); - } + footnoteSeparatorLength = new MinOptMax(separatorArea.getBPD()); } return contentList; } @@ -235,6 +222,18 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { } protected void addAreas(PositionIterator posIter, LayoutContext context) { + if (footnoteSeparatorLM != null) { + StaticContent footnoteSeparator = pageSeq.getStaticContent("xsl-footnote-separator"); + // create a Block area that will contain the separator areas + separatorArea = new Block(); + separatorArea.setIPD(curPV.getCurrentSpan().getColumnWidth()); + // create a StaticContentLM for the footnote separator + footnoteSeparatorLM = (StaticContentLayoutManager) + getLayoutManagerMaker().makeStaticContentLayoutManager( + pslm, footnoteSeparator, separatorArea); + footnoteSeparatorLM.doLayout(); + } + getCurrentChildLM().addAreas(posIter, context); } diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java index 16914757e..613f17a75 100644 --- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java @@ -172,8 +172,8 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { if (getStaticContentFO().getFlowName().equals("xsl-footnote-separator")) { targetBlock.addBlock((Block)childArea); } else { - targetRegion.addBlock((Block)childArea); - } + targetRegion.addBlock((Block)childArea); + } } /** @@ -183,19 +183,33 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { if (getStaticContentFO().getFlowName().equals("xsl-footnote-separator")) { return targetBlock; } else { - return targetRegion; - } + return targetRegion; + } } /** * Does the layout for a side region. Called by PageSequenceLayoutManager. */ public void doLayout() { - StaticContentBreaker breaker = new StaticContentBreaker( - this, targetRegion.getIPD(), regionFO.getDisplayAlign()); - breaker.doLayout(targetRegion.getBPD()); + int targetIPD = 0; + int targetBPD = 0; + int targetAlign = EN_AUTO; + StaticContentBreaker breaker; + + if (getStaticContentFO().getFlowName().equals("xsl-footnote-separator")) { + targetIPD = targetBlock.getIPD(); + targetBPD = targetBlock.getBPD(); + targetAlign = EN_BEFORE; + } else { + targetIPD = targetRegion.getIPD(); + targetBPD = targetRegion.getBPD(); + targetAlign = regionFO.getDisplayAlign(); + } + breaker = new StaticContentBreaker(this, targetIPD, targetAlign); + breaker.doLayout(targetBPD); if (breaker.isOverflow()) { - if (regionFO.getOverflow() == EN_ERROR_IF_OVERFLOW) { + if (!getStaticContentFO().getFlowName().equals("xsl-footnote-separator") + && regionFO.getOverflow() == EN_ERROR_IF_OVERFLOW) { //TODO throw layout exception } log.warn("static-content overflows the available area."); -- 2.39.5