<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>
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;
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);
}
}
- 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;
+ }
}
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
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
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");
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);
}
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") )
{
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 "
this.pageMaster.addAfter(this.regionAfter.makeRegion(contentRectangleXPosition,contentRectangleYPosition,contentRectangleWidth,contentRectangleHeight));
}
- PageMaster getPageMaster() {
+ public PageMaster getPageMaster() {
+ return this.pageMaster;
+ }
+
+ public PageMaster getNextPageMaster() {
return this.pageMaster;
}
if (this.end != null) {
p.addEnd(end.makeAreaContainer());
}
+
return p;
}
}