vmote       2003/08/26 15:11:18

  Modified:    src/java/org/apache/fop/fo/pagination Region.java
                        SimplePageMaster.java
               src/java/org/apache/fop/layoutmgr PageLayoutManager.java
  Log:
  move logic from fo/pagination/SimplePageMaster.end() to 
layoutmgr/PageLayoutManager.createSimplePageMasterAreas()
  
  Revision  Changes    Path
  1.7       +1 -1      xml-fop/src/java/org/apache/fop/fo/pagination/Region.java
  
  Index: Region.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/Region.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Region.java       24 Aug 2003 18:04:06 -0000      1.6
  +++ Region.java       26 Aug 2003 22:11:17 -0000      1.7
  @@ -204,7 +204,7 @@
        * Area tree.
        * @return the region area class
        */
  -    protected abstract int getRegionAreaClass();
  +    public abstract int getRegionAreaClass();
   
       /**
        * Returns the default region name (xsl-region-before, xsl-region-start,
  
  
  
  1.7       +5 -67     
xml-fop/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
  
  Index: SimplePageMaster.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SimplePageMaster.java     24 Aug 2003 18:04:06 -0000      1.6
  +++ SimplePageMaster.java     26 Aug 2003 22:11:17 -0000      1.7
  @@ -51,7 +51,6 @@
   package org.apache.fop.fo.pagination;
   
   // Java
  -import java.awt.Rectangle;
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Map;
  @@ -60,16 +59,12 @@
   import org.xml.sax.Attributes;
   
   // FOP
  -import org.apache.fop.area.CTM;
  -import org.apache.fop.datatypes.FODimension;
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.FObj;
   import org.apache.fop.fo.FOTreeVisitor;
   import org.apache.fop.area.PageViewport;
   import org.apache.fop.area.Page;
  -import org.apache.fop.area.RegionViewport;
   import org.apache.fop.area.RegionReference;
  -import org.apache.fop.fo.properties.CommonMarginBlock;
   import org.apache.fop.layout.PageMaster;
   import org.apache.fop.apps.FOPException;
   
  @@ -119,67 +114,6 @@
       }
   
       /**
  -     * At the end of this element read all the information and create
  -     * the page master.
  -     */
  -    protected void end() {
  -        int pageWidth =
  -                this.properties.get("page-width").getLength().getValue();
  -        int pageHeight =
  -                this.properties.get("page-height").getLength().getValue();
  -        // this.properties.get("reference-orientation");
  -        // this.properties.get("writing-mode");
  -
  -        // Get absolute margin properties (top, left, bottom, right)
  -        CommonMarginBlock mProps = propMgr.getMarginProps();
  -
  -        /* Create the page reference area rectangle (0,0 is at top left
  -        * of the "page media" and y increases
  -        * when moving towards the bottom of the page.
  -        * The media rectangle itself is (0,0,pageWidth,pageHeight).
  -        */
  -        Rectangle pageRefRect =
  -                new Rectangle(mProps.marginLeft, mProps.marginTop,
  -                        pageWidth - mProps.marginLeft - mProps.marginRight,
  -                        pageHeight - mProps.marginTop - mProps.marginBottom);
  -
  -        // ??? KL shouldn't this take the viewport too???
  -        Page page = new Page();  // page reference area
  -
  -        // Set up the CTM on the page reference area based on writing-mode
  -        // and reference-orientation
  -        FODimension reldims = new FODimension(0, 0);
  -        CTM pageCTM = CTM.getCTMandRelDims(propMgr.getAbsRefOrient(),
  -                propMgr.getWritingMode(), pageRefRect, reldims);
  -
  -        // Create a RegionViewport/ reference area pair for each page region
  -
  -        boolean bHasBody = false;
  -
  -        for (Iterator regenum = regions.values().iterator();
  -             regenum.hasNext();) {
  -            Region r = (Region)regenum.next();
  -            RegionViewport rvp = r.makeRegionViewport(reldims, pageCTM);
  -            rvp.setRegion(r.makeRegionReferenceArea(rvp.getViewArea()));
  -            page.setRegion(r.getRegionAreaClass(), rvp);
  -            if (r.getRegionAreaClass() == RegionReference.BODY) {
  -                bHasBody = true;
  -            }
  -        }
  -
  -        if (!bHasBody) {
  -            getLogger().error("simple-page-master has no region-body");
  -        }
  -
  -        this.pageMaster = new PageMaster(new PageViewport(page,
  -                new Rectangle(0, 0, pageWidth, pageHeight)));
  -
  -        //  regions = null; // PageSequence access SimplePageMaster....
  -        children = null;
  -        properties = null;
  -    }
  -
  -    /**
        * @see org.apache.fop.fo.FObj#generatesReferenceAreas()
        */
       public boolean generatesReferenceAreas() {
  @@ -194,6 +128,10 @@
           return this.pageMaster;
       }
   
  +    public void setPageMaster(PageMaster pageMaster) {
  +        this.pageMaster = pageMaster;
  +    }
  +
       /**
        * Returns the next page master. For simple-page-master this is always the
        * same as the previous.
  @@ -251,7 +189,7 @@
        * Returns a Map of regions associated with this simple-page-master
        * @return the regions
        */
  -    protected Map getRegions() {
  +    public Map getRegions() {
           return regions;
       }
   
  
  
  
  1.5       +71 -3     xml-fop/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java
  
  Index: PageLayoutManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageLayoutManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PageLayoutManager.java    26 Aug 2003 20:32:26 -0000      1.4
  +++ PageLayoutManager.java    26 Aug 2003 22:11:17 -0000      1.5
  @@ -51,11 +51,14 @@
   package org.apache.fop.layoutmgr;
   
   import org.apache.fop.apps.FOPException;
  +
  +import org.apache.fop.area.CTM;
   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;
  +import org.apache.fop.area.Page;
   import org.apache.fop.area.RegionViewport;
   import org.apache.fop.area.RegionReference;
   import org.apache.fop.area.BodyRegion;
  @@ -64,20 +67,28 @@
   import org.apache.fop.area.BeforeFloat;
   import org.apache.fop.area.Footnote;
   import org.apache.fop.area.Resolveable;
  +
  +import org.apache.fop.datatypes.FODimension;
  +
   import org.apache.fop.fo.flow.Marker;
  -import org.apache.fop.fo.properties.Constants;
  +
   import org.apache.fop.fo.pagination.PageNumberGenerator;
   import org.apache.fop.fo.pagination.PageSequence;
   import org.apache.fop.fo.pagination.Region;
   import org.apache.fop.fo.properties.RetrieveBoundary;
   import org.apache.fop.fo.pagination.SimplePageMaster;
   import org.apache.fop.fo.pagination.StaticContent;
  +
  +import org.apache.fop.fo.properties.CommonMarginBlock;
  +import org.apache.fop.fo.properties.Constants;
  +
   import org.apache.fop.layout.PageMaster;
   
   import java.util.ArrayList;
   import java.util.List;
   import java.util.Map;
  -import org.apache.fop.apps.*;
  +import java.awt.Rectangle;
  +import java.util.Iterator;
   
   /**
    * LayoutManager for a PageSequence and its flow.
  @@ -715,7 +726,12 @@
                                    + "' does not map to the region-body in 
page-master '"
                                    + 
pageSequence.getCurrentSimplePageMaster().getMasterName() + "'");
           }
  -        PageMaster pageMaster = 
pageSequence.getCurrentSimplePageMaster().getPageMaster();
  +        SimplePageMaster currentSimplePageMaster = 
pageSequence.getCurrentSimplePageMaster();
  +        PageMaster pageMaster = currentSimplePageMaster.getPageMaster();
  +        if (pageMaster == null) {
  +            createSimplePageMasterAreas(currentSimplePageMaster);
  +        }
  +        pageMaster = pageSequence.getCurrentSimplePageMaster().getPageMaster();
           PageViewport p = pageMaster.makePage();
           return p;
           // The page will have a viewport/reference area pair defined
  @@ -728,6 +744,58 @@
   
           // handle the 'force-page-count'
           //forcePage(areaTree, firstAvailPageNumber);
  +    }
  +
  +    public void createSimplePageMasterAreas(SimplePageMaster node) {
  +        int pageWidth =
  +                node.properties.get("page-width").getLength().getValue();
  +        int pageHeight =
  +                node.properties.get("page-height").getLength().getValue();
  +        // Get absolute margin properties (top, left, bottom, right)
  +        CommonMarginBlock mProps = node.getPropertyManager().getMarginProps();
  +
  +      /* Create the page reference area rectangle (0,0 is at top left
  +       * of the "page media" and y increases
  +       * when moving towards the bottom of the page.
  +       * The media rectangle itself is (0,0,pageWidth,pageHeight).
  +       */
  +       Rectangle pageRefRect =
  +               new Rectangle(mProps.marginLeft, mProps.marginTop,
  +                       pageWidth - mProps.marginLeft - mProps.marginRight,
  +                       pageHeight - mProps.marginTop - mProps.marginBottom);
  +
  +       // ??? KL shouldn't this take the viewport too???
  +       Page page = new Page();  // page reference area
  +
  +       // Set up the CTM on the page reference area based on writing-mode
  +       // and reference-orientation
  +       FODimension reldims = new FODimension(0, 0);
  +       CTM pageCTM = 
CTM.getCTMandRelDims(node.getPropertyManager().getAbsRefOrient(),
  +               node.getPropertyManager().getWritingMode(), pageRefRect, reldims);
  +
  +       // Create a RegionViewport/ reference area pair for each page region
  +
  +       boolean bHasBody = false;
  +
  +       for (Iterator regenum = node.getRegions().values().iterator();
  +            regenum.hasNext();) {
  +           Region r = (Region)regenum.next();
  +           RegionViewport rvp = r.makeRegionViewport(reldims, pageCTM);
  +           rvp.setRegion(r.makeRegionReferenceArea(rvp.getViewArea()));
  +           page.setRegion(r.getRegionAreaClass(), rvp);
  +           if (r.getRegionAreaClass() == RegionReference.BODY) {
  +               bHasBody = true;
  +           }
  +       }
  +
  +       if (!bHasBody) {
  +           node.getLogger().error("simple-page-master has no region-body");
  +       }
  +
  +       node.setPageMaster(new PageMaster(new PageViewport(page,
  +               new Rectangle(0, 0, pageWidth, pageHeight))));
  +
  +
       }
   
   }
  
  
  

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

Reply via email to