]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Supports March 27 2000 spec
authorarved <arved@unknown>
Tue, 11 Jul 2000 02:32:06 +0000 (02:32 +0000)
committerarved <arved@unknown>
Tue, 11 Jul 2000 02:32:06 +0000 (02:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193474 13f79535-47bb-0310-9956-ffa450edef68

src/codegen/properties.xml
src/org/apache/fop/fo/pagination/LayoutMasterSet.java
src/org/apache/fop/fo/pagination/PageSequence.java
src/org/apache/fop/fo/pagination/SimplePageMaster.java
src/org/apache/fop/layout/PageMaster.java

index 9863b8ff48a17cf38504665c25441509ea2840c2..cbd53701cd1a37efc31eae9f0746b1b2ec09dbde 100644 (file)
@@ -85,8 +85,8 @@
     <default>0pt</default>
   </property>
   <property>
-    <name>page-master-name</name>
-    <class-name>PageMasterName</class-name>
+    <name>master-name</name>
+    <class-name>MasterName</class-name>
     <inherited>false</inherited>
     <datatype>String</datatype>
     <default></default>
        <datatype>String</datatype>
        <default></default> 
    </property>
+  <property>
+       <name>maximum-repeats</name>
+       <class-name>MaximumRepeats</class-name>
+       <inherited>false</inherited>
+       <datatype>String</datatype>
+       <default>no-limit</default> 
+   </property>
+  <property>
+       <name>page-position</name>
+       <class-name>PagePosition</class-name>
+       <inherited>false</inherited>
+       <datatype>
+      <enumeration>
+        <value const="FIRST">first</value>
+        <value const="LAST">last</value>
+        <value const="REST">rest</value>
+        <value const="ANY">any</value>
+      </enumeration>
+       </datatype>
+       <default>any</default> 
+   </property>
+  <property>
+       <name>odd-or-even</name>
+       <class-name>OddOrEven</class-name>
+       <inherited>false</inherited>
+       <datatype>
+      <enumeration>
+        <value const="ODD">odd</value>
+        <value const="EVEN">even</value>
+        <value const="ANY">any</value>
+      </enumeration>
+       </datatype>
+       <default>any</default> 
+   </property>
+  <property>
+       <name>blank-or-not-blank</name>
+       <class-name>BlankOrNotBlank</class-name>
+       <inherited>false</inherited>
+       <datatype>
+      <enumeration>
+        <value const="BLANK">blank</value>
+        <value const="NOT_BLANK">not-blank</value>
+        <value const="ANY">any</value>
+      </enumeration>
+       </datatype>
+       <default>any</default> 
+   </property>
 
 
 </property-list>
index ba38263a47424537ca1fdbe2409e6bdc04814771..b0f8c32de98186c8e69face5d6cc08a5aefa17a2 100644 (file)
@@ -54,6 +54,8 @@ package org.apache.fop.fo.pagination;
 import org.apache.fop.fo.*;
 import org.apache.fop.fo.properties.*;
 import org.apache.fop.apps.FOPException;                                  
+import org.apache.fop.layout.PageMaster;
+import org.apache.fop.apps.FOPException;                   
 
 // Java
 import java.util.Hashtable;
@@ -71,15 +73,18 @@ public class LayoutMasterSet extends FObj {
        return new LayoutMasterSet.Maker();
     }
 
-    private Hashtable layoutMasters;
-    private Root root;
+    private Hashtable simplePageMasters;
+       private Hashtable pageSequenceMasters;
+       private Root root;
        
     protected LayoutMasterSet(FObj parent, PropertyList propertyList)
        throws FOPException {
        super(parent, propertyList);
        this.name = "fo:layout-master-set";
 
-       this.layoutMasters = new Hashtable();
+       this.simplePageMasters = new Hashtable();
+       this.pageSequenceMasters = new Hashtable();
+       
        if (parent.getName().equals("fo:root")) {
            this.root = (Root)parent;
            root.setLayoutMasterSet(this);
@@ -90,11 +95,62 @@ public class LayoutMasterSet extends FObj {
        }
     }
 
-    protected void addLayoutMaster(String masterName, SimplePageMaster layoutMaster) {
-       this.layoutMasters.put(masterName, layoutMaster);
+       public PageMaster getNextPageMaster( String pageSequenceName,
+               int currentPageNumber, boolean thisIsFirstPage )
+               throws FOPException
+       {
+               PageMaster pm = null;
+               
+               PageSequenceMaster psm = getPageSequenceMaster( pageSequenceName );
+               if (null != psm)
+               {
+                       pm = psm.getNextPageMaster( currentPageNumber, thisIsFirstPage );
+               } else {
+                       SimplePageMaster spm = getSimplePageMaster( pageSequenceName );
+                       if (null == spm)
+                       {
+                               throw new FOPException( "'master-name' for 'fo:page-sequence'" +
+                                       "matches no 'simple-page-master' or 'page-sequence-master'" );
+                       }
+                       pm = spm.getNextPageMaster();
+               }
+               return pm;
+       }
+       
+    protected void addSimplePageMaster(
+               String masterName, SimplePageMaster simplePageMaster)
+               throws FOPException {
+       // check against duplication of master-name
+       if (existsName(masterName))
+               throw new FOPException( "'master-name' must be unique" +
+                       "across page-masters and page-sequence-masters" );
+       this.simplePageMasters.put(masterName, simplePageMaster);
+    }
+
+    protected SimplePageMaster getSimplePageMaster(String masterName) {
+               return (SimplePageMaster)this.simplePageMasters.get(masterName);
     }
 
-    protected SimplePageMaster getLayoutMaster(String masterName) {
-       return (SimplePageMaster)this.layoutMasters.get(masterName);
+    protected void addPageSequenceMaster(
+               String masterName, PageSequenceMaster pageSequenceMaster)
+               throws FOPException {
+       // check against duplication of master-name
+       if (existsName(masterName))
+               throw new FOPException( "'master-name' must be unique " +
+                       "across page-masters and page-sequence-masters" );
+       this.pageSequenceMasters.put(masterName, pageSequenceMaster);
     }
+
+    protected PageSequenceMaster getPageSequenceMaster(String masterName) {
+       return (PageSequenceMaster)this.pageSequenceMasters.get(masterName);
+    }
+       
+       private boolean existsName( String masterName )
+       {
+               if (simplePageMasters.containsKey(masterName) ||
+                       pageSequenceMasters.containsKey(masterName))
+                       return true;
+               else
+                       return false;
+       }
 }
index 4db265d52cd35ee2e69dc8337567f2f054e34a66..83411f9482b7ad26e628e93ff688c7ac26bd0221 100644 (file)
@@ -62,7 +62,6 @@ import org.apache.fop.layout.AreaContainer;
 import org.apache.fop.layout.AreaTree;
 import org.apache.fop.layout.Page;
 import org.apache.fop.layout.PageMaster;
-import org.apache.fop.layout.PageMasterFactory;
 import org.apache.fop.apps.FOPException;                   
 
 // Java
@@ -90,12 +89,13 @@ public class PageSequence extends FObj
     static final int AUTO_ODD = 3;
 
     protected Root root;
-    protected SequenceSpecification sequenceSpecification;
     protected Flow flow;
+    // protected Title title;
     protected StaticContent staticBefore;
     protected StaticContent staticAfter;
     protected LayoutMasterSet layoutMasterSet;
-
+       protected String masterName;
+       
     protected Page currentPage;
     protected int currentPageNumber = 0;
     protected static int runningPageNumberCounter = 0;  //keeps count of page number from previous PageSequence
@@ -119,6 +119,7 @@ public class PageSequence extends FObj
             new FOPException("page-sequence must be child of root, not "
             + parent.getName());
         }
+       
         layoutMasterSet = root.getLayoutMasterSet();
         thisIsFirstPage=true; // we are now on the first page of the page sequence
         InitialPageNumber ipn = (InitialPageNumber) this.properties.get("initial-page-number");
@@ -149,36 +150,26 @@ public class PageSequence extends FObj
                 throw new FOPException("\""+ipnValue+"\" is not a valid value for initial-page-number");
             }
         }
