You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by gm...@apache.org on 2005/05/14 18:41:45 UTC

cvs commit: xml-fop/src/java/org/apache/fop/area Span.java PageViewport.java MainReference.java

gmazza      2005/05/14 09:41:45

  Modified:    src/java/org/apache/fop/layoutmgr
                        PageSequenceLayoutManager.java
               src/java/org/apache/fop/area Span.java PageViewport.java
                        MainReference.java
  Log:
  Placed the PSLM.curFlowIdx within the area.Span object, and added
  a few more convenience accessors to PV.  This will give us a little more
  flexibility in which LM's we place functionality.
  
  Revision  Changes    Path
  1.53      +8 -19     xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
  
  Index: PageSequenceLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- PageSequenceLayoutManager.java	14 May 2005 05:22:16 -0000	1.52
  +++ PageSequenceLayoutManager.java	14 May 2005 16:41:45 -0000	1.53
  @@ -68,13 +68,6 @@
       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;
  -
  -    /**
        * The FlowLayoutManager object, which processes
        * the single fo:flow of the fo:page-sequence
        */
  @@ -191,8 +184,8 @@
                   //algorithm so we have a BPD and IPD. This may subject to change later when we
                   //start handling more complex cases.
                   if (!firstPart) {
  -                    if (curFlowIdx < curPV.getCurrentSpan().getColumnCount()-1) {
  -                        curFlowIdx++;
  +                    if (curPV.getCurrentSpan().hasMoreFlows()) {
  +                        curPV.getCurrentSpan().moveToNextFlow();
                       } else  {
                           // if this is the first page that will be created by
                           // the current BlockSequence, it could have a break
  @@ -408,18 +401,16 @@
                    + spm.getMasterName() + "'.  FOP presently "
                    + "does not support this.");
               }
  -            curPV = new PageViewport(spm);
  +            curPV = new PageViewport(spm, pageNumberString);
           } catch (FOPException fopex) {
               throw new IllegalArgumentException("Cannot create page: " + fopex.getMessage());
           }
   
  -        curPV.setPageNumberString(pageNumberString);
           if (log.isDebugEnabled()) {
               log.debug("[" + curPV.getPageNumberString() + (bIsBlank ? "*" : "") + "]");
           }
   
           curPV.createSpan(false);
  -        curFlowIdx = 0;
           return curPV;
       }
   
  @@ -457,7 +448,6 @@
           log.debug("page finished: " + curPV.getPageNumberString() 
                   + ", current num: " + currentPageNum);
           curPV = null;
  -        curFlowIdx = -1;
       }
       
       /**
  @@ -473,7 +463,7 @@
           int aclass = childArea.getAreaClass();
   
           if (aclass == Area.CLASS_NORMAL) {
  -            return curPV.getCurrentSpan().getNormalFlow(curFlowIdx);
  +            return curPV.getCurrentFlow();
           } else if (aclass == Area.CLASS_BEFORE_FLOAT) {
               return curPV.getBodyRegion().getBeforeFloat();
           } else if (aclass == Area.CLASS_FOOTNOTE) {
  @@ -484,16 +474,15 @@
       }
   
       /**
  -     * Depending on the kind of break condition, make new column
  +     * Depending on the kind of break condition, move to next column
        * or page. May need to make an empty page if next page would
        * not have the desired "handedness".
        * @param breakVal - value of break-before or break-after trait.
        */
       private void handleBreakTrait(int breakVal) {
           if (breakVal == Constants.EN_COLUMN) {
  -            if (curFlowIdx < curPV.getCurrentSpan().getColumnCount()) {
  -                // Move to next column
  -                curFlowIdx++;
  +            if (curPV.getCurrentSpan().hasMoreFlows()) {
  +                curPV.getCurrentSpan().moveToNextFlow();
               } else {
                   curPV = makeNewPage(false, false, false);
               }
  
  
  
  1.8       +38 -1     xml-fop/src/java/org/apache/fop/area/Span.java
  
  Index: Span.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/Span.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Span.java	13 May 2005 19:16:53 -0000	1.7
  +++ Span.java	14 May 2005 16:41:45 -0000	1.8
  @@ -35,7 +35,8 @@
       private int colCount;
       private int colGap;
       private int colWidth; // width for each normal flow, calculated value
  -
  +    private int curFlowIdx;  // n-f-r-a currently being processed, zero-based
  +    
       /**
        * Create a span area with the number of columns for this span area.
        *
  @@ -48,6 +49,7 @@
           this.colCount = colCount;
           this.colGap = colGap;
           this.ipd = ipd;
  +        curFlowIdx = 0;
           createNormalFlows();
       }
   
  @@ -108,5 +110,40 @@
                       " available.");
           }
       }
  +    
  +    /**
  +     * Get the NormalFlow area currently being processed
  +     *
  +     * @return the current NormalFlow
  +     */
  +    public NormalFlow getCurrentFlow() {
  +        return getNormalFlow(curFlowIdx); 
  +    }
  +    
  +    /**
  +     * Indicate to the Span that the next column is being 
  +     * processed.
  +     *
  +     * @return the new NormalFlow (in the next column)
  +     */
  +    public NormalFlow moveToNextFlow() {
  +        if (hasMoreFlows()) {
  +            curFlowIdx++;
  +            return getNormalFlow(curFlowIdx);
  +        } else {
  +            throw new IllegalStateException("(Internal error.)" +
  +                    " No more flows left in span.");
  +        }
  +    }
  +    
  +    /**
  +     * Indicates if the Span has unprocessed flows. 
  +     *
  +     * @return true if Span can increment to the next flow, 
  +     * false otherwise.
  +     */
  +    public boolean hasMoreFlows() {
  +        return (curFlowIdx < colCount-1); 
  +    }
   }
   
  
  
  
  1.15      +56 -41    xml-fop/src/java/org/apache/fop/area/PageViewport.java
  
  Index: PageViewport.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/PageViewport.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PageViewport.java	13 May 2005 19:16:53 -0000	1.14
  +++ PageViewport.java	14 May 2005 16:41:45 -0000	1.15
  @@ -77,10 +77,11 @@
        * Create a page viewport.
        * @param spm SimplePageMaster indicating the page and region dimensions
        */
  -    public PageViewport(SimplePageMaster spm) {
  +    public PageViewport(SimplePageMaster spm, String pageStr) {
           this.spm = spm;
           int pageWidth = spm.getPageWidth().getValue();
           int pageHeight = spm.getPageHeight().getValue();
  +        pageNumberString = pageStr;
           viewArea = new Rectangle(0, 0, pageWidth, pageHeight);
           page = new Page(spm);
       }
  @@ -91,43 +92,14 @@
        * @param p Page Reference Area
        * @param bounds Page Viewport dimensions
        */
  -    public PageViewport(SimplePageMaster spm, Page p, Rectangle2D bounds) {
  +    public PageViewport(SimplePageMaster spm, String pageStr, Page p, Rectangle2D bounds) {
           this.spm = spm;
  +        this.pageNumberString = pageStr;
           this.page = p;
           this.viewArea = bounds;
       }
   
       /**
  -     * Convenience method to get BodyRegion of this PageViewport
  -     * @return BodyRegion object
  -     */
  -    public BodyRegion getBodyRegion() {
  -        return (BodyRegion) getPage().getRegionViewport(
  -                Constants.FO_REGION_BODY).getRegionReference();
  -    }    
  -
  -    /**
  -     * Convenience method to create a new Span for this
  -     * this PageViewport.
  -     * 
  -     * @param spanAll whether this is a single-column span
  -     * @return Span object created
  -     */
  -    public Span createSpan(boolean spanAll) {
  -        return getBodyRegion().getMainReference().createSpan(spanAll);
  -    }    
  -
  -    /**
  -     * Convenience method to get the span-reference-area currently
  -     * being processed
  -     * 
  -     * @return span currently being processed.
  -     */
  -    public Span getCurrentSpan() {
  -        return getBodyRegion().getMainReference().getCurrentSpan();
  -    }    
  -
  -    /**
        * Set if this viewport should clip.
        * @param c true if this viewport should clip
        */
  @@ -152,14 +124,6 @@
       }
   
       /**
  -     * Set the page number for this page.
  -     * @param num the string representing the page number
  -     */
  -    public void setPageNumberString(String num) {
  -        pageNumberString = num;
  -    }
  -
  -    /**
        * Get the page number of this page.
        * @return the string that represents this page
        */
  @@ -428,7 +392,8 @@
        */
       public Object clone() {
           Page p = (Page)page.clone();
  -        PageViewport ret = new PageViewport(spm, p, (Rectangle2D)viewArea.clone());
  +        PageViewport ret = new PageViewport(spm, pageNumberString, 
  +                p, (Rectangle2D)viewArea.clone());
           return ret;
       }
   
  @@ -456,4 +421,54 @@
       public SimplePageMaster getSPM() {
           return spm;
       }
  +    
  +    /**
  +     * Convenience method to get BodyRegion of this PageViewport
  +     * @return BodyRegion object
  +     */
  +    public BodyRegion getBodyRegion() {
  +        return (BodyRegion) getPage().getRegionViewport(
  +                Constants.FO_REGION_BODY).getRegionReference();
  +    }    
  +
  +    /**
  +     * Convenience method to create a new Span for this
  +     * this PageViewport.
  +     * 
  +     * @param spanAll whether this is a single-column span
  +     * @return Span object created
  +     */
  +    public Span createSpan(boolean spanAll) {
  +        return getBodyRegion().getMainReference().createSpan(spanAll);
  +    }    
  +
  +    /**
  +     * Convenience method to get the span-reference-area currently
  +     * being processed
  +     * 
  +     * @return span currently being processed.
  +     */
  +    public Span getCurrentSpan() {
  +        return getBodyRegion().getMainReference().getCurrentSpan();
  +    }
  +    
  +    /**
  +     * Convenience method to get the normal-flow-reference-area 
  +     * currently being processed
  +     * 
  +     * @return span currently being processed.
  +     */
  +    public NormalFlow getCurrentFlow() {
  +        return getCurrentSpan().getCurrentFlow();
  +    }
  +    
  +    /**
  +     * Convenience method to increment the Span to the 
  +     * next NormalFlow to be processed, and to return that flow.
  +     * 
  +     * @return the next NormalFlow in the Span.
  +     */
  +    public NormalFlow moveToNextFlow() {
  +        return getCurrentSpan().moveToNextFlow();
  +    }    
   }
  \ No newline at end of file
  
  
  
  1.7       +1 -1      xml-fop/src/java/org/apache/fop/area/MainReference.java
  
  Index: MainReference.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/MainReference.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MainReference.java	13 May 2005 19:16:53 -0000	1.6
  +++ MainReference.java	14 May 2005 16:41:45 -0000	1.7
  @@ -45,7 +45,7 @@
       /**
        * Add a span area to this area.
        *
  -     * @param span the span area to add
  +     * @param spanAll whether to make a single-column span
        */
       public Span createSpan(boolean spanAll) {
           RegionViewport rv = parent.getRegionViewport();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org