]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
-- Modified the PSLM constructor and mapping Maker to take an
authorGlen Mazza <gmazza@apache.org>
Sat, 30 Apr 2005 22:57:08 +0000 (22:57 +0000)
committerGlen Mazza <gmazza@apache.org>
Sat, 30 Apr 2005 22:57:08 +0000 (22:57 +0000)
AreaTreeHandler object.  The Maker also returns a PSLM object to allow
for future detachment of PSLM from increasingly ill-fitting
AbstractLayoutManager and/or LayoutManager.

-- Removed areaTreeModel instance variable from PSLM hopefully
to increase code comprehension (better clarifies that the
ATM is owned by the ATH.)

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_KnuthStylePageBreaking@198599 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/area/AreaTreeHandler.java
src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java

index 16e60b176c0812b6f7e91c15c9437a4d05992bb2..ca0f87c7d73a37530827e1f1275e1b27407d6380 100644 (file)
@@ -230,9 +230,9 @@ public class AreaTreeHandler extends FOEventHandler {
         // If no main flow, nothing to layout!
         if (pageSequence.getMainFlow() != null) {
             PageSequenceLayoutManager pageSLM;
-            pageSLM = (PageSequenceLayoutManager)
-                getLayoutManagerMaker().makeLayoutManager(pageSequence);
-            pageSLM.setAreaTreeHandler(this);
+            pageSLM =
+                getLayoutManagerMaker().makePageSequenceLayoutManager(this,
+                    pageSequence);
             pageSLM.activateLayout();
         }
     }
index 9f344ed82a6d99cb95a15916711b13f11701c379..b0d72344461c7eeceba733e988e2916d8b03c5ab 100644 (file)
@@ -19,6 +19,8 @@ package org.apache.fop.layoutmgr;
 
 import java.util.List;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.area.AreaTreeHandler;
 
 
 /**
@@ -44,5 +46,14 @@ public interface LayoutManagerMaker {
      */
     public LayoutManager makeLayoutManager(FONode node);
 
+    /**
+     * Make a PageSequenceLayoutManager object.
+     * @param ath the AreaTreeHandler object the PSLM interacts with
+     * @param ps the fo:page-sequence object this PSLM will process
+     * @return The created PageSequenceLayoutManager object
+     */
+    public PageSequenceLayoutManager makePageSequenceLayoutManager(
+        AreaTreeHandler ath, PageSequence ps);
+
 }
 
index 821d369444cd81e962599062dcf45edaa8b4b5b8..4b235c09d969f805daad0a86a4792dae4f4242fe 100644 (file)
@@ -58,6 +58,7 @@ import org.apache.fop.fo.pagination.Flow;
 import org.apache.fop.fo.pagination.PageSequence;
 import org.apache.fop.fo.pagination.StaticContent;
 import org.apache.fop.fo.pagination.Title;
+import org.apache.fop.area.AreaTreeHandler;
 
 import org.apache.fop.layoutmgr.list.ListBlockLayoutManager;
 import org.apache.fop.layoutmgr.list.ListItemLayoutManager;
@@ -109,7 +110,6 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
         makers.put(PageNumber.class, new PageNumberLayoutManagerMaker());
         makers.put(PageNumberCitation.class,
                    new PageNumberCitationLayoutManagerMaker());
-        makers.put(PageSequence.class, new PageSequenceLayoutManagerMaker());
         makers.put(Table.class, new TableLayoutManagerMaker());
         makers.put(TableBody.class, new /*TableBodyLayoutManager*/Maker());
         makers.put(TableColumn.class, new /*TableColumnLayoutManager*/Maker());
@@ -153,6 +153,11 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
         return (LayoutManager) lms.get(0);
     }
 
+    public PageSequenceLayoutManager makePageSequenceLayoutManager(
+        AreaTreeHandler ath, PageSequence ps) {
+        return new PageSequenceLayoutManager(ath, ps);
+    }
+
     public static class Maker {
         public void make(FONode node, List lms) {
             // no layout manager
@@ -301,12 +306,6 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
          }
     }
 
