]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Handling page dependent footnote separator
authorLuca Furini <lfurini@apache.org>
Tue, 31 May 2005 16:19:29 +0000 (16:19 +0000)
committerLuca Furini <lfurini@apache.org>
Tue, 31 May 2005 16:19:29 +0000 (16:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198710 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java

index e5f8f67e34a99dd042f8d0f0190ad1383dd2f394..8cfa6d052134d5b17a25601528c255cb9cb64c1b 100644 (file)
@@ -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);
index 54dd6e2fc8fe0f10695832fdea84072bf7d45935..428e2d06189685b7c7cba5846a73d3888067681d 100644 (file)
@@ -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);    
         }
         
index 16914757edcaf29fe01cd47217b84d5f3e406ae9..613f17a7579bb9d2678d11d2ea144dc5b97c51ec 100644 (file)
@@ -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.");