+
+        masterName = ((MasterName) this.properties.get("master-name")).getString();
     }
 
     protected Page makePage(AreaTree areaTree) throws FOPException {
-        PageMaster pageMaster;
         // layout this page sequence
-
+               
         // while there is still stuff in the flow, ask the
-        // sequence-specification for a new page 
-
-        if ( this.sequenceSpecification == null )
-        {
-            throw new FOPException("page-sequence is missing an"
-            + " sequence-specification");
-        }
+        // layoutMasterSet for a new page 
 
-        PageMasterFactory pmf =
-        this.sequenceSpecification.getFirstPageMasterFactory();
+               // page number is 0-indexed
+        PageMaster pageMaster =
+                       this.layoutMasterSet.getNextPageMaster(
+                       masterName, currentPageNumber, thisIsFirstPage );
 
-        pageMaster = pmf.getNextPageMaster();
-
-        while ( pageMaster == null )
+               // a legal alternative is to use the last sub-sequence
+               // specification. That's not done here.
+        if ( pageMaster == null )
         {
-            /* move on to next sequence specifier */
-            pmf = pmf.getNext();
-            if ( pmf == null )
-            {
-                throw new FOPException("out of sequence specifiers"
-                + " (FOP will eventually allow this)");
-            }
-            pageMaster = pmf.getNextPageMaster();
+               throw new FOPException("page masters exhausted");
         }
         return pageMaster.makePage(areaTree);
     }