-    public static class PageSequenceLayoutManagerMaker extends Maker {
-         public void make(FONode node, List lms) {
-             lms.add(new PageSequenceLayoutManager((PageSequence) node));
-         }
-    }
-
     public static class TableLayoutManagerMaker extends Maker {
         
         /*
index a72296fef1cc463844cb359d87c6267ae6b41579..c2511232c7764f85211b722ab0ad07b7f2ceeadd 100644 (file)
@@ -43,11 +43,37 @@ import java.util.LinkedList;
 import java.util.List;
 
 /**
- * LayoutManager for a PageSequence.
+ * LayoutManager for a PageSequence.  This class is instantiated by
+ * area.AreaTreeHandler for each fo:page-sequence found in the
+ * input document.
  */
 public class PageSequenceLayoutManager extends AbstractLayoutManager {
+
+    /** 
+     * AreaTreeHandler which activates the PSLM and controls
+     * the rendering of its pages.
+     */
+    private AreaTreeHandler areaTreeHandler;
+
+    /** 
+     * fo:page-sequence formatting object being
+     * processed by this class
+     */
     private PageSequence pageSeq;
 
+    /** 
+     * Current page-viewport-area being filled by
+     * the PSLM.
+     */
+    private PageViewport curPV = null;
+
+    /**
+     * Zero-based index of column (Normal Flow) in span (of the PV) 
+     * being filled.  See XSL Rec description of fo:region-body 
+     * and fop.Area package classes for more information. 
+     */
+    private int curFlowIdx = -1;
+
     /*
     private static class BlockBreakPosition extends LeafPosition {
         protected BreakPoss breakps;
@@ -61,22 +87,6 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
     private int startPageNum = 0;
     private int currentPageNum = 0;
 
-    /** Current page-viewport-area being filled. */
-    private PageViewport curPV = null;
-
-    /** Zero-based index of column (Normal Flow) in span being filled. */
-    private int curFlowIdx = -1;
-
-    /** 
-     * AreaTreeHandler which activates this PSLM.
-     */
-    private AreaTreeHandler areaTreeHandler;
-
-    /** 
-     * AreaTreeModel that this PSLM sends pages to.
-     */
-    private AreaTreeModel areaTreeModel;
-
     /**
      * The single FlowLayoutManager object, which processes
      * the single fo:flow of the fo:page-sequence
@@ -90,23 +100,15 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
     //private HashMap staticContentLMs = new HashMap(4);
 
     /**
-     * Constructor - activated by AreaTreeHandler for each
-     * fo:page-sequence in the input FO stream
+     * Constructor
      *
-     * @param pageSeq the page-sequence formatting object
-     */
-    public PageSequenceLayoutManager(PageSequence pageSeq) {
-        super(pageSeq);
-        this.pageSeq = pageSeq;
-    }
-
-    /**
-     * Set the AreaTreeHandler
-     * @param areaTreeHandler the area tree handler object
+     * @param ath the area tree handler object
+     * @param pseq fo:page-sequence to process
      */
-    public void setAreaTreeHandler(AreaTreeHandler areaTreeHandler) {
-        this.areaTreeHandler = areaTreeHandler;
-        areaTreeModel = areaTreeHandler.getAreaTreeModel();
+    public PageSequenceLayoutManager(AreaTreeHandler ath, PageSequence pseq) {
+        super(pseq);
+        this.areaTreeHandler = ath;
+        this.pageSeq = pseq;
     }
 
     /**
@@ -134,7 +136,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
             title = (LineArea) clm.getParentArea(null); // can improve
         }
 
-        areaTreeModel.startPageSequence(title);
+        areaTreeHandler.getAreaTreeModel().startPageSequence(title);
         log.debug("Starting layout");
 
         curPV = makeNewPage(false, true, false);
@@ -342,6 +344,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
      * @return the layout manager for the marker contents
      */
     public Marker retrieveMarker(String name, int pos, int boundary) {
+        AreaTreeModel areaTreeModel = areaTreeHandler.getAreaTreeModel();
+        
         // get marker from the current markers on area tree
         Marker mark = (Marker)curPV.getMarker(name, pos);
         if (mark == null && boundary != EN_PAGE) {
@@ -424,7 +428,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
         if (sc == null) {
             return;
         }
-        
+
         RegionViewport rv = curPV.getPage().getRegionViewport(regionID);
         StaticContentLayoutManager lm;
         lm = (StaticContentLayoutManager)
@@ -462,7 +466,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
         layoutSideRegion(FO_REGION_START);
         layoutSideRegion(FO_REGION_END);
         // Queue for ID resolution and rendering
-        areaTreeModel.addPage(curPV);
+        areaTreeHandler.getAreaTreeModel().addPage(curPV);
         log.debug("page finished: " + curPV.getPageNumberString() + ", current num: " + currentPageNum);
         curPV = null;
         curFlowIdx = -1;