keiron      2003/02/19 18:47:45

  Modified:    src/org/apache/fop/area AreaTree.java AreaTreeModel.java
                        PageViewport.java
               src/org/apache/fop/layoutmgr PageLayoutManager.java
                        RetrieveMarkerLayoutManager.java
                        BlockLayoutManager.java
  Log:
  implement position and boundary for markers
  
  Revision  Changes    Path
  1.15      +10 -1     xml-fop/src/org/apache/fop/area/AreaTree.java
  
  Index: AreaTree.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/AreaTree.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AreaTree.java     22 Dec 2002 22:40:31 -0000      1.14
  +++ AreaTree.java     20 Feb 2003 02:47:44 -0000      1.15
  @@ -73,6 +73,15 @@
       }
   
       /**
  +     * Get the area tree model for this area tree.
  +     *
  +     * @return AreaTreeModel the model being used for this area tree
  +     */
  +    public AreaTreeModel getAreaTreeModel() {
  +        return model;
  +    }
  +
  +    /**
        * Start a new page sequence.
        * This signals that a new page sequence has started in the document.
        * @param title the title of the new page sequence or null if no title
  
  
  
  1.3       +33 -1     xml-fop/src/org/apache/fop/area/AreaTreeModel.java
  
  Index: AreaTreeModel.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/AreaTreeModel.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AreaTreeModel.java        23 Jan 2003 18:59:07 -0000      1.2
  +++ AreaTreeModel.java        20 Feb 2003 02:47:44 -0000      1.3
  @@ -11,6 +11,9 @@
    * This is the model for the area tree object.
    * The model implementation can handle the page sequence,
    * page and extensions.
  + * The mathods to acces the page viewports can only
  + * assume the PageViewport is valid as it remains for
  + * the life of the area tree model.
    */
   public abstract class AreaTreeModel {
       /**
  @@ -36,4 +39,33 @@
        * Signal the end of the document for any processing.
        */
       public abstract void endDocument();
  +
  +    /**
  +     * Get the page sequence count.
  +     * @return the number of page sequences in the document.
  +     */
  +    public abstract int getPageSequenceCount();
  +
  +    /**
  +     * Get the title for a page sequence.
  +     * @param count the page sequence count
  +     * @return the title of the page sequence
  +     */
  +    public abstract Title getTitle(int count);
  +
  +    /**
  +     * Get the page count.
  +     * @param seq the page sequence to count.
  +     * @return returns the number of pages in a page sequence
  +     */
  +    public abstract int getPageCount(int seq);
  +
  +    /**
  +     * Get the page for a position in the document.
  +     * @param seq the page sequence number
  +     * @param count the page count in the sequence
  +     * @return the PageViewport for the particular page
  +     */
  +    public abstract PageViewport getPage(int seq, int count);
  +
   }
  
  
  
  1.14      +84 -13    xml-fop/src/org/apache/fop/area/PageViewport.java
  
  Index: PageViewport.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/PageViewport.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- PageViewport.java 19 Feb 2003 05:43:24 -0000      1.13
  +++ PageViewport.java 20 Feb 2003 02:47:44 -0000      1.14
  @@ -16,6 +16,8 @@
   import java.util.HashMap;
   import java.util.Iterator;
   
  +import org.apache.fop.fo.properties.RetrievePosition;
  +
   /**
    * Page viewport that specifies the viewport area and holds the page contents.
    * This is the top level object for a page and remains valid for the life
  @@ -43,8 +45,10 @@
   
       // hashmap of markers for this page
       // start and end are added by the fo that contains the markers
  -    private Map markerStart = null;
  -    private Map markerEnd = null;
  +    private Map markerFirstStart = null;
  +    private Map markerLastStart = null;
  +    private Map markerFirstEnd = null;
  +    private Map markerLastEnd = null;
   
       /**
        * Create a page viewport.
  @@ -176,27 +180,94 @@
       }
   
       /**
  -     * Add the start markers for this page.
  +     * Add the markers for this page.
  +     * Only the required markers are kept.
  +     * For "first-starting-within-page" it adds the markers
  +     * that are starting only if the marker class name is not
  +     * already added.
  +     * For "first-including-carryover" it adds any marker if
  +     * the marker class name is not already added.
  +     * For "last-starting-within-page" it adds all marks that
  +     * are starting, replacing earlier markers.
  +     * For "last-ending-within-page" it adds all markers that
  +     * are ending, replacing earlier markers.
  +     * 
  +     * Should this logic be placed in the Page layout manager.
        *
  -     * @param marks the map of start markers to add
  +     * @param marks the map of markers to add
  +     * @param start if the area being added is starting or ending
        */
       public void addMarkers(Map marks, boolean start) {
           if (start) {
  -            if (markerStart == null) {
  -                markerStart = new HashMap();
  +            if (markerFirstStart == null) {
  +                markerFirstStart = new HashMap();
  +            }
  +            if (markerLastStart == null) {
  +                markerLastStart = new HashMap();
  +            }
  +            if (markerFirstEnd == null) {
  +                markerFirstEnd = new HashMap();
  +            }
  +            // only put in new values, leave current
  +            for (Iterator iter = marks.keySet().iterator(); iter.hasNext();) {
  +                Object key = iter.next();
  +                if (!markerFirstStart.containsKey(key)) {
  +                    markerFirstStart.put(key, marks.get(key));
  +                }
  +                if (!markerFirstEnd.containsKey(key)) {
  +                    markerFirstEnd.put(key, marks.get(key));
  +                }
               }
  -            markerStart.putAll(marks);
  +            markerLastStart.putAll(marks);
           } else {
  -            if (markerEnd == null) {
  -                markerEnd = new HashMap();
  +            if (markerFirstEnd == null) {
  +                markerFirstEnd = new HashMap();
  +            }
  +            if (markerLastEnd == null) {
  +                markerLastEnd = new HashMap();
  +            }
  +            // only put in new values, leave current
  +            for (Iterator iter = marks.keySet().iterator(); iter.hasNext();) {
  +                Object key = iter.next();
  +                if (!markerFirstEnd.containsKey(key)) {
  +                    markerFirstEnd.put(key, marks.get(key));
  +                }
               }
  -            markerEnd.putAll(marks);
  +            markerLastEnd.putAll(marks);
           }
       }
   
  +    /**
  +     * Get a marker from this page.
  +     * This will retrieve a marker with the class name
  +     * and position.
  +     *
  +     * @param name The class name of the marker to retrieve 
  +     * @param pos the position to retrieve
  +     * @return Object the marker found or null
  +     */
       public Object getMarker(String name, int pos) {
  -        if (markerStart != null) {
  -            return markerStart.get(name);
  +        switch (pos) {
  +            case RetrievePosition.FSWP:
  +                if (markerFirstStart != null) {
  +                    return markerFirstStart.get(name);
  +                }
  +            break;
  +            case RetrievePosition.FIC:
  +                if (markerFirstStart != null) {
  +                    return markerFirstEnd.get(name);
  +                }
  +            break;
  +            case RetrievePosition.LSWP:
  +                if (markerFirstStart != null) {
  +                    return markerLastStart.get(name);
  +                }
  +            break;
  +            case RetrievePosition.LEWP:
  +                if (markerFirstStart != null) {
  +                    return markerLastEnd.get(name);
  +                }
  +            break;
           }
           return null;
       }
  
  
  
  1.30      +29 -2     xml-fop/src/org/apache/fop/layoutmgr/PageLayoutManager.java
  
  Index: PageLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/PageLayoutManager.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- PageLayoutManager.java    19 Feb 2003 05:49:28 -0000      1.29
  +++ PageLayoutManager.java    20 Feb 2003 02:47:45 -0000      1.30
  @@ -9,6 +9,7 @@
   
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.area.AreaTree;
  +import org.apache.fop.area.AreaTreeModel;
   import org.apache.fop.area.Area;
   import org.apache.fop.area.PageViewport;
   import org.apache.fop.area.Flow;
  @@ -27,6 +28,7 @@
   import org.apache.fop.fo.pagination.SimplePageMaster;
   import org.apache.fop.fo.pagination.PageNumberGenerator;
   import org.apache.fop.fo.properties.Constants;
  +import org.apache.fop.fo.properties.RetrieveBoundary;
   
   import java.util.ArrayList;
   import java.util.List;
  @@ -267,13 +269,17 @@
        * @param start true if starting marker area, false for ending
        */
       public void addMarkerMap(Map marks, boolean start) {
  -        getLogger().debug("adding markers: " + marks + ":" + start);
  +        //getLogger().debug("adding markers: " + marks + ":" + start);
           // add markers to page on area tree
           curPage.addMarkers(marks, start);
       }
   
       /**
        * Retrieve a marker from this layout manager.
  +     * If the boundary is page then it will only check the
  +     * current page. For page-sequence and document it will
  +     * lookup preceding pages from the area tree and try to find
  +     * a marker.
        *
        * @param name the marker class name to lookup
        * @param pos the position to locate the marker
  @@ -283,6 +289,27 @@
       public Marker retrieveMarker(String name, int pos, int boundary) {
           // get marker from the current markers on area tree
           Marker mark = (Marker)curPage.getMarker(name, pos);
  +        if (mark == null && boundary != RetrieveBoundary.PAGE) {
  +            // go back over pages until mark found
  +            // if document boundary then keep going
  +            boolean doc = boundary == RetrieveBoundary.DOCUMENT;
  +            AreaTreeModel atm = areaTree.getAreaTreeModel();
  +            int seq = atm.getPageSequenceCount();
  +            int page = atm.getPageCount(seq) - 1;
  +            while (page >= 0) {
  +                PageViewport pv = atm.getPage(seq, page);
  +                mark = (Marker)curPage.getMarker(name, pos);
  +                if (mark != null) {
  +                    return mark;
  +                }
  +                page--;
  +                if (page == -1 && doc && seq > 0) {
  +                    seq--;
  +                    page = atm.getPageCount(seq) - 1;
  +                }
  +            }
  +        }
  +
           return mark;
       }
   
  
  
  
  1.2       +17 -11    
xml-fop/src/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java
  
  Index: RetrieveMarkerLayoutManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RetrieveMarkerLayoutManager.java  19 Feb 2003 05:49:28 -0000      1.1
  +++ RetrieveMarkerLayoutManager.java  20 Feb 2003 02:47:45 -0000      1.2
  @@ -20,12 +20,16 @@
       private LayoutManager replaceLM = null;
       private boolean loaded = false;
       private String name;
  +    private int position;
  +    private int boundary;
   
       /**
        * Create a new block container layout manager.
        */
       public RetrieveMarkerLayoutManager(String n, int pos, int bound) {
           name = n;
  +        position = pos;
  +        boundary = bound;
       }
   
       public boolean generatesInlineAreas() {
  @@ -41,7 +45,6 @@
           if (replaceLM == null) {
               return null;
           }
  -        getLogger().debug("getting breaks");
           return replaceLM.getNextBreakPoss(context);
       }
   
  @@ -55,6 +58,7 @@
       }
   
       public boolean isFinished() {
  +        loadLM();
           if (replaceLM == null) {
               return true;
           }
  @@ -74,15 +78,17 @@
           loaded = true;
           if (replaceLM == null) {
               List list = new ArrayList();
  -            Marker marker = retrieveMarker(name, 0, 0);
  -            marker.addLayoutManager(list);
  -            if (list.size() > 0) {
  -                replaceLM =  (LayoutManager)list.get(0);
  -                replaceLM.setParentLM(this);
  -                replaceLM.init();
  -                getLogger().debug("retrieved: " + replaceLM + ":" + list.size());
  -            } else {
  -                getLogger().debug("found no marker with name: " + name);
  +            Marker marker = retrieveMarker(name, position, boundary);
  +            if (marker != null) {
  +                marker.addLayoutManager(list);
  +                if (list.size() > 0) {
  +                    replaceLM =  (LayoutManager)list.get(0);
  +                    replaceLM.setParentLM(this);
  +                    replaceLM.init();
  +                    getLogger().debug("retrieved: " + replaceLM + ":" + 
list.size());
  +                } else {
  +                    getLogger().debug("found no marker with name: " + name);
  +                }
               }
           }
       }
  
  
  
  1.29      +7 -3      xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java
  
  Index: BlockLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- BlockLayoutManager.java   19 Feb 2003 05:49:28 -0000      1.28
  +++ BlockLayoutManager.java   20 Feb 2003 02:47:45 -0000      1.29
  @@ -36,6 +36,8 @@
       int lineHeight = 14000;
       int follow = 2000;
   
  +    int iStartPos = 0;
  +
       protected List childBreaks = new ArrayList();
   
       /**
  @@ -56,6 +58,7 @@
           protected boolean preLoadNext() {
               while (proxy.hasNext()) {
                   LayoutManager lm = (LayoutManager) proxy.next();
  +                lm.setParentLM(BlockLayoutManager.this);
                   if(lm.generatesInlineAreas()) {
                       LineLayoutManager lineLM = createLineManager(lm);
                       listLMs.add(lineLM);
  @@ -208,8 +211,6 @@
           return breakPoss;
       }
   
  -    int iStartPos = 0;
  -
       public void addAreas(PositionIterator parentIter,
                            LayoutContext layoutContext) {
           getParentArea(null);
  @@ -239,6 +240,9 @@
                   childLM.addAreas(breakPosIter, lc);
               }
           }
  +
  +
  +        addMarkers(false);
   
           flush();
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to