@@ -257,11 +248,6 @@ public class PageSequence extends FObj
         this.flow = flow;
     }
 
-    protected void setSequenceSpecification(SequenceSpecification sequenceSpecification) {
-        this.sequenceSpecification = sequenceSpecification;
-        sequenceSpecification.setLayoutMasterSet(this.layoutMasterSet);
-    }
-
     public void setStaticContent(String name, StaticContent staticContent) {
         if ( name.equals("xsl-before") )
         {
index 52338b250acf2a417b2d8bac32e2a877ceeec50b..5562733548b98c89624628216bc56d030d04f0e9 100644 (file)
@@ -85,12 +85,12 @@ public class SimplePageMaster extends FObj {
 
        if (parent.getName().equals("fo:layout-master-set")) {
            this.layoutMasterSet = (LayoutMasterSet) parent;
-           String pm = this.properties.get("page-master-name").getString();
+           String pm = this.properties.get("master-name").getString();
            if (pm == null) {
                MessageHandler.errorln("WARNING: simple-page-master does not have "
-                                  + "a page-master-name and so is being ignored");
+                                  + "a master-name and so is being ignored");
            } else {
-               this.layoutMasterSet.addLayoutMaster(pm, this);
+               this.layoutMasterSet.addSimplePageMaster(pm, this);
            }
        } else {
            throw new FOPException("fo:simple-page-master must be child "
@@ -122,7 +122,11 @@ public class SimplePageMaster extends FObj {
            this.pageMaster.addAfter(this.regionAfter.makeRegion(contentRectangleXPosition,contentRectangleYPosition,contentRectangleWidth,contentRectangleHeight));
     }
 
-    PageMaster getPageMaster() {
+    public PageMaster getPageMaster() {
+       return this.pageMaster;
+    }
+
+    public PageMaster getNextPageMaster() {
        return this.pageMaster;
     }
 
index 67ca59b5a7ddc8bbe5a2eaf79693bcc44c8df030..a677ad4ffd43fbc22b367eb25f507dcd235b28bb 100644 (file)
@@ -111,6 +111,7 @@ public class PageMaster {
        if (this.end != null) {
            p.addEnd(end.makeAreaContainer());
        }
+       
        return p;
     }
 }